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:
Sukun
2023-06-12 23:31:17 +05:30
committed by GitHub
parent 046f112f8a
commit f87f6dbca8
2 changed files with 9 additions and 3 deletions
+2 -3
View File
@@ -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)