use LocalAddr for UDP associate bind address#65
Conversation
|
Oh sorry I found there is another pull request of much the same purpose (#63) but I think my implementation is more appropriate because clients on other hosts require external IP address to use UDP associate bind address. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #65 +/- ##
==========================================
- Coverage 66.66% 62.55% -4.11%
==========================================
Files 14 14
Lines 726 836 +110
==========================================
+ Hits 484 523 +39
- Misses 184 253 +69
- Partials 58 60 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
40c50a9 to
3a1c6a2
Compare
|
(Sorry I mistakenly generated merge commit so I discarded that and did rebase instead. The code is unchanged.) |
|
But then it will be difficult to make go-socks5 listen to the wildcard address (0.0.0.0:XXXXX)? |
here: ResolveUdpAddr(bindIp net.IP, request *Request) (*net.UDPAddr, error)@ge9 impl: ResolveUdpAddr(bindIp net.IP, request *Request) (*net.UDPAddr, error) {
return &net.UDPAddr{IP: request.LocalAddr.(*net.TCPAddr).IP, Port: 0}, nil
}@fregie impl: ResolveUdpAddr(bindIp net.IP, request *Request) (*net.UDPAddr, error) {
if bindIp == nil {
return nil, errors.New("not support")
}
return net.ResolveUDPAddr("udp", bindIp.String()+":0")
}any other impl: ResolveUdpAddr(bindIp net.IP, request *Request) (*net.UDPAddr, error) {
panic("implment me")
}maybe we can direct get |
|
Ah, I see, that's great! Thank you for your idea. |
|
@ge9 |
|
Oh, sorry, I've forgot to create a branch... |
710784a to
43e95d0
Compare
|
Maybe this is good to merge? |
In UDP associate, the IP address used for connection from the client should be notified to client (at least, https://github.com/3proxy/3proxy is implemented in this way).
This also fixes IPv6 address ([::]) replied for IPv4 UDP associate request (in bytes, [5, 3, 0, 1, 0, 0, 0, 0, 0, 0]).Sorry this is wrong.