libtorrent icon indicating copy to clipboard operation
libtorrent copied to clipboard

UDP over SOCKS5 does not work with some SOCKS5 servers that return ATYP == 3 forwarder address

Open arvidjaar opened this issue 1 year ago • 2 comments

Please provide the following information

libtorrent version (or branch): 2.0.5 platform/architecture: Ubuntu 22.04, x86_64 compiler and compiler version: Distribution package libtorrent-rasterbar2.0:amd64 2.0.5-5 please describe what symptom you see, what you would expect to see instead and how to reproduce it. qBittorrent client fails to talk to UDP tracker over SOCKS5 with generic "access denied". There are two problems, the first one is generic and not related to trackers specifically.

Apparently quite a lot of public SOCKS5 servers return NULL hostname (ATYP 3) in response to UDP ASSOCIATE request. As example is 37.99.224.225, port 7497. This looks like following:

Request: Data: 05030001000000000000 Repsonse: Data: 05000003 Data: 01001d49

The same SOCKS5 proxy works as example with Python socks module which simply ignores any hostname in ATYP == 3 response on assumption that normally SOCKS5 server is also SOCKS5 UDP forwarder. I have proof of concept patch that does the same. I am fine to add explicit check for "empty" name. Patch attached. I am using local build based on Ubuntu package with added patches which work for my purpose.

socks-udp-atyp3.txt

arvidjaar avatar Jul 30 '22 18:07 arvidjaar

first step at fixing this: https://github.com/arvidn/libsimulator/pull/68

arvidn avatar Aug 22 '22 08:08 arvidn

I simplified your patch a bit and added a test: https://github.com/arvidn/libtorrent/pull/7027 Would you mind giving it a try to make sure it still works?

arvidn avatar Aug 22 '22 09:08 arvidn