Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(iroh): when ports change for the current best address, use it
  • Loading branch information
Frando committed Jun 30, 2025
commit a8ee257e2f94c7b4ae0badd67b25513b98c3d46f
8 changes: 8 additions & 0 deletions iroh/src/magicsock/node_map/best_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,19 @@ impl BestAddr {
}
Some(state) => {
let candidate = AddrLatency { addr, latency };
// If the current address has exceeded its trust interval, or if the new address has lower latency,
// use the new address.
if !state.is_trusted(confirmed_at) || candidate.is_better_than(&state.addr) {
self.insert(addr, latency, source, confirmed_at);
// If the new address is equal to the current address, mark it as reconfirmed now and expand its trust
// interval.
} else if state.addr.addr == addr {
state.confirmed_at = confirmed_at;
state.trust_until = Some(source.trust_until(confirmed_at));
// If we receive a pong on a different port but the same IP address as the current best addr,
// we assume that the endpoint has rebound, and thus use the new port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main issue with this logic is that I find it fairly arbitrary. It fixes an artificial test case, but it seems like a sub-set of the cases that need to be fixed. We're also not really sure we can send on this path at this point, but I'm not even sure if that's something we're always sure of anyway.

} else if state.addr.addr.ip() == addr.ip() {
self.insert(addr, latency, source, confirmed_at)
}
}
}
Expand Down
Loading