rtci-mdns
Sans-I/O mDNS (RFC 6762) querier and responder, as used for WebRTC mDNS ICE candidates. 1 public module, 13 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
Multicast DNS for WebRTC: a querier that resolves .local names (the mDNS host candidates browsers send) and a responder that publishes local names, with probing, announcing, answering, defending a name and goodbyes, a cache bounded by TTL, and one rate limit over everything sent.
Specifications
- RFC 6762, Multicast DNS
- draft-ietf-mmusic-mdns-ice-candidates, mDNS names for ICE host candidates
Clause-by-clause status, with the test that proves each clause: rfc6762, draft-ietf-mmusic-mdns-ice-candidates.
Use
Mdns::new(now, MdnsConfig) creates the state machine; query_now starts a query and poll_event reports the answer (MdnsEvent). MulticastSocket builds a UDP socket joined to the mDNS group for applications that want one. The root crate (rtci) uses it for mDNS candidates. The crate documentation has query and responder examples.
MulticastSocket::with_interface joins and sends on that interface (IP_MULTICAST_IF, RFC 6762 section 14). Without one the socket joins on INADDR_ANY and sends by the system's route for 224.0.0.251, except on Windows, where it joins and sends on the default route's interface: there the group's route comes from a destination cache that any process which sent to the group from 127.0.0.1 leaves on loopback for the whole host. A Windows host whose mDNS link is not the default route's should pass the interface.
Sans-I/O
The protocol is a sansio::Protocol: datagrams in through handle_read, out through poll_write, deadlines through poll_timeout / handle_timeout. Only MulticastSocket, an optional helper, touches the operating system. The crate does no I/O and reads no clock: every call that depends on time takes an Instant from the caller.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_mdns
A sans-I/O implementation of mDNS (Multicast DNS) for Rust.
- struct
Mdnsfromproto::MdnsSans-I/O mDNS Connection. - struct
MdnsConfigfromconfig::MdnsConfigMdnsConfiguration for an mDNS connection. - struct
MulticastSocketfromsocket::MulticastSocketA builder for creating multicast UDP sockets suitable for mDNS. - enum
MdnsEventfromproto::MdnsEventEvents emitted by the mDNS connection. - enum
MdnsProbePolicyfromconfig::MdnsProbePolicyWhether a name is probed for (RFC 6762 section 8.1) before it is announced and answered. - type
QueryIdfromproto::QueryIdUnique identifier for tracking mDNS queries. - const
MAX_CACHED_ADDRESSESfromproto::MAX_CACHED_ADDRESSESThe most addresses the resolver's cache holds. Any host on the link can offer records, so the cache is bounded: when it is full, the entry nearest its expiry gives way to one that lives longer. - const
MAX_LOCAL_NAMESfromproto::MAX_LOCAL_NAMESThe most namesMdns::add_local_nameregisters: one per local address is the use, and a host has a handful. - const
MDNS_DEST_ADDRfromproto::MDNS_DEST_ADDRmDNS multicast destination address (224.0.0.251:5353). - const
MDNS_MULTICAST_IPV4fromproto::MDNS_MULTICAST_IPV4The mDNS multicast group address (224.0.0.251). - const
MDNS_PORTfromproto::MDNS_PORTThe standard mDNS port (5353). - use
ifacesfromshared::ifaces - use
MdnsRateLimitfromproto::MdnsRateLimitA limit on the mDNS messages sent, as a token bucket:burstmessages may leave back to back, after whichper_secondleave each second.
Generated from the sources of rtci-mdns 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.