Skip to content

Conversation

@AgeManning
Copy link
Member

@AgeManning AgeManning commented Sep 19, 2025

Description

Routers have a wide variety of mechanisms for routing behind a NAT. When sending traffic, some can use random source ports, some can round-robin between a variety of ports. In the cases where a router uses a handful of mapped ports to send traffic from, the PONG responses from our peers can indicate a handful of candidates that could be our reachable external address.

In general, if there are multiple candidates for our true external contactable address, then this likely means that none of them are actually contactable, rather the SNAT configuration of the router hasn't been configured correctly. Any peer trying to contact us from these multiple competing ports, will likely to fail (Symmetric NAT'ing).

Therefore, this PR adjusts the logic behind choosing what is a viable external contactable address.

The following conditions must now be met:

  • Enough votes for the socket that meet or exceed the minimum vote threshold (within the vote duration time period)
  • The winning socket must exceed the next highest competitor by at least 20% 30%
  • If there are two candidates above the threshold, none are chosen.

The idea here is to ignore scenarios where there are multiple competing sockets as these all are likely invalid.

EDIT: I've decided the last condition is too strict. It likely could be manipulated. Instead I've shifted the difference between majority and next highest majority to be 30%.

@AgeManning AgeManning merged commit 42d6ac5 into master Sep 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants