Skip to content

Commit

Permalink
fix securityGroup ipv4 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
M00nF1sh committed Apr 30, 2019
1 parent bf1a6be commit 06a8235
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions pkg/build/lb_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package build
import (
"context"
"fmt"
"net"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/service/ec2"
Expand All @@ -14,12 +17,10 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
"net"
api "sigs.k8s.io/aws-alb-ingress-controller/pkg/apis/ingress/v1alpha1"
"sigs.k8s.io/aws-alb-ingress-controller/pkg/cloud"
"sigs.k8s.io/aws-alb-ingress-controller/pkg/ingress"
"sigs.k8s.io/aws-alb-ingress-controller/pkg/k8s"
"strings"
)

func (b *defaultBuilder) buildLBSecurityGroups(ctx context.Context, stack *LoadBalancingStack,
Expand Down Expand Up @@ -137,17 +138,14 @@ func (b *defaultBuilder) buildManagedLBSecurityGroup(ctx context.Context, stack
}
var IPV4CIDRs, IPV6CIDRs []string
for _, cidr := range cidrs {
ip, _, err := net.ParseCIDR(cidr)
_, _, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}
switch len(ip) {
case net.IPv4len:
IPV4CIDRs = append(IPV4CIDRs, cidr)
case net.IPv6len:
if strings.Contains(cidr, ":") {
IPV6CIDRs = append(IPV6CIDRs, cidr)
default:
return nil, errors.Errorf("CIDR must use an IPv4 or IPv6 address: %v, Ingress: %v", cidr, ingKey.String())
} else {
IPV4CIDRs = append(IPV4CIDRs, cidr)
}
}
for port, _ := range ingPorts {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/group_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (m *defaultGroupBuilder) sortIngresses(ingList []*extensions.Ingress) ([]*e

explicitOrders := sets.NewInt64()
for _, ing := range ingList {
var order = defaultGroupOrder;
var order = defaultGroupOrder
exists, err := m.annotationParser.ParseInt64Annotation(k8s.AnnotationSuffixGroupOrder, &order, ing.Annotations)
if err != nil {
return nil, errors.Wrapf(err, "failed to load ingress group order for ingress: %v", k8s.NamespacedName(ing))
Expand Down

0 comments on commit 06a8235

Please sign in to comment.