Browse code

Windows: Don't pull in all of resolvconf

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/05/12 07:16:23
Showing 3 changed files
... ...
@@ -9,7 +9,7 @@ import (
9 9
 	"github.com/Sirupsen/logrus"
10 10
 	"github.com/docker/docker/opts"
11 11
 	"github.com/docker/docker/pkg/promise"
12
-	"github.com/docker/docker/pkg/resolvconf"
12
+	"github.com/docker/docker/pkg/resolvconf/dns"
13 13
 	"github.com/docker/docker/pkg/signal"
14 14
 	"github.com/docker/docker/runconfig"
15 15
 )
... ...
@@ -65,7 +65,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
65 65
 		// localhost regexp to warn if they are trying to
66 66
 		// set a DNS to a localhost address
67 67
 		for _, dnsIP := range hostConfig.Dns {
68
-			if resolvconf.IsLocalhost(dnsIP) {
68
+			if dns.IsLocalhost(dnsIP) {
69 69
 				fmt.Fprintf(cli.err, "WARNING: Localhost DNS setting (--dns=%s) may fail in containers.\n", dnsIP)
70 70
 				break
71 71
 			}
72 72
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+package dns
1
+
2
+import (
3
+	"regexp"
4
+)
5
+
6
+const IpLocalhost = `((127\.([0-9]{1,3}.){2}[0-9]{1,3})|(::1))`
7
+
8
+var localhostIPRegexp = regexp.MustCompile(IpLocalhost)
9
+
10
+// IsLocalhost returns true if ip matches the localhost IP regular expression.
11
+// Used for determining if nameserver settings are being passed which are
12
+// localhost addresses
13
+func IsLocalhost(ip string) bool {
14
+	return localhostIPRegexp.MatchString(ip)
15
+}
... ...
@@ -10,6 +10,7 @@ import (
10 10
 
11 11
 	"github.com/Sirupsen/logrus"
12 12
 	"github.com/docker/docker/pkg/ioutils"
13
+	"github.com/docker/docker/pkg/resolvconf/dns"
13 14
 )
14 15
 
15 16
 var (
... ...
@@ -24,10 +25,8 @@ var (
24 24
 	// For readability and sufficiency for Docker purposes this seemed more reasonable than a
25 25
 	// 1000+ character regexp with exact and complete IPv6 validation
26 26
 	ipv6Address = `([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{0,4})`
27
-	ipLocalhost = `((127\.([0-9]{1,3}.){2}[0-9]{1,3})|(::1))`
28 27
 
29
-	localhostIPRegexp = regexp.MustCompile(ipLocalhost)
30
-	localhostNSRegexp = regexp.MustCompile(`(?m)^nameserver\s+` + ipLocalhost + `\s*\n*`)
28
+	localhostNSRegexp = regexp.MustCompile(`(?m)^nameserver\s+` + dns.IpLocalhost + `\s*\n*`)
31 29
 	nsIPv6Regexp      = regexp.MustCompile(`(?m)^nameserver\s+` + ipv6Address + `\s*\n*`)
32 30
 	nsRegexp          = regexp.MustCompile(`^\s*nameserver\s*((` + ipv4Address + `)|(` + ipv6Address + `))\s*$`)
33 31
 	searchRegexp      = regexp.MustCompile(`^\s*search\s*(([^\s]+\s*)*)$`)
... ...
@@ -128,13 +127,6 @@ func getLines(input []byte, commentMarker []byte) [][]byte {
128 128
 	return output
129 129
 }
130 130
 
131
-// IsLocalhost returns true if ip matches the localhost IP regular expression.
132
-// Used for determining if nameserver settings are being passed which are
133
-// localhost addresses
134
-func IsLocalhost(ip string) bool {
135
-	return localhostIPRegexp.MatchString(ip)
136
-}
137
-
138 131
 // GetNameservers returns nameservers (if any) listed in /etc/resolv.conf
139 132
 func GetNameservers(resolvConf []byte) []string {
140 133
 	nameservers := []string{}