Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
f2e999aa
Commit
f2e999aa
authored
Oct 26, 2016
by
Matt Holt
Committed by
GitHub
Oct 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1213 from mholt/simplify_code
Remove dead code, do struct alignment, simplify code
parents
c4d64a41
8cc3416b
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
34 additions
and
99 deletions
+34
-99
caddyfile/dispenser_test.go
caddyfile/dispenser_test.go
+2
-2
caddyfile/parse.go
caddyfile/parse.go
+4
-14
caddyhttp/browse/browse.go
caddyhttp/browse/browse.go
+1
-1
caddyhttp/fastcgi/fcgiclient.go
caddyhttp/fastcgi/fcgiclient.go
+0
-24
caddyhttp/fastcgi/fcgiclient_test.go
caddyhttp/fastcgi/fcgiclient_test.go
+1
-1
caddyhttp/markdown/markdown.go
caddyhttp/markdown/markdown.go
+1
-1
caddyhttp/proxy/proxy.go
caddyhttp/proxy/proxy.go
+6
-6
caddyhttp/proxy/upstream.go
caddyhttp/proxy/upstream.go
+15
-16
caddyhttp/rewrite/rewrite.go
caddyhttp/rewrite/rewrite.go
+1
-4
caddytls/config.go
caddytls/config.go
+1
-22
caddytls/crypto_test.go
caddytls/crypto_test.go
+1
-1
caddytls/handshake.go
caddytls/handshake.go
+0
-2
caddytls/user.go
caddytls/user.go
+1
-5
No files found.
caddyfile/dispenser_test.go
View file @
f2e999aa
...
@@ -64,7 +64,7 @@ func TestDispenser_NextArg(t *testing.T) {
...
@@ -64,7 +64,7 @@ func TestDispenser_NextArg(t *testing.T) {
}
}
assertNextArg
:=
func
(
expectedVal
string
,
loadAnother
bool
,
expectedCursor
int
)
{
assertNextArg
:=
func
(
expectedVal
string
,
loadAnother
bool
,
expectedCursor
int
)
{
if
d
.
NextArg
()
!=
true
{
if
!
d
.
NextArg
()
{
t
.
Error
(
"NextArg(): Should load next argument but got false instead"
)
t
.
Error
(
"NextArg(): Should load next argument but got false instead"
)
}
}
if
d
.
cursor
!=
expectedCursor
{
if
d
.
cursor
!=
expectedCursor
{
...
@@ -74,7 +74,7 @@ func TestDispenser_NextArg(t *testing.T) {
...
@@ -74,7 +74,7 @@ func TestDispenser_NextArg(t *testing.T) {
t
.
Errorf
(
"Val(): Expected '%s' but got '%s'"
,
expectedVal
,
val
)
t
.
Errorf
(
"Val(): Expected '%s' but got '%s'"
,
expectedVal
,
val
)
}
}
if
!
loadAnother
{
if
!
loadAnother
{
if
d
.
NextArg
()
!=
false
{
if
d
.
NextArg
()
{
t
.
Fatalf
(
"NextArg(): Should NOT load another argument, but got true instead (val: '%s')"
,
d
.
Val
())
t
.
Fatalf
(
"NextArg(): Should NOT load another argument, but got true instead (val: '%s')"
,
d
.
Val
())
}
}
if
d
.
cursor
!=
expectedCursor
{
if
d
.
cursor
!=
expectedCursor
{
...
...
caddyfile/parse.go
View file @
f2e999aa
...
@@ -16,8 +16,7 @@ import (
...
@@ -16,8 +16,7 @@ import (
// pass in nil instead.
// pass in nil instead.
func
Parse
(
filename
string
,
input
io
.
Reader
,
validDirectives
[]
string
)
([]
ServerBlock
,
error
)
{
func
Parse
(
filename
string
,
input
io
.
Reader
,
validDirectives
[]
string
)
([]
ServerBlock
,
error
)
{
p
:=
parser
{
Dispenser
:
NewDispenser
(
filename
,
input
),
validDirectives
:
validDirectives
}
p
:=
parser
{
Dispenser
:
NewDispenser
(
filename
,
input
),
validDirectives
:
validDirectives
}
blocks
,
err
:=
p
.
parseAll
()
return
p
.
parseAll
()
return
blocks
,
err
}
}
// allTokens lexes the entire input, but does not parse it.
// allTokens lexes the entire input, but does not parse it.
...
@@ -62,12 +61,7 @@ func (p *parser) parseAll() ([]ServerBlock, error) {
...
@@ -62,12 +61,7 @@ func (p *parser) parseAll() ([]ServerBlock, error) {
func
(
p
*
parser
)
parseOne
()
error
{
func
(
p
*
parser
)
parseOne
()
error
{
p
.
block
=
ServerBlock
{
Tokens
:
make
(
map
[
string
][]
Token
)}
p
.
block
=
ServerBlock
{
Tokens
:
make
(
map
[
string
][]
Token
)}
err
:=
p
.
begin
()
return
p
.
begin
()
if
err
!=
nil
{
return
err
}
return
nil
}
}
func
(
p
*
parser
)
begin
()
error
{
func
(
p
*
parser
)
begin
()
error
{
...
@@ -76,6 +70,7 @@ func (p *parser) begin() error {
...
@@ -76,6 +70,7 @@ func (p *parser) begin() error {
}
}
err
:=
p
.
addresses
()
err
:=
p
.
addresses
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -86,12 +81,7 @@ func (p *parser) begin() error {
...
@@ -86,12 +81,7 @@ func (p *parser) begin() error {
return
nil
return
nil
}
}
err
=
p
.
blockContents
()
return
p
.
blockContents
()
if
err
!=
nil
{
return
err
}
return
nil
}
}
func
(
p
*
parser
)
addresses
()
error
{
func
(
p
*
parser
)
addresses
()
error
{
...
...
caddyhttp/browse/browse.go
View file @
f2e999aa
...
@@ -101,12 +101,12 @@ func (l Listing) BreadcrumbMap() map[string]string {
...
@@ -101,12 +101,12 @@ func (l Listing) BreadcrumbMap() map[string]string {
// FileInfo is the info about a particular file or directory
// FileInfo is the info about a particular file or directory
type
FileInfo
struct
{
type
FileInfo
struct
{
IsDir
bool
Name
string
Name
string
Size
int64
Size
int64
URL
string
URL
string
ModTime
time
.
Time
ModTime
time
.
Time
Mode
os
.
FileMode
Mode
os
.
FileMode
IsDir
bool
}
}
// HumanSize returns the size of the file as a human-readable string
// HumanSize returns the size of the file as a human-readable string
...
...
caddyhttp/fastcgi/fcgiclient.go
View file @
f2e999aa
...
@@ -44,7 +44,6 @@ const FCGINullRequestID uint8 = 0
...
@@ -44,7 +44,6 @@ const FCGINullRequestID uint8 = 0
// FCGIKeepConn describes keep connection mode.
// FCGIKeepConn describes keep connection mode.
const
FCGIKeepConn
uint8
=
1
const
FCGIKeepConn
uint8
=
1
const
doubleCRLF
=
"
\r\n\r\n
"
const
(
const
(
// BeginRequest is the begin request flag.
// BeginRequest is the begin request flag.
...
@@ -261,29 +260,6 @@ func (c *FCGIClient) writePairs(recType uint8, pairs map[string]string) error {
...
@@ -261,29 +260,6 @@ func (c *FCGIClient) writePairs(recType uint8, pairs map[string]string) error {
return
nil
return
nil
}
}
func
readSize
(
s
[]
byte
)
(
uint32
,
int
)
{
if
len
(
s
)
==
0
{
return
0
,
0
}
size
,
n
:=
uint32
(
s
[
0
]),
1
if
size
&
(
1
<<
7
)
!=
0
{
if
len
(
s
)
<
4
{
return
0
,
0
}
n
=
4
size
=
binary
.
BigEndian
.
Uint32
(
s
)
size
&^=
1
<<
31
}
return
size
,
n
}
func
readString
(
s
[]
byte
,
size
uint32
)
string
{
if
size
>
uint32
(
len
(
s
))
{
return
""
}
return
string
(
s
[
:
size
])
}
func
encodeSize
(
b
[]
byte
,
size
uint32
)
int
{
func
encodeSize
(
b
[]
byte
,
size
uint32
)
int
{
if
size
>
127
{
if
size
>
127
{
size
|=
1
<<
31
size
|=
1
<<
31
...
...
caddyhttp/fastcgi/fcgiclient_test.go
View file @
f2e999aa
...
@@ -155,7 +155,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
...
@@ -155,7 +155,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
fcgi
.
Close
()
fcgi
.
Close
()
time
.
Sleep
(
1
*
time
.
Second
)
time
.
Sleep
(
1
*
time
.
Second
)
if
bytes
.
Index
(
content
,
[]
byte
(
"FAILED"
))
>=
0
{
if
bytes
.
Contains
(
content
,
[]
byte
(
"FAILED"
))
{
globalt
.
Error
(
"Server return failed message"
)
globalt
.
Error
(
"Server return failed message"
)
}
}
...
...
caddyhttp/markdown/markdown.go
View file @
f2e999aa
...
@@ -144,7 +144,7 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
...
@@ -144,7 +144,7 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
}
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/html; charset=utf-8"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/html; charset=utf-8"
)
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
int64
(
len
(
html
)),
10
))
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
Itoa
(
len
(
html
)
))
httpserver
.
SetLastModifiedHeader
(
w
,
lastModTime
)
httpserver
.
SetLastModifiedHeader
(
w
,
lastModTime
)
if
r
.
Method
==
http
.
MethodGet
{
if
r
.
Method
==
http
.
MethodGet
{
w
.
Write
(
html
)
w
.
Write
(
html
)
...
...
caddyhttp/proxy/proxy.go
View file @
f2e999aa
...
@@ -47,16 +47,16 @@ type UpstreamHostDownFunc func(*UpstreamHost) bool
...
@@ -47,16 +47,16 @@ type UpstreamHostDownFunc func(*UpstreamHost) bool
// UpstreamHost represents a single proxy upstream
// UpstreamHost represents a single proxy upstream
type
UpstreamHost
struct
{
type
UpstreamHost
struct
{
Conns
int64
// must be first field to be 64-bit aligned on 32-bit systems
Conns
int64
// must be first field to be 64-bit aligned on 32-bit systems
MaxConns
int64
Name
string
// hostname of this upstream host
Name
string
// hostname of this upstream host
ReverseProxy
*
ReverseProxy
Fails
int32
FailTimeout
time
.
Duration
Unhealthy
bool
UpstreamHeaders
http
.
Header
UpstreamHeaders
http
.
Header
DownstreamHeaders
http
.
Header
DownstreamHeaders
http
.
Header
FailTimeout
time
.
Duration
CheckDown
UpstreamHostDownFunc
CheckDown
UpstreamHostDownFunc
WithoutPathPrefix
string
WithoutPathPrefix
string
MaxConns
int64
ReverseProxy
*
ReverseProxy
Fails
int32
Unhealthy
bool
}
}
// Down checks whether the upstream host is down or not.
// Down checks whether the upstream host is down or not.
...
...
caddyhttp/proxy/upstream.go
View file @
f2e999aa
...
@@ -27,10 +27,7 @@ type staticUpstream struct {
...
@@ -27,10 +27,7 @@ type staticUpstream struct {
Hosts
HostPool
Hosts
HostPool
Policy
Policy
Policy
Policy
KeepAlive
int
KeepAlive
int
insecureSkipVerify
bool
FailTimeout
time
.
Duration
FailTimeout
time
.
Duration
MaxFails
int32
TryDuration
time
.
Duration
TryDuration
time
.
Duration
TryInterval
time
.
Duration
TryInterval
time
.
Duration
MaxConns
int64
MaxConns
int64
...
@@ -42,6 +39,8 @@ type staticUpstream struct {
...
@@ -42,6 +39,8 @@ type staticUpstream struct {
}
}
WithoutPathPrefix
string
WithoutPathPrefix
string
IgnoredSubPaths
[]
string
IgnoredSubPaths
[]
string
insecureSkipVerify
bool
MaxFails
int32
}
}
// NewStaticUpstreams parses the configuration input and sets up
// NewStaticUpstreams parses the configuration input and sets up
...
...
caddyhttp/rewrite/rewrite.go
View file @
f2e999aa
...
@@ -216,10 +216,7 @@ func (r *ComplexRule) matchExt(rPath string) bool {
...
@@ -216,10 +216,7 @@ func (r *ComplexRule) matchExt(rPath string) bool {
}
}
}
}
if
mustUse
{
return
!
mustUse
return
false
}
return
true
}
}
func
(
r
*
ComplexRule
)
regexpMatches
(
rPath
string
)
[]
string
{
func
(
r
*
ComplexRule
)
regexpMatches
(
rPath
string
)
[]
string
{
...
...
caddytls/config.go
View file @
f2e999aa
...
@@ -217,7 +217,7 @@ func (c *Config) StorageFor(caURL string) (Storage, error) {
...
@@ -217,7 +217,7 @@ func (c *Config) StorageFor(caURL string) (Storage, error) {
// MakeTLSConfig reduces configs into a single tls.Config.
// MakeTLSConfig reduces configs into a single tls.Config.
// If TLS is to be disabled, a nil tls.Config will be returned.
// If TLS is to be disabled, a nil tls.Config will be returned.
func
MakeTLSConfig
(
configs
[]
*
Config
)
(
*
tls
.
Config
,
error
)
{
func
MakeTLSConfig
(
configs
[]
*
Config
)
(
*
tls
.
Config
,
error
)
{
if
configs
==
nil
||
len
(
configs
)
==
0
{
if
len
(
configs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -418,27 +418,6 @@ var supportedCiphersMap = map[string]uint16{
...
@@ -418,27 +418,6 @@ var supportedCiphersMap = map[string]uint16{
"RSA-3DES-EDE-CBC-SHA"
:
tls
.
TLS_RSA_WITH_3DES_EDE_CBC_SHA
,
"RSA-3DES-EDE-CBC-SHA"
:
tls
.
TLS_RSA_WITH_3DES_EDE_CBC_SHA
,
}
}
// List of supported cipher suites in descending order of preference.
// Ordering is very important! Getting the wrong order will break
// mainstream clients, especially with HTTP/2.
//
// Note that TLS_FALLBACK_SCSV is not in this list since it is always
// added manually.
var
supportedCiphers
=
[]
uint16
{
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_256_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
,
tls
.
TLS_RSA_WITH_3DES_EDE_CBC_SHA
,
}
// List of all the ciphers we want to use by default
// List of all the ciphers we want to use by default
var
defaultCiphers
=
[]
uint16
{
var
defaultCiphers
=
[]
uint16
{
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
...
...
caddytls/crypto_test.go
View file @
f2e999aa
...
@@ -120,7 +120,7 @@ func TestStandaloneTLSTicketKeyRotation(t *testing.T) {
...
@@ -120,7 +120,7 @@ func TestStandaloneTLSTicketKeyRotation(t *testing.T) {
t
.
Errorf
(
"Expected TLS ticket keys in use: %d; Got instead: %d."
,
rounds
,
pkt
.
keysInUse
)
t
.
Errorf
(
"Expected TLS ticket keys in use: %d; Got instead: %d."
,
rounds
,
pkt
.
keysInUse
)
return
return
}
}
if
c
.
SessionTicketsDisabled
==
true
{
if
c
.
SessionTicketsDisabled
{
t
.
Error
(
"Session tickets have been disabled unexpectedly."
)
t
.
Error
(
"Session tickets have been disabled unexpectedly."
)
return
return
}
}
...
...
caddytls/handshake.go
View file @
f2e999aa
...
@@ -301,5 +301,3 @@ var failedIssuanceMu sync.RWMutex
...
@@ -301,5 +301,3 @@ var failedIssuanceMu sync.RWMutex
// If this value is recent, do not make any on-demand certificate requests.
// If this value is recent, do not make any on-demand certificate requests.
var
lastIssueTime
time
.
Time
var
lastIssueTime
time
.
Time
var
lastIssueTimeMu
sync
.
Mutex
var
lastIssueTimeMu
sync
.
Mutex
var
errNoCert
=
errors
.
New
(
"no certificate available"
)
caddytls/user.go
View file @
f2e999aa
...
@@ -118,11 +118,7 @@ func getUser(storage Storage, email string) (User, error) {
...
@@ -118,11 +118,7 @@ func getUser(storage Storage, email string) (User, error) {
// load their private key
// load their private key
user
.
key
,
err
=
loadPrivateKey
(
userData
.
Key
)
user
.
key
,
err
=
loadPrivateKey
(
userData
.
Key
)
if
err
!=
nil
{
return
user
,
err
return
user
,
err
}
return
user
,
nil
}
}
// saveUser persists a user's key and account registration
// saveUser persists a user's key and account registration
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment