From c590686630e366e15ba2d850baa15e9c0ae0aba7 Mon Sep 17 00:00:00 2001 From: sukun Date: Wed, 25 Oct 2023 22:59:31 +0530 Subject: [PATCH] upgrade go-multiaddr --- go.mod | 2 +- go.sum | 4 ++-- p2p/protocol/identify/id.go | 4 ++-- p2p/protocol/identify/id_glass_test.go | 13 +++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index a13fb572bb..3d946bc6c1 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/minio/sha256-simd v1.0.1 github.com/mr-tron/base58 v1.2.0 github.com/multiformats/go-base32 v0.1.0 - github.com/multiformats/go-multiaddr v0.11.0 + github.com/multiformats/go-multiaddr v0.12.0 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multiaddr-fmt v0.1.0 github.com/multiformats/go-multibase v0.2.0 diff --git a/go.sum b/go.sum index 475617a846..d2c1324d27 100644 --- a/go.sum +++ b/go.sum @@ -351,8 +351,8 @@ github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9 github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.11.0 h1:XqGyJ8ufbCE0HmTDwx2kPdsrQ36AGPZNZX6s6xfJH10= -github.com/multiformats/go-multiaddr v0.11.0/go.mod h1:gWUm0QLR4thQ6+ZF6SXUw8YjtwQSPapICM+NmCkxHSM= +github.com/multiformats/go-multiaddr v0.12.0 h1:1QlibTFkoXJuDjjYsMHhE73TnzJQl8FSWatk/0gxGzE= +github.com/multiformats/go-multiaddr v0.12.0/go.mod h1:WmZXgObOQOYp9r3cslLlppkrz1FYSHmE834dfz/lWu8= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go index 72dd019dc9..6c07dbdc8e 100644 --- a/p2p/protocol/identify/id.go +++ b/p2p/protocol/identify/id.go @@ -996,7 +996,7 @@ func filterAddrs(addrs []ma.Multiaddr, remote ma.Multiaddr) []ma.Multiaddr { return addrs } if manet.IsPrivateAddr(remote) { - return ma.FilterAddrs(addrs, func(a ma.Multiaddr) bool { return !manet.IsThinWaist(a) || !manet.IsIPLoopback(a) }) + return ma.FilterAddrs(addrs, func(a ma.Multiaddr) bool { return !manet.IsIPLoopback(a) }) } - return ma.FilterAddrs(addrs, func(a ma.Multiaddr) bool { return !manet.IsThinWaist(a) || manet.IsPublicAddr(a) }) + return ma.FilterAddrs(addrs, manet.IsPublicAddr) } diff --git a/p2p/protocol/identify/id_glass_test.go b/p2p/protocol/identify/id_glass_test.go index 21f76405b3..ff303b23ec 100644 --- a/p2p/protocol/identify/id_glass_test.go +++ b/p2p/protocol/identify/id_glass_test.go @@ -179,29 +179,30 @@ func TestIncomingAddrFilter(t *testing.T) { lhAddr := ma.StringCast("/ip4/127.0.0.1/udp/123/quic-v1") privAddr := ma.StringCast("/ip4/192.168.1.101/tcp/123") pubAddr := ma.StringCast("/ip6/2::1/udp/123/quic-v1") - dnsAddr := ma.StringCast("/dns/example.com/udp/123/quic-v1") + pubDNSAddr := ma.StringCast("/dns/example.com/udp/123/quic-v1") + privDNSAddr := ma.StringCast("/dns4/localhost/udp/123/quic-v1") tests := []struct { output []ma.Multiaddr remote ma.Multiaddr }{ { - output: []ma.Multiaddr{lhAddr, privAddr, pubAddr, dnsAddr}, + output: []ma.Multiaddr{lhAddr, privAddr, pubAddr, pubDNSAddr, privDNSAddr}, remote: lhAddr, }, { - output: []ma.Multiaddr{privAddr, pubAddr, dnsAddr}, + output: []ma.Multiaddr{privAddr, pubAddr, pubDNSAddr, privDNSAddr}, remote: privAddr, }, { - output: []ma.Multiaddr{pubAddr, dnsAddr}, + output: []ma.Multiaddr{pubAddr, pubDNSAddr}, remote: pubAddr, }, } for _, tc := range tests { t.Run(fmt.Sprintf("remote:%s", tc.remote), func(t *testing.T) { - input := []ma.Multiaddr{lhAddr, privAddr, pubAddr, dnsAddr} + input := []ma.Multiaddr{lhAddr, privAddr, pubAddr, pubDNSAddr, privDNSAddr} got := filterAddrs(input, tc.remote) - require.ElementsMatch(t, tc.output, got) + require.ElementsMatch(t, tc.output, got, "%s\n%s", tc.output, got) }) } }