mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user