`/dnsaddr` can not be properly used with secure WebSocket transport
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Description
Currently there is no way to properly pass /dnsaddr to WSS transport and work as expected:
- If you wrap
libp2p::websocket::WsConfigwithlibp2p::dns::Transportthen you break secure WebSocket because DNS transport will resolve/dns4to/ip4. - If you wrap
libp2p::dns::Transportwithlibp2p::websocket::WsConfigthen you break/dnsaddrbecause it will never fetch the multiaddresses from DNS.
Currently 2 is the recommended way (link).
Motivation
I want to be able to use /dnsaddr with secure WebSocket.
Requirements
I want to be able to wrap libp2p::websocket::WsConfig with libp2p::dns::Transport which will resolve only /dnsaddr before it passing the multiaddr to WebSocket transport.
For example:
let inner_tcp_transport =
dns::tokio::Transport::system(tcp::tokio::Transport::new(tcp::Config::default()))
.unwrap();
let wss_transport = websocket::WsConfig::new(inner_tcp_transport);
let mut dns_opts = dns::ResolverOpts::default();
dns_opts.resolve_dnsaddr_only = true;
let transport =
dns::tokio::Transport::custom(wss_transport, dns::ResolverConfig::default(), dns_opts);
In case of /dnsaddr the above transport should have the following flow:
- User dials to
/dnsaddr/da-bridge-1.celestia-arabica-11.com/p2p/12D3KooWGqwzdEqM54Dce6LXzfFr97Bnhvm6rN7KM7MFwdomfm4S - DNS transport resolves multiaddr to
/dns/da-bridge-1.celestia-arabica-11.com/tcp/2122/tls/ws/p2p/12D3KooWGqwzdEqM54Dce6LXzfFr97Bnhvm6rN7KM7MFwdomfm4S - DNS transport passes the
/dnsmultiaddr to WebSocket transport. - WebSocket transport initializes TLS based on
/dnsmultiaddr and passes multiaddr to TCP transport. - TCP transport resolves
/dnsmultiaddr to/ip4multiaddr and establishes the connection.
In case of /dns the above transport should have the following flow:
- User dials to
/dns/da-bridge-1.celestia-arabica-11.com/tcp/2122/tls/ws/p2p/12D3KooWGqwzdEqM54Dce6LXzfFr97Bnhvm6rN7KM7MFwdomfm4S - DNS transport passes the
/dnsmultiaddr to WebSocket transport. - WebSocket transport initializes TLS based on
/dnsmultiaddr and passes multiaddr to TCP transport. - TCP transport resolves
/dnsmultiaddr to/ip4multiaddr and establishes the connection.
Open questions
It would be hard to implement this kind of transport combination in SwarmBuilder.
Are you planning to do it yourself in a pull request ?
Maybe
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with transports/websocket/src/lib.rs, especially the documented transport wrapping order, then inspect the DNS and WebSocket transport entry points. Confirm the composition preserves /dnsaddr and /dns for secure WebSocket while leaving TCP resolution intact; done means both example flows work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100