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
ee754b4a
Commit
ee754b4a
authored
May 21, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes
parent
5f72b743
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
31 deletions
+43
-31
config/config.go
config/config.go
+15
-2
config/parse/parsing.go
config/parse/parsing.go
+1
-1
config/setup/tls.go
config/setup/tls.go
+2
-4
main.go
main.go
+25
-24
No files found.
config/config.go
View file @
ee754b4a
...
...
@@ -97,11 +97,24 @@ func ArrangeBindings(allConfigs []server.Config) (map[*net.TCPAddr][]server.Conf
// Group configs by bind address
for
_
,
conf
:=
range
allConfigs
{
a
ddr
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
conf
.
Address
())
newA
ddr
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
conf
.
Address
())
if
err
!=
nil
{
return
addresses
,
errors
.
New
(
"Could not serve "
+
conf
.
Address
()
+
" - "
+
err
.
Error
())
}
addresses
[
addr
]
=
append
(
addresses
[
addr
],
conf
)
// Make sure to compare the string representation of the address,
// not the pointer, since a new *TCPAddr is created each time.
var
existing
bool
for
addr
:=
range
addresses
{
if
addr
.
String
()
==
newAddr
.
String
()
{
addresses
[
addr
]
=
append
(
addresses
[
addr
],
conf
)
existing
=
true
break
}
}
if
!
existing
{
addresses
[
newAddr
]
=
append
(
addresses
[
newAddr
],
conf
)
}
}
// Don't allow HTTP and HTTPS to be served on the same address
...
...
config/parse/parsing.go
View file @
ee754b4a
...
...
@@ -268,7 +268,7 @@ func standardAddress(str string) (host, port string, err error) {
}
host
,
port
,
err
=
net
.
SplitHostPort
(
str
)
if
err
!=
nil
{
if
err
!=
nil
&&
schemePort
==
""
{
host
,
port
,
err
=
net
.
SplitHostPort
(
str
+
":"
)
// tack on empty port
}
if
err
!=
nil
&&
schemePort
!=
""
{
...
...
config/setup/tls.go
View file @
ee754b4a
...
...
@@ -14,10 +14,8 @@ func TLS(c *Controller) (middleware.Middleware, error) {
c
.
TLS
.
Enabled
=
true
if
c
.
Port
==
"http"
{
c
.
TLS
.
Enabled
=
false
log
.
Printf
(
"Warning: TLS was disabled on host http://%s."
+
" Make sure you are specifying https://%s in your config (if you haven't already)."
+
" If you meant to serve tls on port 80,"
+
" specify port 80 in your config (https://%s:80)."
,
c
.
Host
,
c
.
Host
,
c
.
Host
)
log
.
Printf
(
"Warning: TLS disabled for %s://%s. To force TLS over the plaintext HTTP port, "
+
"specify port 80 explicitly (https://%s:80)."
,
c
.
Port
,
c
.
Host
,
c
.
Host
)
}
for
c
.
Next
()
{
...
...
main.go
View file @
ee754b4a
...
...
@@ -78,39 +78,40 @@ func main() {
}(
s
)
app
.
Servers
=
append
(
app
.
Servers
,
s
)
}
if
!
app
.
Quiet
{
var
checkedFdLimit
bool
for
addr
,
configs
:=
range
addresses
{
for
_
,
conf
:=
range
configs
{
// Print address of site
fmt
.
Println
(
conf
.
Address
())
// Note if non-localhost site resolves to loopback interface
if
addr
.
IP
.
IsLoopback
()
&&
!
isLocalhost
(
conf
.
Host
)
{
fmt
.
Printf
(
"Notice: %s is only accessible on this machine (%s)
\n
"
,
conf
.
Host
,
addr
.
IP
.
String
())
}
// Show initialization output
if
!
app
.
Quiet
{
var
checkedFdLimit
bool
for
addr
,
configs
:=
range
addresses
{
for
_
,
conf
:=
range
configs
{
// Print address of site
fmt
.
Println
(
conf
.
Address
())
// Note if non-localhost site resolves to loopback interface
if
addr
.
IP
.
IsLoopback
()
&&
!
isLocalhost
(
conf
.
Host
)
{
fmt
.
Printf
(
"Notice: %s is only accessible on this machine (%s)
\n
"
,
conf
.
Host
,
addr
.
IP
.
String
())
}
}
// Warn if ulimit is too low for production sites
if
(
runtime
.
GOOS
==
"linux"
||
runtime
.
GOOS
==
"darwin"
)
&&
!
addr
.
IP
.
IsLoopback
()
&&
!
checkedFdLimit
{
out
,
err
:=
exec
.
Command
(
"ulimit"
,
"-n"
)
.
Output
()
if
err
==
nil
{
// Note that an error here need not be reported
lim
,
err
:=
strconv
.
Atoi
(
string
(
bytes
.
TrimSpace
(
out
)))
if
err
==
nil
&&
lim
<
4096
{
fmt
.
Printf
(
"Warning: File descriptor limit is too low (%d) for production sites
\n
"
,
lim
)
}
checkedFdLimit
=
true
// Warn if ulimit is too low for production sites
if
(
runtime
.
GOOS
==
"linux"
||
runtime
.
GOOS
==
"darwin"
)
&&
!
addr
.
IP
.
IsLoopback
()
&&
!
checkedFdLimit
{
out
,
err
:=
exec
.
Command
(
"ulimit"
,
"-n"
)
.
Output
()
if
err
==
nil
{
// Note that an error here need not be reported
lim
,
err
:=
strconv
.
Atoi
(
string
(
bytes
.
TrimSpace
(
out
)))
if
err
==
nil
&&
lim
<
4096
{
fmt
.
Printf
(
"Warning: File descriptor limit is too low (%d) for production sites
\n
"
,
lim
)
}
checkedFdLimit
=
true
}
}
}
}
// Wait for all listeners to stop
app
.
Wg
.
Wait
()
}
...
...
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