Browse Source
Merge pull request #511 from libp2p/fix/autorelay-pubaddr
don't advertise the raw public address in autorelay
pull/513/head
Steven Allen
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
3 additions and
27 deletions
-
p2p/host/relay/autorelay.go
|
|
@ -203,37 +203,13 @@ func (h *AutoRelayHost) doUpdateAddrs() { |
|
|
|
addrs := h.baseAddrs() |
|
|
|
raddrs := make([]ma.Multiaddr, 0, len(addrs)+len(h.relays)) |
|
|
|
|
|
|
|
// remove our public addresses from the list and replace them by just the public IP
|
|
|
|
// remove our public addresses from the list
|
|
|
|
for _, addr := range addrs { |
|
|
|
if manet.IsPublicAddr(addr) { |
|
|
|
ip, err := addr.ValueForProtocol(ma.P_IP4) |
|
|
|
if err == nil { |
|
|
|
pub, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s", ip)) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
|
|
|
|
if !containsAddr(raddrs, pub) { |
|
|
|
raddrs = append(raddrs, pub) |
|
|
|
} |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
ip, err = addr.ValueForProtocol(ma.P_IP6) |
|
|
|
if err == nil { |
|
|
|
pub, err := ma.NewMultiaddr(fmt.Sprintf("/ip6/%s", ip)) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
if !containsAddr(raddrs, pub) { |
|
|
|
raddrs = append(raddrs, pub) |
|
|
|
} |
|
|
|
continue |
|
|
|
} |
|
|
|
} else { |
|
|
|
raddrs = append(raddrs, addr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// add relay specific addrs to the list
|
|
|
|
for _, pi := range h.relays { |
|
|
|