libQtShadowsocks
libQtShadowsocks copied to clipboard
[Probably fixed] server mode UDP relay not working
OS: Windows 7 SP1 x86 Running shadowsocks-libqss in server mode. The client (a OpenWrt router) is using following iptables rule to redirect UDP packets (sent by hosts in LAN) to ss-redir:
iptables -t mangle -A PREROUTING -p udp -s [LAN IP RANGE] -p udp -j TPROXY --on-ip 0.0.0.0 --on-port [ss-redir listening port]
But, it didn't work. I got some error messages from ss-redir like this:
2018-03-11 20:12:35 ERROR: [udp] remote_recv_bind: Address family not supported by protocol
ss-tunnel seemed to work (with a DNAT rule redirecting DNS requests to ss-tunnel), but, if I recalled correctly, it still had some weird problems, which were similar to the description on this post: https://www.v2ex.com/t/436361
shadowsocks-android didn't work, either, unless the "Enable UDP relay" feature was un-ticked.
Although I'm not a professional programmer, I've tried to skim over the code. After that, I thought the problem might be relevant to here:
https://github.com/shadowsocks/libQtShadowsocks/blob/master/lib/network/udprelay.cpp#L175
I then tried to replace Common::packAddress(r_addr, r_port) by destAddr (lambda captures are modified as well), then the re-compiled program seemed to work!
这是修复了UDP可用性的问题吗?
I haven't looked into the issue myself yet, can you compare the code of shadowsocks-libev or the python version? I might have implemented it wrong in the first place so it'd be great if that's the case and this can fix the UDP issue
@librehat To be honest, this "fix" is not perfect, too. It seemed that the server didn't release UDP sockets in time, which made the clients suffer from DNS timeouts.