Skip to content

fix UDP forwarding#2

Open
diyism wants to merge 4 commits into
ge9:mainfrom
diyism:main
Open

fix UDP forwarding#2
diyism wants to merge 4 commits into
ge9:mainfrom
diyism:main

Conversation

@diyism
Copy link
Copy Markdown

@diyism diyism commented Apr 23, 2026

Changes

  1. Added ForwardUDPV3 (tsproxy/port_forward_udp_v3.go)
    • Uses Listen() + Accept() for proper tsnet UDP handling
    • Simplified connection-oriented approach with io.Copy
  2. Added listenUDPAsListener helper (tsproxy/port_forward_udp_fixed.go)
    • Abstracts the difference between Tailscale and regular UDP listening
  3. Updated main.go
    • Changed UDP forwarding to use ForwardUDPV3 by default
  4. Fixed timeout bug in original ForwardUDP
    • Changed time.Duration(t.udpTimeout) to time.Duration(t.udpTimeout) * time.Second

diyism added 4 commits April 23, 2026 19:50
- Use Listen() + Accept() instead of ListenPacket() for Tailscale UDP
- Fix timeout calculation bug (330ns -> 330s)
- Add ForwardUDPV3 with proper connection-oriented UDP handling
- Include compiled binary ts-proxy-v3-test
- Requires TS_DEBUG_MTU=1400 for QUIC traffic to prevent packet fragmentation
@ge9
Copy link
Copy Markdown
Owner

ge9 commented Apr 26, 2026

Thank you for the pull request!
The current ForwardUDP is AI-generated, so it's okay to totally replace it with your PR.
I have a question, what is the functional difference between ForwardUDPFixed and ForwardUDPV3?
We can choose either one if one is better than the other, or add a new option to switch between them if there is a trade-off.

@diyism
Copy link
Copy Markdown
Author

diyism commented Apr 26, 2026

My fault, I should get rid of ForwardUDPFixed():

main.go
  └─> ForwardUDPV3()  ✓ used  (from port_forward_udp_v3.go)
        └─> listenUDPAsListener()  ✓ used (from port_forward_udp_fixed.go)
ForwardUDPFixed()  ✗ unused

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