Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix address advertisement bugs #974

Merged
merged 9 commits into from
Jul 7, 2020
11 changes: 8 additions & 3 deletions p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ func (h *BasicHost) updateLocalIpAddr() {
if err != nil {
log.Errorw("failed to resolve local interface addresses", "error", err)
} else {
h.allInterfaceAddrs = ifaceAddrs
for _, addr := range ifaceAddrs {
// Skip link-local addrs, they're mostly useless.
if !manet.IsIP6LinkLocal(addr) {
h.allInterfaceAddrs = append(h.allInterfaceAddrs, addr)
}
}
}

// If we failed to lookup interface addrs.
Expand All @@ -304,11 +309,11 @@ func (h *BasicHost) updateLocalIpAddr() {
// them.
if len(h.filteredInterfaceAddrs) == 0 {
// Add all addresses.
h.filteredInterfaceAddrs = append(h.filteredInterfaceAddrs, ifaceAddrs...)
h.filteredInterfaceAddrs = h.allInterfaceAddrs
Stebalien marked this conversation as resolved.
Show resolved Hide resolved
} else {
// Only add loopback addresses. Filter these because we might
// not _have_ an IPv6 loopback address.
for _, addr := range ifaceAddrs {
for _, addr := range h.allInterfaceAddrs {
if manet.IsIPLoopback(addr) {
h.filteredInterfaceAddrs = append(h.filteredInterfaceAddrs, addr)
}
Expand Down