wgengine/filter: fix, test NewAllowAllForTest

I probably broke it when SCTP support was added but nothing apparently
ever used NewAllowAllForTest so it wasn't noticed when it broke.

Change-Id: Ib5a405be233d53cb7fcc61d493ae7aa2d1d590a2
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz/exit_node_forward_dns
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent f8cef1ba08
commit ff9727c9ff

@ -103,6 +103,7 @@ func NewAllowAllForTest(logf logger.Logf) *Filter {
any6 := netaddr.IPPrefixFrom(netaddr.IPFrom16([16]byte{}), 0)
ms := []Match{
{
IPProto: []ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv4},
Srcs: []netaddr.IPPrefix{any4},
Dsts: []NetPortRange{
{
@ -115,6 +116,7 @@ func NewAllowAllForTest(logf logger.Logf) *Filter {
},
},
{
IPProto: []ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv6},
Srcs: []netaddr.IPPrefix{any6},
Dsts: []NetPortRange{
{

@ -815,3 +815,13 @@ func TestMatchesFromFilterRules(t *testing.T) {
})
}
}
func TestNewAllowAllForTest(t *testing.T) {
f := NewAllowAllForTest(logger.Discard)
src := netaddr.MustParseIP("100.100.2.3")
dst := netaddr.MustParseIP("100.100.1.2")
res := f.CheckTCP(src, dst, 80)
if res.IsDrop() {
t.Fatalf("unexpected drop verdict: %v", res)
}
}

Loading…
Cancel
Save