arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.27k stars 997 forks source link

Feature: Add support for SOCKS5 BIND #7793

Open 0xThiebaut opened 1 week ago

0xThiebaut commented 1 week ago

Currently accepting inbound connections when a proxy is present relies on proxy_accept_incoming (#7726), optionally with a mixture of announce_ip and announce_port. This however causes a tight configuration coupling between the proxy and libtorrent where libtorrent needs to announce the proxy's listen port or vice versa. The SOCKS5 protocol provides functionality to accept inbound TCP connections through the BIND operation. This issue is to discuss whether we could add support for this into libtorrent and, if so, which approach would be best.

If implemented, it would enable libtorrent to negotiate a working TCP listening port with compatible SOCKS5 proxies and ensure this is automatically announced to TCP-based trackers.

@arvidn is this something you could see added into libtorrent?

arvidn commented 1 week ago

As far as I know, SOCKS5 BIND is already supported, as well as UDP ASSOCIATE for incoming TCP and uTP connections respectively.

BIND isn't quite meant for this use case, so it doesn't necessarily work that well with most proxies.

0xThiebaut commented 1 week ago

I know that outbound connectivity is implemented (CONNECT for TCP, ASSOCIATE for UDP) and, through hole-punching, it also provides inbound UDP. But inbound TCP would need BIND which I don't see being attempted. Is this located behind a specific setting?