Skip to content

Commit 2cb8d57

Browse files
author
Henry Wagner
committed
remove unnecessary validation checks
1 parent 24a5276 commit 2cb8d57

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

cloud/linode/loadbalancers.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,6 @@ func (l *loadbalancers) createNodeBalancer(ctx context.Context, clusterName stri
876876

877877
// Check for static IPv4 address annotation
878878
if ipv4, ok := service.GetAnnotations()[annotations.AnnLinodeLoadBalancerIPv4]; ok {
879-
if err := isValidPublicIPv4(ipv4); err != nil {
880-
return nil, fmt.Errorf("invalid IPv4 address in annotation %s: %w", annotations.AnnLinodeLoadBalancerIPv4, err)
881-
}
882879
createOpts.IPv4 = &ipv4
883880
}
884881

@@ -910,31 +907,6 @@ func (l *loadbalancers) createNodeBalancer(ctx context.Context, clusterName stri
910907
return l.client.CreateNodeBalancer(ctx, createOpts)
911908
}
912909

913-
// isValidPublicIPv4 checks if the given string is a valid public IPv4 address
914-
func isValidPublicIPv4(ipStr string) error {
915-
ip := net.ParseIP(ipStr)
916-
if ip == nil {
917-
return fmt.Errorf("invalid IP address format: %s", ipStr)
918-
}
919-
920-
ipv4 := ip.To4()
921-
if ipv4 == nil {
922-
return fmt.Errorf("not an IPv4 address: %s", ipStr)
923-
}
924-
925-
// Check if it's a public IP (not private, not multicast, not experimental)
926-
if ipv4[0] == 10 || // 10.0.0.0/8
927-
(ipv4[0] == 172 && ipv4[1] >= 16 && ipv4[1] <= 31) || // 172.16.0.0/12
928-
(ipv4[0] == 192 && ipv4[1] == 168) || // 192.168.0.0/16
929-
ipv4[0] >= 224 || // Class D & E
930-
ipv4[0] == 0 || // 0.0.0.0/8
931-
ipv4[0] == 127 { // 127.0.0.0/8
932-
return fmt.Errorf("not a public IPv4 address: %s", ipStr)
933-
}
934-
935-
return nil
936-
}
937-
938910
func (l *loadbalancers) buildNodeBalancerConfig(ctx context.Context, service *v1.Service, port v1.ServicePort) (linodego.NodeBalancerConfig, error) {
939911
portConfigResult, err := getPortConfig(service, port)
940912
if err != nil {

0 commit comments

Comments
 (0)