resolvconf.go 412 B

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