Validate Service.Spec.publicIPs to be a valid IP that is not a localhost

This commit is contained in:
Filip Grzadkowski
2015-03-16 15:03:05 +01:00
parent d0b468f4b0
commit 24eb1a08f3
4 changed files with 65 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"net"
"regexp"
)
@@ -94,3 +95,8 @@ func IsCIdentifier(value string) bool {
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 {
return net.ParseIP(value) != nil && net.ParseIP(value).To4() != nil
}