use outgoing interface's IP for UDP relay port #1030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(resending without an unnecessary file; cf. #1029)
Currently relay ports for SOCKS UDP associate are obtained with
nil
([::]:0
), and then replied to clients with the IP replaced by TCP local address.My implementation uses the TCP local address instead of
nil
when getting UDP relay ports.This solves possible problems in situations where the SOCKS server can be seen through more than one IP addresses.
For example, if we use some external interface address (like 10.0.0.1) to access gost SOCKS5 proxy running on the same machine as client, only my implementation will work, because current implementation will send back UDP packets using localhost (127.0.0.1), which is different from the replied relay port.
Also, the current implementation typically replies IPv4-mapped IPv6 address to IPv4 clients (like ::ffff:10.0.0.1), which is incompatible with redsocks (https://github.com/semigodking/redsocks) which is one of the most widely-used transparent SOCKS5 proxy clients. My implementation will also fix this.