|
@@ -8,7 +8,6 @@ import (
|
|
|
"strings"
|
|
|
"sync"
|
|
|
|
|
|
- "github.com/docker/docker/libnetwork/resolvconf/dns"
|
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
)
|
|
@@ -59,20 +58,26 @@ func Path() string {
|
|
|
return pathAfterSystemdDetection
|
|
|
}
|
|
|
|
|
|
-var (
|
|
|
- // Note: the default IPv4 & IPv6 resolvers are set to Google's Public DNS
|
|
|
- defaultIPv4Dns = []string{"nameserver 8.8.8.8", "nameserver 8.8.4.4"}
|
|
|
- defaultIPv6Dns = []string{"nameserver 2001:4860:4860::8888", "nameserver 2001:4860:4860::8844"}
|
|
|
- ipv4NumBlock = `(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`
|
|
|
- ipv4Address = `(` + ipv4NumBlock + `\.){3}` + ipv4NumBlock
|
|
|
+const (
|
|
|
+ // ipLocalhost is a regex pattern for IPv4 or IPv6 loopback range.
|
|
|
+ ipLocalhost = `((127\.([0-9]{1,3}\.){2}[0-9]{1,3})|(::1)$)`
|
|
|
+ ipv4NumBlock = `(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`
|
|
|
+ ipv4Address = `(` + ipv4NumBlock + `\.){3}` + ipv4NumBlock
|
|
|
+
|
|
|
// This is not an IPv6 address verifier as it will accept a super-set of IPv6, and also
|
|
|
// will *not match* IPv4-Embedded IPv6 Addresses (RFC6052), but that and other variants
|
|
|
// -- e.g. other link-local types -- either won't work in containers or are unnecessary.
|
|
|
// For readability and sufficiency for Docker purposes this seemed more reasonable than a
|
|
|
// 1000+ character regexp with exact and complete IPv6 validation
|
|
|
ipv6Address = `([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{0,4})(%\w+)?`
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ // Note: the default IPv4 & IPv6 resolvers are set to Google's Public DNS
|
|
|
+ defaultIPv4Dns = []string{"nameserver 8.8.8.8", "nameserver 8.8.4.4"}
|
|
|
+ defaultIPv6Dns = []string{"nameserver 2001:4860:4860::8888", "nameserver 2001:4860:4860::8844"}
|
|
|
|
|
|
- localhostNSRegexp = regexp.MustCompile(`(?m)^nameserver\s+` + dns.IPLocalhost + `\s*\n*`)
|
|
|
+ localhostNSRegexp = regexp.MustCompile(`(?m)^nameserver\s+` + ipLocalhost + `\s*\n*`)
|
|
|
nsIPv6Regexp = regexp.MustCompile(`(?m)^nameserver\s+` + ipv6Address + `\s*\n*`)
|
|
|
nsRegexp = regexp.MustCompile(`^\s*nameserver\s*((` + ipv4Address + `)|(` + ipv6Address + `))\s*$`)
|
|
|
nsIPv6Regexpmatch = regexp.MustCompile(`^\s*nameserver\s*((` + ipv6Address + `))\s*$`)
|