diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-05 06:54:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-05 06:54:48 -0700 |
commit | 879a2a8c38408501aef13bfe8dc2c4b3972e4b53 (patch) | |
tree | bd1361c70d6aa97c9590221a1dad8f92ab0a0f58 /pkg/resolvconf/dns/resolvconf.go | |
parent | a4a6f7dac2364fc4215a9b0b12d54fccac623903 (diff) | |
parent | e9ab8583d0a73c686591edfb8b4dfdca212d5eb6 (diff) | |
download | podman-879a2a8c38408501aef13bfe8dc2c4b3972e4b53.tar.gz podman-879a2a8c38408501aef13bfe8dc2c4b3972e4b53.tar.bz2 podman-879a2a8c38408501aef13bfe8dc2c4b3972e4b53.zip |
Merge pull request #1537 from mheon/libnetwork_resolv
Switch to using libnetwork's resolvconf package
Diffstat (limited to 'pkg/resolvconf/dns/resolvconf.go')
-rw-r--r-- | pkg/resolvconf/dns/resolvconf.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/resolvconf/dns/resolvconf.go b/pkg/resolvconf/dns/resolvconf.go new file mode 100644 index 000000000..cb4bd1033 --- /dev/null +++ b/pkg/resolvconf/dns/resolvconf.go @@ -0,0 +1,28 @@ +// Originally from github.com/docker/libnetwork/resolvconf/dns + +package dns + +import ( + "regexp" +) + +// IPLocalhost is a regex pattern for IPv4 or IPv6 loopback range. +const IPLocalhost = `((127\.([0-9]{1,3}\.){2}[0-9]{1,3})|(::1)$)` + +// IPv4Localhost is a regex pattern for IPv4 localhost address range. +const IPv4Localhost = `(127\.([0-9]{1,3}\.){2}[0-9]{1,3})` + +var localhostIPRegexp = regexp.MustCompile(IPLocalhost) +var localhostIPv4Regexp = regexp.MustCompile(IPv4Localhost) + +// IsLocalhost returns true if ip matches the localhost IP regular expression. +// Used for determining if nameserver settings are being passed which are +// localhost addresses +func IsLocalhost(ip string) bool { + return localhostIPRegexp.MatchString(ip) +} + +// IsIPv4Localhost returns true if ip matches the IPv4 localhost regular expression. +func IsIPv4Localhost(ip string) bool { + return localhostIPv4Regexp.MatchString(ip) +} |