Replies: 2 comments 1 reply
-
mDNS Discovery Implementation Progress Update🚀 Current StatusHey @seetadev I've been working on implementing mDNS-based peer discovery for py-libp2p as outlined in issue #633. Here's the current status of my implementation: ✅ What's Working:
🔧 Current Implementation Structure:Following the proposed module structure from the discussion:
🤔 Where I Need Guidance - Event System:This is where I could use some input . Currently, I have the discovery logic working, but I'm looking for guidance on the best practices for emitting events with peer info as payload. Specific questions: Event System Architecture:
🧪 Testing Status:Still needed:
This feature is very close to completion - just need to nail down the event system design! 🚀 Looking forward to your feedback and guidance on the event system implementation! |
Beta Was this translation helpful? Give feedback.
-
@seetadev The Multicast DNS is ready for review. Developer documentation: https://drive.google.com/file/d/104byHM3iOi9AeDeK_W0Jb1BIOXo6bvNF/view?usp=drive_link |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This proposal outlines how we can introduce Multicast DNS (mDNS)-based peer discovery into
py-libp2p
, aligned with the behavior ofgo-libp2p
andjs-libp2p
.Module Structure & Responsibilities
We propose creating a dedicated module,
libp2p.discovery.mdns
, with the following internal components:Each component would manage distinct responsibilities:
Broadcaster
_p2p._udp.local
service name.Example:
id=QmPeerID123...
Listener
224.0.0.251:5353
for mDNS responses.PeerInfo
for peers discovered on the same LAN.Integration Layer
Swarm
orHost
to trigger connection attempts when peers are discovered.🛠️ How it Works (Expected Flow)
On startup, if
mdns
is enabled:mdns_broadcaster
advertises the peer using Zeroconf (or equivalent).mdns_listener
listens for peer advertisements.When a peer is found:
PeerInfo
object is emitted.Swarm
auto-dials the discovered peer or adds it to its peerstore.Dependency Suggestion:
[zeroconf](https://github.com/jstasiak/python-zeroconf)
Python LibraryWe suggest using
zeroconf
, a well-supported Python library with support for:The library is used in projects like Home Assistant, which shows it handles real-world, high-performance discovery.
Configuration Options
Add a new config object or flags to enable/disable mDNS:
Advanced options could include:
Testing Plan
Unit Tests
Integration Tests
We can leverage
pytest
fixtures to spin up hosts in subprocesses on local ports.Example Usage (Preview)
🔍 Open Questions for Discussion
Where should peer discovery events be surfaced?
Host
expose a listener pattern or use async callbacks?How do we ensure safety and scoping?
Do we want to align broadcast intervals with go/js defaults?
Should we emit events even if the peer is already known (i.e., for heartbeats)?
Why This Is a Good Fit for
py-libp2p
Beta Was this translation helpful? Give feedback.
All reactions