diff --git a/filter.go b/filter/filter.go similarity index 95% rename from filter.go rename to filter/filter.go index 6751202..4eb0c56 100644 --- a/filter.go +++ b/filter/filter.go @@ -1,8 +1,10 @@ -package multiaddr +package filter import ( "net" "sync" + + ma "github.com/multiformats/go-multiaddr" ) // Action is an enum modelling all possible filter actions. @@ -108,17 +110,17 @@ func (fs *Filters) RemoveLiteral(ipnet net.IPNet) (removed bool) { // TODO: currently, the last filter to match wins always, but it shouldn't be that way. // Instead, the highest-specific last filter should win; that way more specific filters // override more general ones. -func (fs *Filters) AddrBlocked(a Multiaddr) (deny bool) { +func (fs *Filters) AddrBlocked(a ma.Multiaddr) (deny bool) { var ( netip net.IP found bool ) - ForEach(a, func(c Component) bool { + ma.ForEach(a, func(c ma.Component) bool { switch c.Protocol().Code { - case P_IP6ZONE: + case ma.P_IP6ZONE: return true - case P_IP6, P_IP4: + case ma.P_IP6, ma.P_IP4: found = true netip = net.IP(c.RawValue()) return false diff --git a/filter_test.go b/filter/filter_test.go similarity index 98% rename from filter_test.go rename to filter/filter_test.go index 741ee0a..b8a2faa 100644 --- a/filter_test.go +++ b/filter/filter_test.go @@ -1,4 +1,4 @@ -package multiaddr +package filter import ( "net" @@ -66,7 +66,7 @@ func TestFilterBlocking(t *testing.T) { "/ip6/fd00::2/tcp/321", "/ip6/fc00::1/udp/321", } { - maddr, err := NewMultiaddr(blocked) + maddr, err := ma.NewMultiaddr(blocked) if err != nil { t.Error(err) }