arvidn / libtorrent

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

Make proxy_peer_connections and proxy_tracker_connections settings independent #7397

Open syphyr opened 1 year ago

syphyr commented 1 year ago

Please provide the following information

libtorrent version (or branch): master

platform/architecture: linux

compiler and compiler version: gcc-9

Some trackers are udp only but the available proxy does not support udp connections. I would like to make tcp peer connections with proxy and use direct connection to connect to udp tracker.

If proxy_peer_connections and proxy_tracker_connections could be enabled independently, then it would be possible to connect to udp trackers with a direct connection and use tcp peer connections with the available proxy.

syphyr commented 1 year ago

The goal is to have the following two independent settings in torrent client:

1) Force communication with peers over proxy 2) Force communication with trackers over proxy, including DHT.

arvidn commented 1 year ago

If proxy_peer_connections and proxy_tracker_connections could be enabled independently, then it would be possible to connect to udp trackers with a direct connection and use tcp peer connections with the available proxy.

What do you do when you receive a direct incoming peer connection? It sounds like you want a mode where you just ask for peers from the tracker, without it recording your IP and port in its peer list

syphyr commented 1 year ago

A mode where the direct vpn connection handles the udp tracker because it can support udp connections and the other proxy handling the peer connection with tcp only.

arvidn commented 1 year ago

the case I was getting at is that when you contact a tracker, it will look at the source IP (and port in the case of DHT) and assume that's how one can reach your peer. That source IP and port will be handed out to other peers.

It doesn't really matter whether you use some other proxy for making outgoing connections to peers, incoming connections will be made based on the source IP of your tracker announce.

so, if you don't use a proxy for the tracker announce, other peers will connect to you directly. They don't know anything about your proxy for peer connections.

Another aspect of this is UPnP and NAT-PMP (/PCP). If you have some specific plan to announce your public IP but not accept incoming connections over it, the port forwarding would also need an independent configuration. But I suppose you could just disable port forwarding.

However, if you have a full-cone NAT, the fact that you announced to the tracker may have opened a pin-hole allowing peers to connect to you anyway. At least over uTP (since that's UDP).

syphyr commented 1 year ago

A way to keep the vpn from knowing what the peer connections are doing over a proxy.

syphyr commented 1 year ago

The only torrent client available that has the ability to independently control the tracker and peer connection proxy settings is tTorrent on Android. I can verify that it works as expected. It would be really great if this library could also support that functionality for a Linux solution.

arvidn commented 1 year ago

the first step is to define, precisely, how it's expected to work.

evilblade666 commented 10 months ago

Yes! Thank you, Syphyr, for mentioning this tTorrent app. Just checked and it has EXACTLY the behavior I need, when you can connect to trackers directly and to peers via proxy! To bad it's only for Android :(