From dd1c54385ebabe6177df81d74bdf749d39f018a2 Mon Sep 17 00:00:00 2001 From: vnxme <46669194+vnxme@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:29:10 +0300 Subject: [PATCH] Runtime placeholders: remove unused ParseNetworks --- layer4/matchers.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/layer4/matchers.go b/layer4/matchers.go index c5f6878..48a723a 100644 --- a/layer4/matchers.go +++ b/layer4/matchers.go @@ -19,7 +19,6 @@ import ( "fmt" "net" "net/netip" - "strings" "github.com/caddyserver/caddy/v2" "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" @@ -403,29 +402,3 @@ var ( _ ConnMatcher = (*MatchNot)(nil) _ caddyfile.Unmarshaler = (*MatchNot)(nil) ) - -// ParseNetworks parses a list of string IP addresses or CIDR subnets into a slice of net.IPNet's. -// It accepts for example ["127.0.0.1", "127.0.0.0/8", "::1", "2001:db8::/32"]. -func ParseNetworks(networks []string) (ipNets []netip.Prefix, err error) { - for _, str := range networks { - if strings.Contains(str, "/") { - ipNet, err := netip.ParsePrefix(str) - if err != nil { - return nil, fmt.Errorf("parsing CIDR expression: %v", err) - } - ipNets = append(ipNets, ipNet) - continue - } - - addr, err := netip.ParseAddr(str) - if err != nil { - return nil, err - } - bits := 32 - if addr.Is6() { - bits = 128 - } - ipNets = append(ipNets, netip.PrefixFrom(addr, bits)) - } - return ipNets, nil -}