Skip to content

Commit

Permalink
Runtime placeholders: remove unused ParseNetworks
Browse files Browse the repository at this point in the history
  • Loading branch information
vnxme committed Aug 7, 2024
1 parent 0531091 commit dd1c543
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions layer4/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"net"
"net/netip"
"strings"

"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
Expand Down Expand Up @@ -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
}

0 comments on commit dd1c543

Please sign in to comment.