From 7133f4124f7cac148da779c750aaf02506336f6c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 2 Aug 2018 14:18:47 -0700 Subject: [PATCH] when we do a nat port mapping, explicitly remember the mapped address related to #383 I won't call this *fixed* yet but it should help. --- p2p/host/basic/natmgr.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/p2p/host/basic/natmgr.go b/p2p/host/basic/natmgr.go index 349f79e..be48375 100644 --- a/p2p/host/basic/natmgr.go +++ b/p2p/host/basic/natmgr.go @@ -8,6 +8,7 @@ import ( lgbl "github.com/libp2p/go-libp2p-loggables" inat "github.com/libp2p/go-libp2p-nat" inet "github.com/libp2p/go-libp2p-net" + pstore "github.com/libp2p/go-libp2p-peerstore" ma "github.com/multiformats/go-multiaddr" ) @@ -187,6 +188,9 @@ func addPortMapping(nmgr *natManager, intaddr ma.Multiaddr) { return } + // TODO: make these temporary and rediscover them. + nmgr.net.Peerstore().AddAddr(nmgr.net.LocalPeer(), extaddr, pstore.PermanentAddrTTL) + lm["outcome"] = "success" lm["externalAddr"] = func() interface{} { return extaddr.String() } log.Infof("established nat port mapping: %s <--> %s", intaddr, extaddr) -- GitLab