near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.31k stars 605 forks source link

network: pick STUN server to match node_addr IP version #11628

Closed saketh-are closed 4 weeks ago

saketh-are commented 1 month ago

When nodes query an address such as stun.l.google.com:19302 for which there exist both IPv4 and IPv6 records, tokio::net::UdpSocket::connect chooses one arbitrarily.

We should make sure to query the appropriate server based on the IP version of the node's TCP listener address.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 80.55556% with 7 lines in your changes missing coverage. Please review.

Project coverage is 71.46%. Comparing base (cd7526d) to head (ab16c51). Report is 4 commits behind head on master.

Files Patch % Lines
chain/network/src/stun/tests.rs 75.00% 0 Missing and 5 partials :warning:
...in/network/src/peer_manager/network_state/tier1.rs 50.00% 0 Missing and 1 partial :warning:
chain/network/src/stun/mod.rs 87.50% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #11628 +/- ## ========================================== - Coverage 71.46% 71.46% -0.01% ========================================== Files 788 788 Lines 160854 160867 +13 Branches 160854 160867 +13 ========================================== + Hits 114958 114964 +6 - Misses 40876 40877 +1 - Partials 5020 5026 +6 ``` | [Flag](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | Coverage Δ | | |---|---|---| | [backward-compatibility](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (+<0.01%)` | :arrow_up: | | [db-migration](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (+<0.01%)` | :arrow_up: | | [genesis-check](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.35% <7.14%> (+<0.01%)` | :arrow_up: | | [integration-tests](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `37.60% <30.55%> (-0.10%)` | :arrow_down: | | [linux](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `68.90% <77.77%> (+0.01%)` | :arrow_up: | | [linux-nightly](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `70.94% <77.77%> (-0.03%)` | :arrow_down: | | [macos](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `52.57% <71.42%> (+0.26%)` | :arrow_up: | | [pytests](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.59% <7.14%> (+<0.01%)` | :arrow_up: | | [sanity-checks](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.38% <7.14%> (+<0.01%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `66.12% <80.55%> (-0.01%)` | :arrow_down: | | [upgradability](https://app.codecov.io/gh/near/nearcore/pull/11628/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.28% <0.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.