Skip to content

Commit

Permalink
Merge pull request #511 from libp2p/fix/autorelay-pubaddr
Browse files Browse the repository at this point in the history
don't advertise the raw public address in autorelay
  • Loading branch information
Stebalien authored Dec 21, 2018
2 parents 768598b + c5f50f9 commit 4b70d71
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions p2p/host/relay/autorelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,36 +203,12 @@ 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)
continue
}
raddrs = append(raddrs, addr)
}

// add relay specific addrs to the list
Expand Down

0 comments on commit 4b70d71

Please sign in to comment.