update address when flipping firewall - #277
Open
marco-hp wants to merge 3 commits into
Open
Conversation
`_updateAddresses()` is usually called via `.add()` so has a sample. If the firewall is `OPEN` there is a lack of addresses, but we don't need to return the dht's apparent remote address if we have a sample. Added a test for each with the zero sample case being triggered via `unfreeze()` as that's the only way it theoretically be set. This may never be done in practice however.
Contributor
|
@marco-hp Thanks for catching this! The I pushed some changes as the solution doesn't account for samples that are available. I also adjusted the existing "zero-sample" test to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a race condition
Racer A: the node's own bootstrap self-check (dht-rpc's _bootstrap() → the "quick NAT heuristic" → _checkIfFirewalled()). This runs automatically once you start using a freshly-constructed HyperDHT, and it can flip the shared dht.firewalled boolean from true to false within milliseconds.
Racer B: that node's own holepunch negotiation for the in-flight connection — specifically, the moment roundPunch() builds round 1's payload, it reads c.puncher.nat.firewall and c.puncher.nat.addresses at that instant and ships them to the peer. That per-connection Nat instance derives its firewall value from the same shared dht.firewalled boolean Racer A is mutating.
-- coworking with Claude