Add validation for Endpoints
This commit is contained in:
@@ -91,7 +91,7 @@ func IsValidPortNum(port int) bool {
|
||||
return 0 < port && port < 65536
|
||||
}
|
||||
|
||||
// IsValidIP tests that the argument is a valid IPv4 address.
|
||||
func IsValidIP(value string) bool {
|
||||
// IsValidIPv4 tests that the argument is a valid IPv4 address.
|
||||
func IsValidIPv4(value string) bool {
|
||||
return net.ParseIP(value) != nil && net.ParseIP(value).To4() != nil
|
||||
}
|
||||
|
@@ -232,7 +232,7 @@ func TestIsValidIP(t *testing.T) {
|
||||
"0.0.0.0",
|
||||
}
|
||||
for _, val := range goodValues {
|
||||
if !IsValidIP(val) {
|
||||
if !IsValidIPv4(val) {
|
||||
t.Errorf("expected true for %q", val)
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func TestIsValidIP(t *testing.T) {
|
||||
"1.0.0.1.",
|
||||
}
|
||||
for _, val := range badValues {
|
||||
if IsValidIP(val) {
|
||||
if IsValidIPv4(val) {
|
||||
t.Errorf("expected false for %q", val)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user