-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(socks) proxy support #286
Comments
So, @rklaehn pointed out a simple solution for dialing: use the websocket transport. It should work just fine over any HTTP(s) proxy. All we need to do is expose this somehow. Unfortunately, listening could be tricky. |
So it should work, but in my experiments I could not actually get it to work. Just to clarify: websocket is a complete transport that will work just as well as the native tcp or udp transports? So in theory you could have a swarm just communicating over ws? Or is it in some way limited? |
Yes, it's a full transport. I assumed it wouldn't work because we don't explicitly tell it to use the proxy from the environment. However, it looks like it does this by default. So, this is a bit odd. It should just work. I'm wondering if it's a port issue. Does your proxy not support forwarding to random ports? |
I too need a transport proxy interface. In many cases in Go, proxies are implemented by accepting a EDIT: as mentioned in libp2p/go-ws-transport#33 I instead am just proxying raw |
Did anyone find a solution that worked for this problem?
|
So, I've tested this and dialing does actually work. You just need to correctly configure your environment to use a proxy: https://wiki.archlinux.org/index.php/Proxy_settings#Environment_variables For example, if you're using SSH, you can run Note: this still doesn't help with inbound connections. |
I have my environment variables set in etc/environment and exported http_proxy in ~/.bashrc, Ive tried passing http_proxy before the daemon and before the computes daemon. Im only connecting 2 Ubuntu machines through a bridged network and have them communicate in a swarm. Im still getting the following task status:
|
Ah. Sorry, I forgot. While we can dial websocket addresses, go-ipfs doesn't listen on them by default. That's probably the problem here. Note: we haven't enabled listening by default as our primary usecase for the websocket transport is allowing browsers to dial go-ipfs nodes. Unfortunately, browsers often need to dial websocket over https and IPFS nodes can't get valid certificates. I've opened an issue for enabling it by default: ipfs/kubo#5251. In the mean-time, try running |
|
Damn. It looks like the bootstrappers only listen on |
Any idea what the scope might be to update this? |
Are there any updates? |
Team, are there any updates on this? |
Any updates on this? |
Dialing wss is now supported (libp2p/go-ws-transport#115). So this should work if you use the websocket transport |
Are there bootstrap websocket nodes? |
How are you hoping to use this? If you're trying to leverage the IPFS Public DHT while only having websockets available as a transport you'll be out of luck since most of the DHT server nodes aren't listening on websockets and so your queries won't really work even if you can talk to the bootstrappers. |
it doesn't seem like HTTP_PROXY is respected:
this should fail as there is no proxy at |
ok just in case it silently skips the proxy if it doesn't work I tried with a real proxy, no dice:
@aschmahmann any clues? we are absolutely dying not being able to dial out, just need to connect to a known boostd node |
go-libp2p doesn't respect HTTP_PROXY, as a basic code search confirms: https://github.com/search?q=repo%3Alibp2p%2Fgo-libp2p%20HTTP_PROXY&type=code |
@marten-seemann am I not reading @Stebalien's comment here correctly as implying that it should work? my initial guess was that this did not happen explicitly in go-libp2p but rather by default in some dependency, as no commit was referenced in that comment |
Another basic code search confirms that the websocket library also doesn't respect HTTP_PROXY: https://github.com/search?q=repo%3Agorilla%2Fwebsocket%20HTTP_PROXY&type=code |
gorilla/websocket does in fact support using a proxy: https://pkg.go.dev/github.com/gorilla/websocket#Dialer.Proxy and it seems like the var does get read in as examples of usage show: gorilla/websocket#508 |
@marten-seemann ok so this is a feature of https://pkg.go.dev/golang.org/x/net/http/httpproxy which is used by gorilla/websocket as far as I can tell, so this not being observed here is extremely strange to me |
ok so this is kind of suspect: go-libp2p/p2p/net/swarm/swarm_dial.go Line 670 in 4651a0d
this happens inside a call to @marten-seemann looks like you signed off on the last PR that touched this code here EDIT: ok no this is wrong, dumping the traffic shows that it is indeed speaking websockets -- when provided only a ws address in a swarm connect command it does seem to be used (this may still be an issue for us with nodes that advertise both raw tcp and ws addresses but I'd like to sort out the proxy behavior first) |
Looks like you're right, if the
Not entirely sure if this means that the HTTP_PROXY will not be used, the way default values are set here is not the most obvious. Should be pretty straightforward to test out though.
There's no such thing as "explicitly requesting" a transport if you look at the swarm API, but you're right, libp2p chooses the best transport when dialing. And that means preferring plain TCP over WebSocket, if available. go-libp2p was never designed to work with HTTP_PROXY, and it's probably a lot of work to make it actually work. Also, you're limiting yourself to a single (not very widely supported) transport, so the value of doing that work is limited as well. There are better ways to connect a node behind a firewall / NAT to the rest of the network anyway. |
thank you, I have just arrived at the same conclusion (see edit above) I would absolutely prefer not to use ws addresses here (since it requires boost node operators to configure them explicitly and possibly exclusively) but no better solution has come to mind as we can't open arbitrary tcp streams to the outside -- I am very open to ideas all we need to do is dial SPs to push deal proposals to their boost |
It won't be used. Looks like this behavior was broken in libp2p/go-ws-transport@0ea4a8a. Seems like easy enough functionality to restore. I've put up a small PR (#3136) that just re-adds the environment variable checking. If anyone feels the need for something more generic (or to not support the environment variables by default) we can also pass the proxy function as an option although the proxies supported will have to be left up to what gorilla/websocket supports.
It certainly seems fair to say that enabling proxies across all supported transports and other network components might be a pain. However, IMO it seems reasonable to enable it for people who need it and let them pass along feature requests / needs if we need to expand support. Starting with proxy support for WebSockets doesn't seem unreasonable, am I missing something? @parkan can you check if the linked PR is enough for your use case? |
In some environments, users need to be able to proxy all traffic through, e.g., a corporate socks proxy. This sucks but is sometimes inevitable.
Solution:
Problems:
The text was updated successfully, but these errors were encountered: