mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-23 00:27:05 +08:00
nat: add HasDiscoveredNAT method for checking NAT environments (#2358)
* nat: add HasNAT method for checking NAT environments * rename to better variable
This commit is contained in:
@@ -843,11 +843,10 @@ func (h *BasicHost) AllAddrs() []ma.Multiaddr {
|
||||
|
||||
finalAddrs = network.DedupAddrs(finalAddrs)
|
||||
|
||||
// natmgr is nil if we do not use nat option;
|
||||
if h.natmgr != nil {
|
||||
// use nat mappings if we have them
|
||||
if h.natmgr != nil && h.natmgr.HasDiscoveredNAT() {
|
||||
// We have successfully mapped ports on our NAT. Use those
|
||||
// instead of observed addresses (mostly).
|
||||
|
||||
// Next, apply this mapping to our addresses.
|
||||
for _, listen := range listenAddrs {
|
||||
extMaddr := h.natmgr.GetMapping(listen)
|
||||
|
||||
Reference in New Issue
Block a user