erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
Other
3.22k stars 290 forks source link

[Feature Request] socks5 with udp support #188

Closed hdid closed 4 months ago

hdid commented 5 months ago

can you add UDP associate support for socks5 to handle udp packets (dns or ntp requests and so on)? thanx

erebe commented 5 months ago

Hello, Would you mind describing your use case/how you intend to use it ? I never saw anybody using UDP association, as it is kind of cumbersome to use.

hdid commented 5 months ago

i may use tun2socks for routing system traffic over wstunnel socks5.

bytejedi commented 5 months ago

I think socks5 with udp should not supported, please keep it simple.

bytejedi commented 5 months ago

@erebe The main problem solved by wstunnel is the problem of WireGuard UDP QoS. I hope to maintain this original intention.

erebe commented 5 months ago

Adding udp support in the socks5 server will not change anything for wireguard. wiregaurd will still use udp:// server, it is just that for now the socks5 server socks5:// only support tcp connection.

Anyway for now, I will work on supporting transparent proxy, I will see later for adding udp on socks5

cattyhouse commented 5 months ago

UDP associate is a standard sock5 feature, i think it is very useful if one needs to proxy udp traffic, things like udp dns, quic traffic, games, some audio call protocol, etc, via socks5 proxy. almost all socks5 proxy i have used support this feature.

wolfman42 commented 5 months ago

+1 for adding this feature. Use case is SNMP communication with devices that only support SNMP via UDP.

erebe commented 4 months ago

Hi, Just to let you know that I will work in the incoming weeks to support socks5 udp association.

surbiks commented 4 months ago

+1 good idea

erebe commented 4 months ago

By any chances, do you know a soft/way (running on linux) that allows to easily test udp association with socks5 ?

hdid commented 4 months ago

by tun2socks and dig tool or this script

erebe commented 4 months ago

Would you mind trying this pre release https://github.com/erebe/wstunnel/releases/tag/v8.6.0 and let me know if it works for you ?

You should be able to start the tunnel as usual with -L socks5://xxx

surbiks commented 4 months ago

Hi. I tested the latest version (v8.6.0) using this script and this script. UDP DNS packets are sent and received successfully.

wolfman42 commented 4 months ago

Hi. I tested the latest version (v8.6.0) using this script and this script. UDP DNS packets are sent and received successfully.

I tested with the same scripts under Windows and am getting an error as soon as I run the script a second time. It works the first time. Can you check that case on your end as well, please?

  wstunnel 8.6.0    ./wstunnel.exe client -L socks5://127.0.0.1:9999 ws://localhost:8888
2024-01-08T17:17:23.807036Z  INFO wstunnel::socks5: Starting SOCKS5 server listening cnx on 127.0.0.1:9999
2024-01-08T17:17:23.809100Z  INFO wstunnel::socks5_udp: Starting SOCKS5 UDP server listening cnx on 127.0.0.1:9999 with cnx timeout of 30s
2024-01-08T17:17:42.771773Z  INFO wstunnel::socks5_udp: New UDP connection for 1.1.1.1:53
2024-01-08T17:17:42.772069Z  INFO wstunnel::tcp: Opening TCP connection to localhost:8888
2024-01-08T17:17:53.796595Z ERROR wstunnel::socks5_udp: Cannot read from UDP server. Closing server: An existing connection was forcibly closed by the remote host. (os error 10054)

I started the server using: ./wstunnel.exe server ws://127.0.0.1:8888

wolfman42 commented 4 months ago

I just tried the same under Linux (WSL) and on the 2nd run of check.py it just hangs on the s.recvfrom(4096) call. No errors in the logs of the wstunnel client or server.

erebe commented 4 months ago

Thanks for the feedback, it should be fixed by latest commit. I have updated the release with the fix https://github.com/erebe/wstunnel/releases/tag/v8.6.0 Let me know if it is ok

erebe commented 4 months ago

I released it in v9.0.0 https://github.com/erebe/wstunnel/releases/tag/v9.0.0

Feel free to re-open if it is nok