Skip to content

Commit

Permalink
Merge branch 'kubernetes:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobrek authored May 23, 2022
2 parents fd49717 + 869e18b commit 06e7adf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion images/opentelemetry/rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ RUN bash /opt/third_party/build.sh -n
FROM alpine:3.14.6
COPY --from=base /opt/third_party/init_module.sh /usr/local/bin/init_module.sh
COPY --from=nginx /etc/nginx/modules /etc/nginx/modules
COPY --from=nginx /opt/third_party/install/lib /usr/lib
COPY --from=nginx /opt/third_party/install/lib /etc/nginx/modules
9 changes: 6 additions & 3 deletions internal/ingress/annotations/ipwhitelist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,21 @@ func NewParser(r resolver.Resolver) parser.IngressAnnotation {
// e.g. `18.0.0.0/8,56.0.0.0/8`
func (a ipwhitelist) Parse(ing *networking.Ingress) (interface{}, error) {
defBackend := a.r.GetDefaultBackend()
sort.Strings(defBackend.WhitelistSourceRange)

defaultWhitelistSourceRange := make([]string, len(defBackend.WhitelistSourceRange))
copy(defaultWhitelistSourceRange, defBackend.WhitelistSourceRange)
sort.Strings(defaultWhitelistSourceRange)

val, err := parser.GetStringAnnotation("whitelist-source-range", ing)
// A missing annotation is not a problem, just use the default
if err == ing_errors.ErrMissingAnnotations {
return &SourceRange{CIDR: defBackend.WhitelistSourceRange}, nil
return &SourceRange{CIDR: defaultWhitelistSourceRange}, nil
}

values := strings.Split(val, ",")
ipnets, ips, err := net.ParseIPNets(values...)
if err != nil && len(ips) == 0 {
return &SourceRange{CIDR: defBackend.WhitelistSourceRange}, ing_errors.LocationDenied{
return &SourceRange{CIDR: defaultWhitelistSourceRange}, ing_errors.LocationDenied{
Reason: fmt.Errorf("the annotation does not contain a valid IP address or network: %w", err),
}
}
Expand Down

0 comments on commit 06e7adf

Please sign in to comment.