Skip to content

Commit 90288d8

Browse files
committed
feat: move filters into a sub-package
These really don't belong in the root package.
1 parent 192ac0f commit 90288d8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: filter.go renamed to filter/filter.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
package multiaddr
1+
package filter
22

33
import (
44
"net"
55
"sync"
6+
7+
ma "github.com/multiformats/go-multiaddr"
68
)
79

810
// Action is an enum modelling all possible filter actions.
@@ -108,17 +110,17 @@ func (fs *Filters) RemoveLiteral(ipnet net.IPNet) (removed bool) {
108110
// TODO: currently, the last filter to match wins always, but it shouldn't be that way.
109111
// Instead, the highest-specific last filter should win; that way more specific filters
110112
// override more general ones.
111-
func (fs *Filters) AddrBlocked(a Multiaddr) (deny bool) {
113+
func (fs *Filters) AddrBlocked(a ma.Multiaddr) (deny bool) {
112114
var (
113115
netip net.IP
114116
found bool
115117
)
116118

117-
ForEach(a, func(c Component) bool {
119+
ma.ForEach(a, func(c ma.Component) bool {
118120
switch c.Protocol().Code {
119-
case P_IP6ZONE:
121+
case ma.P_IP6ZONE:
120122
return true
121-
case P_IP6, P_IP4:
123+
case ma.P_IP6, ma.P_IP4:
122124
found = true
123125
netip = net.IP(c.RawValue())
124126
return false

Diff for: filter_test.go renamed to filter/filter_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package multiaddr
1+
package filter
22

33
import (
44
"net"
@@ -66,7 +66,7 @@ func TestFilterBlocking(t *testing.T) {
6666
"/ip6/fd00::2/tcp/321",
6767
"/ip6/fc00::1/udp/321",
6868
} {
69-
maddr, err := NewMultiaddr(blocked)
69+
maddr, err := ma.NewMultiaddr(blocked)
7070
if err != nil {
7171
t.Error(err)
7272
}

0 commit comments

Comments
 (0)