arvidn / libtorrent

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

DNS leak during DHT bootstrap over SOCKS #6295

Open ichorid opened 3 years ago

ichorid commented 3 years ago

Libtorrent 1.2.7 in Tribler on Windows and Linux. Libtorrent is using SOCKS5 proxy in Tribler. The same thing happens with client_test.

изображение

The rest of the traffic goes through the tunnel normally.

arvidn commented 2 years ago

this is not as simple as it might seem. I can't think of a way to actually resolve a name via SOCKS5, all you can do is to specify a hostname instead of an IP address when sending packets. The DHT routing table contains IP addresses, not hostnames. Currently there's an extra step to resolve names into IPs before adding them to the routing table.

I'm hesitant to make the routing table able to hold hostnames.

ichorid commented 2 years ago

There is a setting called dht_bootstrap_nodes. Documentation states:

This is a comma-separated list of IP port-pairs. They will be added to the DHT node (if it's enabled) as back-up nodes in case we don't know of any.

Is there a way to completely override the addresses of Mainline DHT nodes? At least in Tribler, we could start providing bootstrap nodes through our own means.

arvidn commented 2 years ago

yes, if you put IP addresses in that setting, there won't be any hostname lookups.

arvidn commented 2 years ago

I started exploring deferring hostname lookups to the DHT socket class, which supports SOCKS5 hostnames in this branch dht-hostname-lookups. It's far from complete and I think I should simplify the DHT implementation a bit first, to avoid the complexity from growing out of control