-
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
feat: allow dialing wss peers using DNS multiaddrs #1592
Conversation
Does it make sense to dial WSS in the first place? We might want to consider disabling WSS dialing altogether (except for tests), as any node offering WSS will also offer TCP and that's always preferable.
Can we pass the resolver to this transport? Probably would have to teach Steven's constructor magic that there's a new parameter. |
Is there a way to have a test to demonstrate correctness? |
Thinking about it, this logic should probably live in the swarm.
@BigLep, what do you mean? We have unit tests for dialing. |
We have a source code change without a corresponding test. I'm assuming we didn't have a failing test in the past that this code is now fixing. If that is true, then is there a test we should add to show this works as intended? |
Yes, I think we should:
|
Should we prefer WS over WSS as well, or the other way around? It seems like generally either what we have here is sufficient or we shouldn't be using ranking independent of this PR. go-libp2p/p2p/net/swarm/dial_worker.go Line 283 in d7ba372
@marten-seemann are you able to take a look at this, or is this waiting on me/someone else to push things along? Areas where I feel most in need of help here:
|
If I understand correctly, this ranking function isn't particularly useful, since we dial 8 addresses at the same time. My point is that we shouldn't dial WebSocket at all (if we have a TCP address), as there's no benefit in first establishing a TCP connection, the layering WebSocket on top of that, and then speaking libp2p. The only reason we do this is to enable browsers to connect to us. The same will apply for WebTransport and QUIC addresses.
We should prefer WS, WSS doesn't buy us anything, unless we encode the libp2p peer ID into the certificate (like we do for the TLS handshake). Since we don't expect to use WSS in any other environment than browsers (that don't provide an API to access the certificate), there's not really a point in doing so.
We should have unit tests in the websocket package that show that we can dial DNS multiaddrs (we might need to mock the DNS resolver for that). Given how close we are to basic Testground interop tests, I think we can defer integration tests. |
I know this isn't the ideal solution, but it does fix dialing WSS with dns multiaddrs. But what are the downsides of merging this and doing the proper solution later? |
The only downside I can think of at the moment (aside from wasted dials, but IMO that's not as bad as failing to dial at all) is that there's potentially a security leak if someone doesn't want go-libp2p to be using the OS resolver since this will use the OS resolver rather than the one given to the libp2p host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes #1593
This fixes an issue where the WSS dialer can only handle IP multiaddrs not DNS
go-libp2p/p2p/transport/websocket/websocket.go
Line 26 in d7ba372
A couple areas to consider here for improvement (recommendations or maintainers pushing commits to this PR are welcome).