mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
p2p/nat: re-factors nat object
- allow retrieving addresses - allow notifications on mapping changes - allow lifecycle mgmt (future commit will manage it)
This commit is contained in:
12
core/core.go
12
core/core.go
@ -432,10 +432,14 @@ func constructPeerHost(ctx context.Context, cfg *config.Config, id peer.ID, ps p
|
||||
}
|
||||
log.Infof("Swarm listening at: %s", addrs)
|
||||
|
||||
mapAddrs := inat.MapAddrs(filteredAddrs)
|
||||
if len(mapAddrs) > 0 {
|
||||
log.Infof("NAT mapping addrs: %s", mapAddrs)
|
||||
addrs = append(addrs, mapAddrs...)
|
||||
nat := inat.DiscoverGateway()
|
||||
if nat != nil {
|
||||
nat.PortMapAddrs(filteredAddrs)
|
||||
mapAddrs := nat.ExternalAddrs()
|
||||
if len(mapAddrs) > 0 {
|
||||
log.Infof("NAT mapping addrs: %s", mapAddrs)
|
||||
addrs = append(addrs, mapAddrs...)
|
||||
}
|
||||
}
|
||||
|
||||
ps.AddAddresses(id, addrs)
|
||||
|
Reference in New Issue
Block a user