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
287543a0
Commit
287543a0
authored
Sep 11, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #238 from LK4D4/fix_vet
Fix all vet warnings and add vet check to CI
parents
7545755b
f2e68043
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
17 deletions
+48
-17
.travis.yml
.travis.yml
+7
-1
config/setup/basicauth_test.go
config/setup/basicauth_test.go
+1
-1
config/setup/controllertest.go
config/setup/controllertest.go
+1
-1
config/setup/gzip.go
config/setup/gzip.go
+2
-2
config/setup/rewrite_test.go
config/setup/rewrite_test.go
+8
-8
server/server.go
server/server.go
+29
-4
No files found.
.travis.yml
View file @
287543a0
...
...
@@ -5,4 +5,10 @@ go:
-
1.5
-
tip
script
:
go test ./...
install
:
-
go get -d ./...
-
go get golang.org/x/tools/cmd/vet
script
:
-
go vet ./...
-
go test ./...
config/setup/basicauth_test.go
View file @
287543a0
...
...
@@ -117,7 +117,7 @@ md5:$apr1$l42y8rex$pOA2VJ0x/0TwaFeAF9nX61`
pwd
=
fmt
.
Sprintf
(
"%s%d"
,
pwd
,
j
+
1
)
}
if
!
actualRule
.
Password
(
pwd
)
||
actualRule
.
Password
(
test
.
password
+
"!"
)
{
t
.
Errorf
(
"Test %d, rule %d: Expected password '%
s', got '%s
'"
,
t
.
Errorf
(
"Test %d, rule %d: Expected password '%
v', got '%v
'"
,
i
,
j
,
test
.
password
,
actualRule
.
Password
)
}
...
...
config/setup/controllertest.go
View file @
287543a0
...
...
@@ -28,5 +28,5 @@ var EmptyNext = middleware.HandlerFunc(func(w http.ResponseWriter, r *http.Reque
// SameNext does a pointer comparison between next1 and next2.
func
SameNext
(
next1
,
next2
middleware
.
Handler
)
bool
{
return
fmt
.
Sprintf
(
"%
p"
,
next1
)
==
fmt
.
Sprintf
(
"%p
"
,
next2
)
return
fmt
.
Sprintf
(
"%
v"
,
next1
)
==
fmt
.
Sprintf
(
"%v
"
,
next2
)
}
config/setup/gzip.go
View file @
287543a0
...
...
@@ -27,8 +27,8 @@ func gzipParse(c *Controller) ([]gzip.Config, error) {
for
c
.
Next
()
{
config
:=
gzip
.
Config
{}
pathFilter
:=
gzip
.
PathFilter
{
make
(
gzip
.
Set
)}
extFilter
:=
gzip
.
ExtFilter
{
make
(
gzip
.
Set
)}
pathFilter
:=
gzip
.
PathFilter
{
IgnoredPaths
:
make
(
gzip
.
Set
)}
extFilter
:=
gzip
.
ExtFilter
{
Exts
:
make
(
gzip
.
Set
)}
// No extra args expected
if
len
(
c
.
RemainingArgs
())
>
0
{
...
...
config/setup/rewrite_test.go
View file @
287543a0
...
...
@@ -42,17 +42,17 @@ func TestRewriteParse(t *testing.T) {
expected
[]
rewrite
.
Rule
}{
{
`rewrite /from /to`
,
false
,
[]
rewrite
.
Rule
{
rewrite
.
SimpleRule
{
"/from"
,
"/to"
},
rewrite
.
SimpleRule
{
From
:
"/from"
,
To
:
"/to"
},
}},
{
`rewrite /from /to
rewrite a b`
,
false
,
[]
rewrite
.
Rule
{
rewrite
.
SimpleRule
{
"/from"
,
"/to"
},
rewrite
.
SimpleRule
{
"a"
,
"b"
},
rewrite
.
SimpleRule
{
From
:
"/from"
,
To
:
"/to"
},
rewrite
.
SimpleRule
{
From
:
"a"
,
To
:
"b"
},
}},
{
`rewrite a`
,
true
,
[]
rewrite
.
Rule
{}},
{
`rewrite`
,
true
,
[]
rewrite
.
Rule
{}},
{
`rewrite a b c`
,
true
,
[]
rewrite
.
Rule
{
rewrite
.
SimpleRule
{
"a"
,
"b"
},
rewrite
.
SimpleRule
{
From
:
"a"
,
To
:
"b"
},
}},
}
...
...
@@ -98,14 +98,14 @@ func TestRewriteParse(t *testing.T) {
r .*
to /to
}`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
RegexpRule
{
"/"
,
"/to"
,
nil
,
regexp
.
MustCompile
(
".*"
)},
&
rewrite
.
RegexpRule
{
Base
:
"/"
,
To
:
"/to"
,
Regexp
:
regexp
.
MustCompile
(
".*"
)},
}},
{
`rewrite {
regexp .*
to /to
ext / html txt
}`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
RegexpRule
{
"/"
,
"/to"
,
[]
string
{
"/"
,
"html"
,
"txt"
},
regexp
.
MustCompile
(
".*"
)},
&
rewrite
.
RegexpRule
{
Base
:
"/"
,
To
:
"/to"
,
Exts
:
[]
string
{
"/"
,
"html"
,
"txt"
},
Regexp
:
regexp
.
MustCompile
(
".*"
)},
}},
{
`rewrite /path {
r rr
...
...
@@ -116,8 +116,8 @@ func TestRewriteParse(t *testing.T) {
to /to
}
`
,
false
,
[]
rewrite
.
Rule
{
&
rewrite
.
RegexpRule
{
"/path"
,
"/dest"
,
nil
,
regexp
.
MustCompile
(
"rr"
)},
&
rewrite
.
RegexpRule
{
"/"
,
"/to"
,
nil
,
regexp
.
MustCompile
(
"[a-z]+"
)},
&
rewrite
.
RegexpRule
{
Base
:
"/path"
,
To
:
"/dest"
,
Regexp
:
regexp
.
MustCompile
(
"rr"
)},
&
rewrite
.
RegexpRule
{
Base
:
"/"
,
To
:
"/to"
,
Regexp
:
regexp
.
MustCompile
(
"[a-z]+"
)},
}},
{
`rewrite {
to /to
...
...
server/server.go
View file @
287543a0
...
...
@@ -113,6 +113,34 @@ func (s *Server) Serve() error {
return
server
.
ListenAndServe
()
}
// copy from net/http/transport.go
func
cloneTLSConfig
(
cfg
*
tls
.
Config
)
*
tls
.
Config
{
if
cfg
==
nil
{
return
&
tls
.
Config
{}
}
return
&
tls
.
Config
{
Rand
:
cfg
.
Rand
,
Time
:
cfg
.
Time
,
Certificates
:
cfg
.
Certificates
,
NameToCertificate
:
cfg
.
NameToCertificate
,
GetCertificate
:
cfg
.
GetCertificate
,
RootCAs
:
cfg
.
RootCAs
,
NextProtos
:
cfg
.
NextProtos
,
ServerName
:
cfg
.
ServerName
,
ClientAuth
:
cfg
.
ClientAuth
,
ClientCAs
:
cfg
.
ClientCAs
,
InsecureSkipVerify
:
cfg
.
InsecureSkipVerify
,
CipherSuites
:
cfg
.
CipherSuites
,
PreferServerCipherSuites
:
cfg
.
PreferServerCipherSuites
,
SessionTicketsDisabled
:
cfg
.
SessionTicketsDisabled
,
SessionTicketKey
:
cfg
.
SessionTicketKey
,
ClientSessionCache
:
cfg
.
ClientSessionCache
,
MinVersion
:
cfg
.
MinVersion
,
MaxVersion
:
cfg
.
MaxVersion
,
CurvePreferences
:
cfg
.
CurvePreferences
,
}
}
// ListenAndServeTLSWithSNI serves TLS with Server Name Indication (SNI) support, which allows
// multiple sites (different hostnames) to be served from the same address. This method is
// adapted directly from the std lib's net/http ListenAndServeTLS function, which was
...
...
@@ -123,10 +151,7 @@ func ListenAndServeTLSWithSNI(srv *http.Server, tlsConfigs []TLSConfig) error {
addr
=
":https"
}
config
:=
new
(
tls
.
Config
)
if
srv
.
TLSConfig
!=
nil
{
*
config
=
*
srv
.
TLSConfig
}
config
:=
cloneTLSConfig
(
srv
.
TLSConfig
)
if
config
.
NextProtos
==
nil
{
config
.
NextProtos
=
[]
string
{
"http/1.1"
}
}
...
...
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