Skip to content

Commit 3d8cebe

Browse files
Address PR comments for ipv6 cidr
1 parent 84daa82 commit 3d8cebe

File tree

1 file changed

+7
-7
lines changed
  • internal/ingress/annotations/loadbalancer

1 file changed

+7
-7
lines changed

internal/ingress/annotations/loadbalancer/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,25 +214,25 @@ func parseCidrs(ing parser.AnnotationInterface) (v4CIDRs, v6CIDRs []string, err
214214
}
215215

216216
for _, inboundCidr := range cidrConfig {
217-
ip, _, err := net.ParseCIDR(inboundCidr)
217+
_, _, err := net.ParseCIDR(inboundCidr)
218218
if err != nil {
219219
return v4CIDRs, v6CIDRs, err
220220
}
221221

222-
if ip.To4() == nil {
222+
if strings.Contains(inboundCidr, ":") {
223223
v6CIDRs = append(v6CIDRs, inboundCidr)
224224
} else {
225225
v4CIDRs = append(v4CIDRs, inboundCidr)
226226
}
227227
}
228228

229-
if len(v4CIDRs) == 0 {
229+
if len(v4CIDRs) == 0 && len(v6CIDRs) == 0 {
230230
v4CIDRs = append(v4CIDRs, "0.0.0.0/0")
231-
}
232231

233-
addrType, _ := parser.GetStringAnnotation("ip-address-type", ing)
234-
if addrType != nil && *addrType == elbv2.IpAddressTypeDualstack && len(v6CIDRs) == 0 {
235-
v6CIDRs = append(v6CIDRs, "::/0")
232+
addrType, _ := parser.GetStringAnnotation("ip-address-type", ing)
233+
if addrType != nil && *addrType == elbv2.IpAddressTypeDualstack {
234+
v6CIDRs = append(v6CIDRs, "::/0")
235+
}
236236
}
237237

238238
return v4CIDRs, v6CIDRs, nil

0 commit comments

Comments
 (0)