-
Notifications
You must be signed in to change notification settings - Fork 88
Various UDP fixes/improvements #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Actually implement the whole "A UDP association terminates when the TCP connection that the UDP ASSOCIATE request arrived on terminates" thing, instead of leaking resources (oops!) Let's be strict and error out when garbage is written to the controlling TCP connection.
We're not supposed to stop upon encountering an error, we're supposed to drop the packet and go on. Let's split the inner parts of the loops into functions that return Result and match on that to just debug log. While here, reduce ridiculous 64K buffer sizes and simplify some silly code.
To avoid the need to copy-paste the bind-and-reply-success code, allow reusing it with a custom transport function.
src/server.rs
Outdated
.ok_or(SocksServerError::Bug("no socket addrs"))?; | ||
|
||
target_addr.set_ip(match target_addr.ip() { | ||
std::net::IpAddr::V4(v4) => std::net::IpAddr::V6(v4.to_ipv6_mapped()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the advantage to use to_ipv6_mapped
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not new; UDP support was initially added here using dual-stack sockets (which are v6 sockets that use mapped v4 addresses to reach v4 destinations). Actually, we do need to check about handling the case when v6 is completely unavailable…
Can you help review this PR @yuguorui |
a8e4cd9
to
4c12963
Compare
Yes, please give me a few days. |
At least hev-socks5-tunnel as a client does not expect v6-mapped ones in response to v4 requests.
Helpful for writing custom UDP transports
4c12963
to
c06b067
Compare
Thanks @valpackett about the last commits, I'll test it then release a RC |
Dear all, FYI v1.0.0-rc.0 has been released https://github.com/dizda/fast-socks5/releases/tag/v1.0.0-rc.0 |
Most importantly: not stopping the whole UDP proxy if something goes wrong with one packet.
Includes #60