Skip to content
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

mDNS peer discovery stops working once a certain threshold is reached #2012

Closed
achingbrain opened this issue Aug 31, 2023 · 0 comments · Fixed by #2014
Closed

mDNS peer discovery stops working once a certain threshold is reached #2012

achingbrain opened this issue Aug 31, 2023 · 0 comments · Fixed by #2014
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization

Comments

@achingbrain
Copy link
Member

achingbrain commented Aug 31, 2023

mDNS peer discovery works by making a broadcast query for _p2p._udp.local services. Peers respond with their multiaddrs.

The number of multiaddrs a peer has affects the size of the UDP message being sent as the mDNS response.

Once this message hits a certain size the multicast-dns module fails to decode the message. The message size this occurs at is well under the maximum size for a mDNS response message - turns out there's a hard length limit for mDNS TXT answers and certain addresses such as circuit relay over WebTransport can exceed this limit and cause parsing failures.

Refs: mafintosh/multicast-dns#85

@achingbrain achingbrain added need/triage Needs initial labeling and prioritization kind/bug A bug in existing code (including security flaws) and removed need/triage Needs initial labeling and prioritization labels Aug 31, 2023
achingbrain added a commit that referenced this issue Sep 1, 2023
The data field of mDNS TXT records has a [hard limit of 255 characters](https://agnat.github.io/node_mdns/user_guide.html#txt_records) - some multiaddrs can be longer than this so filter them out before sending, otherwise remote peers can fail to parse our mDNS response.

We should also only be sending [link-local addresses](https://github.com/libp2p/specs/blob/master/discovery/mdns.md#issues) in mDNS responses so filter any non-link-local addresses out too, though go-libp2p includes loopback addresses even though it probably shouldn't (according to the mDNS spec which conflicts with our mDNS Peer Discovery spec) so we continue to do so as well.

Fixes #2012
This was referenced Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization
Projects
None yet
1 participant