mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-23 00:27:05 +08:00
autonat: don't use autonat for address discovery (#2148)
* dont use autonat for address discovery * dont increase timeout
This commit is contained in:
@@ -776,7 +776,6 @@ func (h *BasicHost) AllAddrs() []ma.Multiaddr {
|
||||
h.addrMu.RLock()
|
||||
filteredIfaceAddrs := h.filteredInterfaceAddrs
|
||||
allIfaceAddrs := h.allInterfaceAddrs
|
||||
autonat := h.autoNat
|
||||
h.addrMu.RUnlock()
|
||||
|
||||
// Iterate over all _unresolved_ listen addresses, resolving our primary
|
||||
@@ -790,19 +789,6 @@ func (h *BasicHost) AllAddrs() []ma.Multiaddr {
|
||||
finalAddrs = append(finalAddrs, resolved...)
|
||||
}
|
||||
|
||||
// add autonat PublicAddr Consider the following scenario
|
||||
// For example, it is deployed on a cloud server,
|
||||
// it provides an elastic ip accessible to the public network,
|
||||
// but not have an external network card,
|
||||
// so net.InterfaceAddrs() not has the public ip
|
||||
// The host can indeed be dialed !!!
|
||||
if autonat != nil {
|
||||
publicAddr, _ := autonat.PublicAddr()
|
||||
if publicAddr != nil {
|
||||
finalAddrs = append(finalAddrs, publicAddr)
|
||||
}
|
||||
}
|
||||
|
||||
finalAddrs = dedupAddrs(finalAddrs)
|
||||
|
||||
var natMappings []inat.Mapping
|
||||
|
||||
Reference in New Issue
Block a user