Accepting incoming connections over Tor through the Tor proxy. I'm developing a socks client in rust for tokio tcp streams. Like https://crates.io/crates/tokio-socks but with upgraded libraries and support for resolving onion addresses.
Tor proxy does not support the SOCKS BIND command. However, I know it's possible to accept incoming requests through the proxy because zeroMQ does it (on a high level by setting the SOCKS proxy, and "binding" to an onion address).
Figuring out the protocol
The SOCKS CONNECT and BIND protocols are implemented and work (using 3proxy to test). When it comes to tor (which doesn't have BIND), this is currently where I'm stuck:
- Authentication method selection
[0x05, 0x01, 0x00]or
[0x05, 0x02, 0x00, 0x02]([version], [nmethods], [methods...])
- Receive the accepted auth method (so
[0x05, 0x00]No auth)
Here's where I'm not sure. I need the socks protocol to notify me when someone connects to the hidden service. So far, I don't receive anything from the socks proxy when attempting to connect to the hidden service.
Tor proxy only supports CONNECT and the tor extensions RESOLVE and RESOLVE_PTR. I tried to CONNECT to the hidden service first (maybe to "register"?) but that, as expected, returns a SOCKS error (HostUnreachable). Perhaps the tor proxy will send an OK(0x00) response when someone connects to the hidden service. So far, that appears not to be happening.
What is the correct protocol for "listening" for connections on a hidden service through the SOCKS proxy?