Merge pull request #5508 from fgrzadkowski/validate_ips

Validate Service.Spec.publicIPs to be a valid IP that is not a localhost
This commit is contained in:
Filip Grzadkowski
2015-03-25 12:11:29 +01:00
4 changed files with 65 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"net"
"regexp"
)
@@ -89,3 +90,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
}