Using `dns-sd` with `libp2p-mdns`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Summary
I am unable to use dns-sd tool with libp2p-mdns. See below for more info.
Expected behavior
I will give an example over another crate, mdns-sd. Suppose we register a service _p2p._udp with our hostname foobar there. Then, we will see ourself with:
$ dns-sd -B _p2p._udp
A/R Flags if Domain Service Type Instance Name
Add 3 11 local. _p2p._udp. foobar
We can then query that service instance as well:
$ dns-sd -Q _p2p._udp.local. PTR
A/R Flags IF Name Type Class Rdata
Add 40000003 11 _p2p._udp.local. PTR IN foobar._p2p._udp.local.
We can follow that PTR value to get SRV and TXT records:
# service records
$ dns-sd -Q foobar._p2p._udp.local. SRV
A/R Flags IF Name Type Class Rdata
Add 40000003 1 foobar._p2p._udp.local. SRV IN 0 0 3456 <something-here>
# additional records
$ dns-sd -Q foobar._p2p._udp.local. TXT
A/R Flags IF Name Type Class Rdata
Add 40000003 11 foobar._p2p._udp.local. TXT IN 9 bytes: <some bytes here>
Actual behavior
Looking at the chat example, I would expect to how the mDNS implementation responds to the dns-sd tool.
Of course at first nothing appears when we are not running the service:
# see a p2p related service
dns-sd -Q _services._dns-sd._udp.local PTR | grep p2p
# or directly query the service name:
dns-sd -Q _p2p._udp.local. PTR
Then I do cargo run within the chat example, and we can immediately see some results:
$ dns-sd -Q _services._dns-sd._udp.local PTR | grep p2p
Add 2 12 _services._dns-sd._udp.local. PTR IN _p2p._udp.local.
$ dns-sd -Q _p2p._udp.local. PTR
A/R Flags IF Name Type Class Rdata
Add 40000003 12 _p2p._udp.local. PTR IN PJ2Adr3Zp8KKry1ftPa0wckURooHtuaQq9abVx2ZjL.
Add 40000003 12 _p2p._udp.local. PTR IN BtLsbrMhFqOLJxqb4IH91BWuy4PmXIHkJDWZr8VE.
Add 40000003 12 _p2p._udp.local. PTR IN evwca28w1FbzKvilNd3entoeSD2OYf0XZZfC.
Add 40000003 12 _p2p._udp.local. PTR IN akG3qYT6xxTfmEIl8c0akPhB7HeaUb4l86CuW.
Add 40000003 12 _p2p._udp.local. PTR IN hsEIRIw3O9gwZSUAvtoFIG5nVTxHyWpR.
Add 40000002 12 _p2p._udp.local. PTR IN Ip5EpyxGobOBKCgTItmJAK0mRgEoNyNXV.
Add 3 12 _p2p._udp.local. PTR IN 4AEDDykQHCi7lnaZAlhRtOZ2PElE9PENgEouK4HiMRubEhXJK0bMObeGYHr.
Add 2 12 _p2p._udp.local. PTR IN b8Kl6NpZR7HLZqbgYVqHKAV6u2Xwso8Z52fmdmxmXhlzmacyQE.
At this point, I couldn't see how I could query the SRV and TXT records as is expected in the standard. Normally we should be able to query those records, like:
dns-sd -Q 4AEDDykQHCi7lnaZAlhRtOZ2PElE9PENgEouK4HiMRubEhXJK0bMObeGYHr. SRV
dns-sd -Q 4AEDDykQHCi7lnaZAlhRtOZ2PElE9PENgEouK4HiMRubEhXJK0bMObeGYHr. TXT
but these do not return any response.
When we look at the libp2p mdns spec we also see that we should be able to query with <peer-id>.<service>, but I wasn't able to get any response with that as well.
It also does not respond to dns-sd -B _p2p._udp. with an instance name.
Relevant log output
Possible Solution
Not a solution for this library maybe, but I would love to have info one how one can perhaps integrate the mentioned mdns-sd crate as a Behaviour for libp2p.
Version
0.55.0
Would you like to work on fixing this bug?
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 the chat example and the libp2p-mdns implementation referenced by the report, then compare its responses with the linked libp2p mDNS specification. Reproduce the dns-sd PTR, SRV, TXT, and browsing queries against the example. Done means the expected query behavior is implemented or the compatibility limitation and integration guidance are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100