1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork/resolvconf/dns/resolvconf.go
Abhishek Chanda 0ce2a2dba0 Fix regex for IPv6
Only match strings which end with ::1

Fixes #830

Signed-off-by: Abhishek Chanda <abhishek.becs@gmail.com>
2015-12-30 00:22:44 +05:30

17 lines
479 B
Go

package dns
import (
"regexp"
)
// IPLocalhost is a regex patter for localhost IP address range.
const IPLocalhost = `((127\.([0-9]{1,3}\.){2}[0-9]{1,3})|(::1)$)`
var localhostIPRegexp = regexp.MustCompile(IPLocalhost)
// 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)
}