Skip to content

Conversation

@lidel
Copy link
Member

@lidel lidel commented Dec 1, 2025

This PR filters mDNS advertised addresses to help stay within 1500-byte MTU:

  • Skip browser transports (WebTransport, WebRTC, WebSocket)
  • Skip circuit relay addresses
  • Skip non-.local DNS names (require unicast DNS)
  • Allow IP addresses and .local DNS names (RFC 6762)

This PR aims to help IPFS (Kubo) users with local discovery problems on Windows and macOS, as noted in #3415

Filter mDNS advertised addresses to help stay within 1500-byte MTU:

- Skip browser transports (WebTransport, WebRTC, WebSocket)
- Skip circuit relay addresses
- Skip non-.local DNS names (require unicast DNS)
- Allow IP addresses and .local DNS names (RFC 6762)

Fixes: #3415
@lidel lidel marked this pull request as ready for review December 1, 2025 19:45
@lidel lidel requested review from MarcoPolo and sukunrt December 1, 2025 19:45
switch first.Protocol().Code {
case ma.P_IP4, ma.P_IP6:
// Direct IP addresses are always suitable for LAN discovery
case ma.P_DNS, ma.P_DNS4, ma.P_DNS6, ma.P_DNSADDR:
Copy link
Collaborator

@MarcoPolo MarcoPolo Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does DNSADDR make sense here?

Copy link
Member Author

@lidel lidel Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it mostly for completeness, but yes, technically someone could have TXT record on _dnsaddr.foo.local and use it for signaling peerid similar to how one can ipfs swarm connect /dnsaddr/bootstrap.libp2p.io without knowing peerid upfront (or connecting to more than one peer)

// WebRTC, WebSocket) because these are not useful for direct LAN discovery.
//
// Filtering reduces mDNS packet size, helping stay within the 1500-byte MTU
// limit per RFC 6762. See: https://github.com/libp2p/go-libp2p/issues/3415
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A slight correction in this comment. The RFC states the packet "MUST NOT exceed 9000 bytes". Below 1500 bytes is recommended.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1aabf13

per review feedback: RFC 6762 states packets MUST NOT exceed 9000 bytes,
with 1500 bytes being recommended
Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

@MarcoPolo MarcoPolo merged commit cf61065 into master Dec 2, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants