Skip to content

Stun Nat Type Testing#3646

Merged
xiaokangwang merged 6 commits intov2fly:masterfrom
xiaokangwang:dev-stun-nat-type-testing
Mar 10, 2026
Merged

Stun Nat Type Testing#3646
xiaokangwang merged 6 commits intov2fly:masterfrom
xiaokangwang:dev-stun-nat-type-testing

Conversation

@xiaokangwang
Copy link
Copy Markdown
Contributor

This pull request introduces dual stack UDP support and adds a comprehensive STUN NAT behavior testing utility, along with several related enhancements and fixes. The most significant changes are the implementation of a dual stack UDP abstraction, integration of STUN protocol handling and testing, and updates to configuration and dependencies to support these features.

Dual stack UDP support:

  • Added FusedPacketConn abstraction in common/dualStack/fusedPacketConn/fusedPacketSocket.go to combine IPv4 and IPv6 UDP sockets, enabling dual stack UDP operations with correct socket selection for send/receive.
  • Updated common/packetswitch/gvisorstack/config.proto and config.pb.go to introduce the dual_stack_udp option in the Config message and its corresponding getter. (Fc53659fR1, [1] [2] [3]
  • Modified common/packetswitch/gvisorstack/dialer.go to instantiate FusedPacketConn when DualStackUdp is enabled, supporting dual stack UDP listening in the gVisor stack. [1] [2]

STUN NAT behavior testing utility:

  • Added STUN client connection, filtered connection, and processor utilities for handling STUN messages and transactions in common/natTraversal/stun/filteredStunConnection.go, processor.go, and stunClientConn.go. [1] [2] [3]
  • Introduced a new engineering command-line utility in common/natTraversal/stun/stuncli/stuncli.go that performs NAT type discovery tests using STUN, supporting SOCKS5 UDP relay and reporting NAT behavior results.
  • Registered the STUN CLI command in the main engineering command set in main/distro/all/all.go.

Dependency updates:

  • Added github.com/pion/stun/v3, github.com/pion/transport/v4, and github.com/wlynxg/anet as new dependencies in go.mod to support STUN protocol and dual stack networking.
  • Updated github.com/pion/logging to v0.2.4 and added github.com/pion/dtls/v3 for improved protocol support.

Minor fixes:

  • Corrected a typo ("pancis" → "panics") in app/log/command/config_grpc.pb.go.
  • Changed error construction from status.Errorf to status.Error in unimplemented gRPC methods for improved error handling.
  • Adjusted UDP destination initialization in Wireguard outbound processing for better compatibility with dual stack.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 0% with 674 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.97%. Comparing base (bf1803d) to head (b6c48b4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
common/natTraversal/stun/natTypeTest.go 0.00% 374 Missing ⚠️
common/natTraversal/stun/stuncli/stuncli.go 0.00% 141 Missing ⚠️
...mon/dualStack/fusedPacketConn/fusedPacketSocket.go 0.00% 67 Missing ⚠️
common/natTraversal/stun/processor.go 0.00% 33 Missing ⚠️
common/natTraversal/stun/stunClientConn.go 0.00% 32 Missing ⚠️
common/natTraversal/stun/filteredStunConnection.go 0.00% 10 Missing ⚠️
common/packetswitch/gvisorstack/dialer.go 0.00% 10 Missing ⚠️
common/packetswitch/gvisorstack/config.pb.go 0.00% 4 Missing ⚠️
app/log/command/config_grpc.pb.go 0.00% 2 Missing ⚠️
proxy/wireguard/outbound/outbound.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3646      +/-   ##
==========================================
- Coverage   23.29%   22.97%   -0.33%     
==========================================
  Files         857      863       +6     
  Lines       46766    47437     +671     
==========================================
+ Hits        10893    10897       +4     
- Misses      34615    35284     +669     
+ Partials     1258     1256       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xiaokangwang xiaokangwang merged commit 1f4dc3b into v2fly:master Mar 10, 2026
40 of 42 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