resolvconf.go 479 B

123456789101112131415161718
  1. package dns
  2. import (
  3. "regexp"
  4. )
  5. // IPLocalhost is a regex patter for localhost IP address range.
  6. const IPLocalhost = `((127\.([0-9]{1,3}\.){2}[0-9]{1,3})|(::1)$)`
  7. var localhostIPRegexp = regexp.MustCompile(IPLocalhost)
  8. // IsLocalhost returns true if ip matches the localhost IP regular expression.
  9. // Used for determining if nameserver settings are being passed which are
  10. // localhost addresses
  11. func IsLocalhost(ip string) bool {
  12. return localhostIPRegexp.MatchString(ip)
  13. }