From f5ccb904a3db2bffd980feee685afaa762224cb2 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 16 Apr 2020 11:41:32 -0600 Subject: 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 --- listeners.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'listeners.go') diff --git a/listeners.go b/listeners.go index bfbe6dd..39bd811 100644 --- a/listeners.go +++ b/listeners.go @@ -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) -- cgit v1.2.3