2015-05-13 03:27:22 +00:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
|
|
|
|
// IPLocalhost is a regex patter for localhost IP address range.
|
2015-12-30 00:20:37 +05:30
|
|
|
const IPLocalhost = `((127\.([0-9]{1,3}\.){2}[0-9]{1,3})|(::1)$)`
|
2015-05-13 03:27:22 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|