admin: Disable host checking if wildcard interface is specified

To clarify, listening on wildcard interfaces is NOT the default and
should only be done under certain circumstances and when you know
what you're doing. Emits a warning in the log.

Fixes https://github.com/caddyserver/caddy-docker/issues/71
This commit is contained in:
Matthew Holt
2020-04-16 11:41:32 -06:00
parent 829e36d535
commit f5ccb904a3
2 changed files with 31 additions and 13 deletions

View File

@@ -302,6 +302,16 @@ func (na NetworkAddress) isLoopback() bool {
return false
}
func (na NetworkAddress) isWildcardInterface() bool {
if na.Host == "" {
return true
}
if ip := net.ParseIP(na.Host); ip != nil {
return ip.IsUnspecified()
}
return false
}
func (na NetworkAddress) port() string {
if na.StartPort == na.EndPort {
return strconv.FormatUint(uint64(na.StartPort), 10)