diff --git a/addr.go b/addr.go index 1853999..a7b0f03 100644 --- a/addr.go +++ b/addr.go @@ -136,25 +136,6 @@ func AddrInList(addr ma.Multiaddr, list []ma.Multiaddr) bool { return false } -// AddrIsShareableOnWAN returns whether the given address should be shareable on the -// wide area network (wide internet). -func AddrIsShareableOnWAN(addr ma.Multiaddr) bool { - s := ma.Split(addr) - if len(s) < 1 { - return false - } - a := s[0] - if manet.IsIPLoopback(a) || manet.IsIP6LinkLocal(a) || manet.IsIPUnspecified(a) { - return false - } - return manet.IsThinWaist(a) -} - -// WANShareableAddrs filters addresses based on whether they're shareable on WAN -func WANShareableAddrs(inp []ma.Multiaddr) []ma.Multiaddr { - return FilterAddrs(inp, AddrIsShareableOnWAN) -} - // Subtract filters out all addrs in b from a func Subtract(a, b []ma.Multiaddr) []ma.Multiaddr { return FilterAddrs(a, func(m ma.Multiaddr) bool { diff --git a/addr_test.go b/addr_test.go index 86e97aa..ed3cc53 100644 --- a/addr_test.go +++ b/addr_test.go @@ -137,45 +137,6 @@ func TestResolvingAddrs(t *testing.T) { } -func TestWANShareable(t *testing.T) { - - wanok := []ma.Multiaddr{ - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234"), - newMultiaddr(t, "/ip6/abcd::1/tcp/1234"), - } - - wanbad := []ma.Multiaddr{ - newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234"), - newMultiaddr(t, "/ip4/0.0.0.0/tcp/1234"), - newMultiaddr(t, "/ip6/::1/tcp/1234"), - newMultiaddr(t, "/ip6/::/tcp/1234"), - newMultiaddr(t, "/ip6/fe80::1/tcp/1234"), - newMultiaddr(t, "/ip6/fe80::/tcp/1234"), - } - - for _, a := range wanok { - if !AddrIsShareableOnWAN(a) { - t.Error("should be true", a) - } - } - - for _, a := range wanbad { - if AddrIsShareableOnWAN(a) { - t.Error("should be false", a) - } - } - - wanok2 := WANShareableAddrs(wanok) - if len(wanok) != len(wanok2) { - t.Error("should be the same") - } - - wanbad2 := WANShareableAddrs(wanbad) - if len(wanbad2) != 0 { - t.Error("should be zero") - } -} - func TestSubtract(t *testing.T) { a := []ma.Multiaddr{