Simple mDNS
Pure Rust implementation for mDNS and DNS-SD protocols
This crate provides two versions of service discovery, the sync version is located in the module sync_discovery and the async counterpart in async_discovery.
Features
It is necessary to enable at least one of the features to use service discovery
- sync: Provides
sync_discoverymodule - async-tokio: Provides
async_discoverymodule using tokio runtime
ServiceDiscovery
Advertise registered addresses and query for available instances on the same network.
It is necessary to provide instance and service name
#
OneShotMdnsResolver (Legacy mDNS)
One shot resolvers are considered legacy and not fully compliant with the mDNS protocol, but they are handy for service discovery if you have (or need) only one service instance
How it works
One shot resolvers or queries send a multicast DNS question to discover available services in the network.
- Only the IP address is necessary (port is fixed or already known), a A or AAAA question is sent.
- IP address and port are necessary, a SRV question is sent.
Since mDNS is a well known protocol, you can register your service in any mDNS responder inside your network, and they should be able to reply the requested information about your service.
Query example:
#
SimpleMdnsResponder
In case you don't have a mDNS responder in your network, or for some reason don't want to use the ones available.
This responder will list for any mDNS query in the network via Multicast and will reply only to the resources that were added.
This struct relies on simple-dns crate and the same must be added as a dependency
#
IPV6
IPV6 is now supported by using the NetworkScope enum.
# // This is test is marked as no_run because IPV6 is not available in github actions.
#
Note: It is not tested on MacOS.