diff --git a/go.mod b/go.mod index bee22b789..a54a412f1 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/libp2p/go-addr-util v0.0.2 github.com/libp2p/go-conn-security-multistream v0.2.0 github.com/libp2p/go-eventbus v0.2.1 - github.com/libp2p/go-libp2p-autonat v0.3.1 + github.com/libp2p/go-libp2p-autonat v0.3.2 github.com/libp2p/go-libp2p-blankhost v0.2.0 github.com/libp2p/go-libp2p-circuit v0.3.1 github.com/libp2p/go-libp2p-core v0.6.1 diff --git a/go.sum b/go.sum index 4da3d8887..4e244b4ee 100644 --- a/go.sum +++ b/go.sum @@ -141,6 +141,8 @@ github.com/libp2p/go-flow-metrics v0.0.3 h1:8tAs/hSdNvUiLgtlSy3mxwxWP4I9y/jlkPFT github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs= github.com/libp2p/go-libp2p-autonat v0.3.1 h1:60sc3NuQz+RxEb4ZVCRp/7uPtD7gnlLcOIKYNulzSIo= github.com/libp2p/go-libp2p-autonat v0.3.1/go.mod h1:0OzOi1/cVc7UcxfOddemYD5vzEqi4fwRbnZcJGLi68U= +github.com/libp2p/go-libp2p-autonat v0.3.2 h1:OhDSwVVaq7liTaRIsFFYvsaPp0pn2yi0WazejZ4DUmo= +github.com/libp2p/go-libp2p-autonat v0.3.2/go.mod h1:0OzOi1/cVc7UcxfOddemYD5vzEqi4fwRbnZcJGLi68U= github.com/libp2p/go-libp2p-blankhost v0.2.0 h1:3EsGAi0CBGcZ33GwRuXEYJLLPoVWyXJ1bcJzAJjINkk= github.com/libp2p/go-libp2p-blankhost v0.2.0/go.mod h1:eduNKXGTioTuQAUcZ5epXi9vMl+t4d8ugUBRQ4SqaNQ= github.com/libp2p/go-libp2p-circuit v0.3.1 h1:69ENDoGnNN45BNDnBd+8SXSetDuw0eJFcGmOvvtOgBw= diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go index f7726da0b..2f2ab7624 100644 --- a/p2p/host/basic/basic_host_test.go +++ b/p2p/host/basic/basic_host_test.go @@ -20,6 +20,7 @@ import ( "github.com/libp2p/go-libp2p-core/test" "github.com/libp2p/go-eventbus" + autonat "github.com/libp2p/go-libp2p-autonat" swarmt "github.com/libp2p/go-libp2p-swarm/testing" "github.com/libp2p/go-libp2p/p2p/protocol/identify" @@ -199,6 +200,16 @@ func TestHostAddrsFactory(t *testing.T) { if !addrs[0].Equal(maddr) { t.Fatalf("expected %s, got %s", maddr.String(), addrs[0].String()) } + + var err error + h.AutoNat, err = autonat.New(ctx, h, autonat.WithReachability(network.ReachabilityPublic)) + if err != nil { + t.Fatalf("should be able to attach autonat: %v", err) + } + addrs = h.Addrs() + if len(addrs) != 1 { + t.Fatalf("didn't expect change in returned addresses.") + } } func TestLocalIPChangesWhenListenAddrChanges(t *testing.T) {