diff options
Diffstat (limited to 'modules/caddytls/matchers.go')
-rw-r--r-- | modules/caddytls/matchers.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/modules/caddytls/matchers.go b/modules/caddytls/matchers.go index f44b4c02..a74d6ea8 100644 --- a/modules/caddytls/matchers.go +++ b/modules/caddytls/matchers.go @@ -20,6 +20,7 @@ import ( "net" "net/netip" "regexp" + "slices" "strconv" "strings" @@ -321,12 +322,9 @@ func (MatchRemoteIP) parseIPRange(str string) ([]netip.Prefix, error) { } func (MatchRemoteIP) matches(ip netip.Addr, ranges []netip.Prefix) bool { - for _, ipRange := range ranges { - if ipRange.Contains(ip) { - return true - } - } - return false + return slices.ContainsFunc(ranges, func(prefix netip.Prefix) bool { + return prefix.Contains(ip) + }) } // UnmarshalCaddyfile sets up the MatchRemoteIP from Caddyfile tokens. Syntax: @@ -439,12 +437,9 @@ func (MatchLocalIP) parseIPRange(str string) ([]netip.Prefix, error) { } func (MatchLocalIP) matches(ip netip.Addr, ranges []netip.Prefix) bool { - for _, ipRange := range ranges { - if ipRange.Contains(ip) { - return true - } - } - return false + return slices.ContainsFunc(ranges, func(prefix netip.Prefix) bool { + return prefix.Contains(ip) + }) } // UnmarshalCaddyfile sets up the MatchLocalIP from Caddyfile tokens. Syntax: |