grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

Support socks5 proxy

Open tiero opened this issue 4 years ago • 7 comments

Is your feature request related to a problem? Please describe.

I want to use my tor client that expose a socks5 proxy, to connect to gRPC services exposed trough .onion endpoint

Describe the solution you'd like

Add additional env var here something like socks5_proxy

Describe alternatives you've considered

Using a client written in another language. ie. grpc-go has a custom net dialer you can pass down, so you can customize this.

What I did

I tried doing this

export http_proxy="http://localhost:9150"
export grpc_proxy="http://localhost:9150"
export http_proxy="socks5://localhost:9150"
export http_proxy="socks5h://localhost:9150"

All do not work

tiero avatar Mar 03 '21 09:03 tiero

I want to note a couple of things. First, the library uses http_proxy and grpc_proxy interchangeably, with the only difference being that grpc_proxy is a higher priority, so adding another environment variable wouldn't change anything. And second, only the http:// protocol is supported, so I would expect an error to be output if you use socks5:// or socks5h://. So, the only way you're going to connect to gRPC services through TOR is by exposing a HTTP CONNECT proxy in your TOR client.

murgatroid99 avatar Mar 03 '21 17:03 murgatroid99

so I would expect an error to be output if you use socks5:// or socks5h://.

Yes indeed, I got errors. Just mentioned for sake of completeness.

So, the only way you're going to connect to gRPC services through TOR is by exposing a HTTP CONNECT proxy in your TOR client.

Ok, so practically, I would need to add HTTPTunnelPort in my torrc file, is that correct?

PS: Any reason why we wouldn't directly support socks5 proxies in grpc-node like we can in grpc-go and others? I see some setup where may be difficult to change tor client configuration

Thanks

tiero avatar Mar 03 '21 18:03 tiero

I am not familiar with TOR configuration; you'll have to figure that part out for yourself.

My understanding is that grpc-go and other libraries do not actually directly support socks5 proxies. Rather, grpc-go provides an interface to use a custom dialer that can connect through a socks5 proxies, and the other libraries do not even provide that.

murgatroid99 avatar Mar 03 '21 19:03 murgatroid99

grpc-go provides an interface to use a custom dialer that can connect through a socks5 proxies, and the other libraries do not even provide that.

Yes exaclty, I pass down a custom dialer in go. So yes, it's not that simple more how nodejs works vs go inner interfaces mechanics. Thanks, will try to circumnvent this via my tor client.

tiero avatar Mar 03 '21 21:03 tiero

What are the advantages of enabling a socks5 proxy as opposed to using the http proxy?

CMCDragonkai avatar Apr 01 '21 04:04 CMCDragonkai

What are the advantages of enabling a socks5 proxy as opposed to using the http proxy?

This means "tinkering" with the tor client configuration.

I have use case in an app (wich uses grpc-js) where I need users to call an onion hidden service that exposes a grpc sever. If grpc-node only support http-proxy I cannot just say to the users "Hey open a Tor Browser and that's it" now you can use the app (wich is exposing a socks5 proxy on 9*50 port), but rather I need them to do extra instructions.

In go instead I can pass a custom dialer, so I can handle this out of grpc-go hands of course, in grpc-node instead we have this to be done inside.

Not a big deal, just nice to have it.

tiero avatar Apr 01 '21 11:04 tiero

grpc have no support then to those things. you cant just listen the thing.

red0bear avatar Jul 18 '22 01:07 red0bear