wgengine/filter: use slices.Contains in another place

We keep finding these.

Updates #cleanup

Change-Id: Iabc049b0f8da07341011356f0ecd5315c33ff548
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/9758/head
Brad Fitzpatrick 7 months ago committed by Brad Fitzpatrick
parent 0a412eba40
commit 8b630c91bc

@ -6,6 +6,7 @@ package filter
import (
"fmt"
"net/netip"
"slices"
"strings"
"tailscale.com/net/packet"
@ -100,7 +101,7 @@ type matches []Match
func (ms matches) match(q *packet.Parsed) bool {
for _, m := range ms {
if !protoInList(q.IPProto, m.IPProto) {
if !slices.Contains(m.IPProto, q.IPProto) {
continue
}
if !ipInList(q.Src.Addr(), m.Srcs) {
@ -138,7 +139,7 @@ func (ms matches) matchIPsOnly(q *packet.Parsed) bool {
// ignored, as long as the match is for the entire uint16 port range.
func (ms matches) matchProtoAndIPsOnlyIfAllPorts(q *packet.Parsed) bool {
for _, m := range ms {
if !protoInList(q.IPProto, m.IPProto) {
if !slices.Contains(m.IPProto, q.IPProto) {
continue
}
if !ipInList(q.Src.Addr(), m.Srcs) {
@ -164,12 +165,3 @@ func ipInList(ip netip.Addr, netlist []netip.Prefix) bool {
}
return false
}
func protoInList(proto ipproto.Proto, valid []ipproto.Proto) bool {
for _, v := range valid {
if proto == v {
return true
}
}
return false
}

Loading…
Cancel
Save