dylanmckay / mdns Goto Github PK
View Code? Open in Web Editor NEWA multicast DNS client in Rust
License: MIT License
A multicast DNS client in Rust
License: MIT License
See for example this NVidia shield listed by avahi:
$ avahi-browse _nv_shield_remote._tcp --resolve
+ enp0s25 IPv6 SHIELD _nv_shield_remote._tcp local
+ enp0s25 IPv4 SHIELD _nv_shield_remote._tcp local
= enp0s25 IPv4 SHIELD _nv_shield_remote._tcp local
hostname = [Android.local]
address = [192.168.1.58]
port = [8987]
txt = ["SERVER=aac0f0d6fbb59b5c"]
= enp0s25 IPv6 SHIELD _nv_shield_remote._tcp local
hostname = [Android.local]
address = [192.168.1.58]
port = [8987]
txt = ["SERVER=aac0f0d6fbb59b5c"]
But running the chromecast_discovery
example with _nv_shield_remote._tcp.local
as SERVICE_NAME
doesn't list those services.
For some reason, the IPv4 is also removed from avahi-browse
while the example is running:
- enp0s25 IPv4 SHIELD _nv_shield_remote._tcp local
I think it would be awesome if there was an example showing how to call this crate from a main that does not use tokio::main, and to get one single result back and print it! :)
(I tried to use this crate to create a simple blocking function that I could call to look up things on the local network using mdns. I failed, because the example uses tokio::main and I failed to understand how to stop the stream so it just continued giving responses.)
The stream in the example keeps on returning the same IP address again and again and the while let loop never breaks, which means I cannot use any of the discovered devices as the loop is infinite.
I have copy/pasted the example and just changed the SERVICE_NAME to "_airplay._tcp.local" and it keeps printing the same Airplay devices agai and again. The example SERVICE_NAME "_googlecast._tcp.local" just hangs without output since I don't have any Chromecast devices on my network.
I tried on both Windows and Mac devices and the issue is same in both.
using the chromecast example but switching to compantion-link._tcp.local
, some names panic. Not sure what the best course of action is, to support UTF-8 maybe?
Maybe I am missing something, but how do I publish a new service? It seems that currently only the discovery is supported, right? If so, are there any plans to add the support for publishing the new services? (like the one can do with Bonjour / Avahi)
Hi is it possible to add support for retrieving TXT records and the hostname in the discovered services?
It would be helpful if README.md explained which features of mDNS this crate implements. mDNS documentation
If I am not mistaken, it performs queries in an approx-periodical way and gives a collection of responses - "One-Shot Multicast DNS Queries".
It's totally ok for many use cases, but it is not full mDNS implementation. But there are also other mDNS queries (Section 5)
Hello! I'm currently using mdns 2.0.2, as it's the last version that works with the tokio runtime, which I use in my app.
in a tokio app, mdns 3.x never streams anything, likely due to a runtime conflict. but 2.x works perfectly fine.
so i'm suggesting that both tokio and async-std be supported via features.
The only modification I made to the example code provided in the docs is the SERVICE_NAME to a known service on my network.
Running the program, it never returned any output.
I then commented out the "while loop" and added a single manual entry for the next item and a print statement right before and right after it. This second print statement is never reached.
It looks like "stream.next().await" never returns.
Title. Wireshark shows that the packets seem to be transmitting, but mdns
doesn't receive them?
If I wait a while (after inserting a dbg!
into mdns), it seems to detect everything but my target:
Here's my code:
async fn find_server() -> Result<Vec<Ipv4Addr>> {
let stream = mdns::discover::all("_name._tcp.local", Duration::from_secs(15))?
.ignore_empty(false)
.listen();
pin_mut!(stream);
let mut servers = Vec::new();
let _ = timeout(Duration::from_secs(20), async {
while let Some(Ok(response)) = stream.next().await {
// IT DOES NOT GET TO THIS POINT, stream hangs until timeout kicks in
let addr = response
.records()
.filter_map(|record| match record.kind {
RecordKind::A(addr) => Some(addr),
_ => None,
})
.next();
if let Some(addr) = addr {
println!("found cast device at {}");
servers.push(addr);
return;
}
}
})
.await;
println!("done");
Ok(servers)
}
The mDNS server is working - I can view it perfectly fine from a Bonjour viewer app on iOS.
Will be fixed once tailhook/dns-parser#19 lands.
Hi,
Thanks for your work.
I'm still learning Rust, so it's likely I'm just confused. But it seems like doing anything beyond modifying the service name that gets passed to discover::all() in the given example isn't going to work -- due to what has been exposed as public and what has not been exposed. For example, can a user of this crate set the timeout? I don't see a way to do that. Since Discovery is public but composed of fields that are not public, I don't think I can ever instantiate a Discovery to set the timeout; or any other way to set the timeout without modifying the crate. Is that right?
First of all, thanks for building this library! It does return what I need, but there is a slight issue.
When I run cargo run --example chromecast_discovery
, the discover::all
iterator keeps on producing responses endlessly.
Apr 17 23:58:48 found cast device at 192.168.1.140
Apr 17 23:58:49 found cast device at 192.168.1.140
Apr 17 23:58:49 found cast device at 192.168.1.140
Apr 17 23:58:50 found cast device at 192.168.1.140
Apr 17 23:58:50 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:52 found cast device at 192.168.1.140
Apr 17 23:58:52 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:55 found cast device at 192.168.1.140
Apr 17 23:58:55 found cast device at 192.168.1.140
Apr 17 23:58:56 found cast device at 192.168.1.140
Apr 17 23:58:56 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
^C
While the application is running, I notice degraded performance of my network, to the point where websites barely load. This also happens on different machines from the one running the application. I suspect the application is somehow saturating the network. I have a single Chromecast Audio in my network. I am running the application on Linux 4.15.15-1-ARCH
.
Running avahi-browse --terminate _googlecast._tcp
does return a single result before exiting and causes no network issues.
I can reproduce this problem consistently, and I would be happy to provide more information to help debug this issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.