-
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
DNS resolution should be moved to the transports #1597
Comments
I am not convinced its the transport's responsibility to do dns resolution; and we can pass the domain in a contrext option for websockets. For caching, we should probably rely on the resolver, might make sense to make a caching layer for the vanilla/OS resolver as the DoH resolver already does it. |
IIUC this isn't technically what happens instead we get both At the moment WSS chooses the worst option by only choosing the IP one due to the filtering here
IIUC the issue above is not so much that we're missing the DNS ID when dialing websockets its that we've effectively thrown away information by resolving DNS -> IP and keeping them as two equally valid addresses, when in reality one of them derives from the other. This means we're stuck trying to figure out which of A couple ways I can see approaching this:
I suspect 1 is easier to do, but either seem plausible. |
It seems to me that a transport should encapsulate all the logic around (at least a part of) the multiaddr. It seems weird that the host knows how to resolve a dns name to an ip address, shouldn't this be fully the transport's responsibility? I think I agree with @marten-seemann here. As for caching, isn't the OS doing this already? Have we seen a need to handle this caching ourselves?
I'm not sure I follow, do you mean only keep the peer id in the peer store? Or only keep the unresolved |
Ah we support custom dns resolvers. Okay I agree the cache should live with these resolvers. |
I meant keeping the addresses that libp2p learns about either from the caller calling something like The comment around the peer ID was just to say that if the caller does something like |
To clarify, this proposal only applies to |
Just started to play around with this, and ran into the following issue: This however prevents us from just doing a call to |
Fixes an issue where the implied SNI is dropped when connecting over a p2p-circuit address. For example if you connected to a peer over `/dns/example.com/wss/p2p/qmFoo/p2p-circuit/p2p/qmTarget` the swarm would resolve example.com without preserving the SNI information needed for `WSS`. The WebSocket transport would only get the IP address of example.com without knowning the host name it needed to use for the SNI. We had the same problem previously when dialing a wss address. See #1597. This was fixed by letting transports resolve the multiaddr instead of the swarm. This case is similar, except that we want to tell the swarm to just skip resolving altogether since the inner transport will resolve the multiaddr later.
We currently resolve multiaddrs in the basichost:
go-libp2p/p2p/host/basic/basic_host.go
Line 712 in d7ba372
This leads to problems with transports that, for example, validate TLS certificates, as they're kept ignorant about the domain name, and only learn the resolved address. This applies to WebSockets (thanks to @aschmahmann for bringing it up in #1592) and will apply to WebTransport as well (although we will mostly use certificate hashes there).
Architecturally, address resolution should probably live within the transport. This has a few advantages:
However, there are caching implications. Currently, we implement some rudimentary caching for a const 2 minutes, not based on the TTL of the DNS record:
go-libp2p/p2p/host/basic/basic_host.go
Line 707 in d7ba372
Arguably, caching should live inside the DNS resolver, so one could argue that this is safe to remove.
@Stebalien @vyzo @aschmahmann @MarcoPolo Thoughts?
The text was updated successfully, but these errors were encountered: