comit-network / rust-libp2p-tokio-socks5

Libp2p transport for sending TCP traffic via a SOCKS5 proxy e.g., over Tor network.
GNU General Public License v3.0
10 stars 4 forks source link

Only supports Tor target addresses #1

Open tcharding opened 4 years ago

tcharding commented 4 years ago

Problem

Currently the dial method of the transport converts the input Multiaddr into a string address that is in the form that Tor expects.

Onion v3 Multiaddr: /onion3/7gr3dngwhk74thi4vv6bm3v3bicaxe4apvcemoxo3hadpvsyfifjqnid:7 Tor address: 7gr3dngwhk74thi4vv6bm3v3bicaxe4apvcemoxo3hadpvsyfifjqnid.onion:7

Clearly this address conversion will not work for non-tor proxies.

Solution discussion

In order to support other SOCKS5 proxies we need to control how the multi address is converted into an address for the target SOCKS5 proxy. See the dial method, specifically:

        let dest = tor_address_string(addr.clone())
            .ok_or_else(|| TransportError::MultiaddrNotSupported(addr))?;

This functionality will somehow need to be made configurable.

thomaseizinger commented 3 years ago

We don't necessarily have to bail if it is something else other than a tor address right? We could just pass on whatever we got passed. There are probably more applications that can run over socks5 so over time, this list could be extended.

I am thinking of something like:

let dest = match segment {
    "onion" => parse_tor_address,
    "foobar" => parse_foo_bar_address,
    _ => addr
};
thomaseizinger commented 3 years ago

I guess this could also be made even more dynamical by parsing functions in the constructor and store them as Box<Fn>.

tcharding commented 3 years ago

Thanks for the comment. I'm not personally super motivated to extend this crate for use with other proxies since I have no need for it. I wanted to say, I appreciate you taking the time to think about this issue though.

thomaseizinger commented 3 years ago

Thanks for the comment. I'm not personally super motivated to extend this crate for use with other proxies since I have no need for it. I wanted to say, I appreciate you taking the time to think about this issue though.

No sweat, no immediate need on my side either but I was interested in thinking about the problem :)