xxxxxxxxxx
func ValidIpAddress(ip string) (bool, error) {
n := net.ParseIP(ip)
if n.To4() == nil {
return false, fmt.Errorf("IP address %s not valid", ip)
}
if _, err := regexp.MatchString(`\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b`, ip); err != nil {
return false, fmt.Errorf("IP address %s not allowed", ip)
}
return true, nil
}