Skip to content

Conversation

valpackett
Copy link
Contributor

Most importantly: not stopping the whole UDP proxy if something goes wrong with one packet.

Includes #60

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()),
Copy link
Owner

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?

Copy link
Contributor Author

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…

@dizda
Copy link
Owner

dizda commented Feb 12, 2025

Can you help review this PR @yuguorui

@yuguorui
Copy link
Contributor

Can you help review this PR @yuguorui

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
@dizda
Copy link
Owner

dizda commented Feb 19, 2025

Thanks @valpackett about the last commits, I'll test it then release a RC

@dizda dizda merged commit 0f8ca5a into dizda:master Feb 19, 2025
@valpackett valpackett deleted the push-ptmrtlprvrpt branch February 19, 2025 07:51
@dizda
Copy link
Owner

dizda commented Mar 3, 2025

Dear all,

FYI v1.0.0-rc.0 has been released https://github.com/dizda/fast-socks5/releases/tag/v1.0.0-rc.0

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.

3 participants