From 10320a5f1f20e12b863f461e6d4f456546663349 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Wed, 26 Apr 2023 17:42:14 +0200 Subject: [PATCH] lint and nolint tailscale borrowed func Signed-off-by: Kristoffer Dalby --- acls.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/acls.go b/acls.go index 71ad628e..cbe2f719 100644 --- a/acls.go +++ b/acls.go @@ -830,6 +830,7 @@ var ( // around, and ultimately use a new version of IPSet.ContainsFunc like // Contains16Func that works in [16]byte address, so we we can match // at runtime without allocating? +// nolint func parseIPSet(arg string, bits *int) ([]netip.Prefix, error) { if arg == "*" { // User explicitly requested wildcard. @@ -846,22 +847,27 @@ func parseIPSet(arg string, bits *int) ([]netip.Prefix, error) { if pfx != pfx.Masked() { return nil, fmt.Errorf("%v contains non-network bits set", pfx) } + return []netip.Prefix{pfx}, nil } if strings.Count(arg, "-") == 1 { ip1s, ip2s, _ := strings.Cut(arg, "-") + ip1, err := netip.ParseAddr(ip1s) if err != nil { return nil, err } + ip2, err := netip.ParseAddr(ip2s) if err != nil { return nil, err } + r := netipx.IPRangeFrom(ip1, ip2) - if !r.Valid() { + if !r.IsValid() { return nil, fmt.Errorf("invalid IP range %q", arg) } + return r.Prefixes(), nil } ip, err := netip.ParseAddr(arg) @@ -875,16 +881,8 @@ func parseIPSet(arg string, bits *int) ([]netip.Prefix, error) { } bits8 = uint8(*bits) } - return []netip.Prefix{netip.PrefixFrom(ip, int(bits8))}, nil -} -func ipInPrefixList(ip netip.Addr, netlist []netip.Prefix) bool { - for _, net := range netlist { - if net.Contains(ip) { - return true - } - } - return false + return []netip.Prefix{netip.PrefixFrom(ip, int(bits8))}, nil } type Match struct {