generated from MatrixAI/TypeScript-Demo-Lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
developmentStandard developmentStandard development
Description
Specification
Migrate the existing embedded MDNS functionality in js-mdns to use the lightweight, portable C library mjansson/mdns via Rust FFI bindings. Implement a hybrid discovery model:
- Prefer OS-native MDNS stacks (Avahi on Linux, Bonjour on macOS, etc.) when available.
- Fallback to embedded
mjansson/mdnswhen OS-native stacks are unavailable (e.g., Docker containers, minimal OS environments).
The MDNS class must:
- Manage all multicast group lifecycle state explicitly when using the embedded library.
- Remain stateless when delegating to OS-native stacks (rely on their managed state).
- Support cross-platform multicast discovery (IPv4/IPv6) on Linux, macOS, and Windows.
Additional Context
- Current
js-mdnsuses custom JavaScript logic for multicast handling, which lacks IGMP optimizations and cross-platform reliability. - Docker/container use-case: OS-native stacks (Avahi) are often unavailable, necessitating an embedded solution.
- Hybrid design ensures broad compatibility.
- The
mjansson/mdnslibrary is:- Stateless at the library level (application manages sockets/groups).
- Portable across Linux/macOS/Windows.
- MIT-licensed and dependency-free.
- Native Windows mDNS Stack Support (Windows.Networking.ServiceDiscovery.Dnssd) #3
- Native Linux mDNS Stack Support (Avahi and systemd-resolved) #2
- Native macOS/iOS mDNS stack support (NWListener) #4
- Rely on OS-native MDNS stack when possible #8
Tasks
-
Create Rust FFI bindings for
mjansson/mdns: -
Integrate Rust module with Node.js:
- Use
napi-rsor similar to expose functionality via Node.js N-API. - Design JS API mirroring current
js-mdnsinterface for backward compatibility.
- Use
-
Implement OS-native stack detection:
- Linux: Check for Avahi DBus service (
dbus-sendor socket presence). - macOS: Verify Bonjour/mDNSResponder availability via
dns-sdCLI or headers. - Windows: Validate Bonjour SDK installation/registry entries.
- Return detection status to JS layer.
- Linux: Check for Avahi DBus service (
-
Implement hybrid mode:
- If OS-native stack detected:
- Delegate advertisement/discovery to native APIs (Avahi/Bonjour bindings).
- Else:
- Use embedded
mjansson/mdnsvia Rust bindings. - Explicitly manage multicast group joins/leaves per interface.
- Handle TXT record serialization/parsing in Rust.
- Use embedded
- If OS-native stack detected:
-
State management for embedded mode:
- MDNS class to track:
- Active multicast sockets per interface.
- Service advertisement TTLs.
- Discovery query intervals.
- Ensure resource cleanup (socket closure, group leaves) on shutdown.
- MDNS class to track:
-
Testing & CI/CD:
- Add cross-platform tests for hybrid mode:
- Native stack available (Linux host).
- Embedded fallback (Docker bridge network).
- Verify Windows firewall allows multicast traffic during tests.
- Build ARM binaries for container/embedded use.
- Add cross-platform tests for hybrid mode:
-
Documentation:
- Update README with hybrid mode explanation.
- Add troubleshooting guide for multicast firewall rules.
- Note Docker-specific considerations (e.g.,
--network hostvs. bridge).
Metadata
Metadata
Assignees
Labels
developmentStandard developmentStandard development