MCPcopy Index your code
hub / github.com/dylanmckay/mdns

github.com/dylanmckay/mdns @3.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.0.0 ↗ · + Follow
35 symbols 62 edges 10 files 7 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

mdns

Build Status crates.io MIT license

Documentation

An multicast DNS client in Rust.

Error logging is handled with the log library.

Wikipedia

Example

Find IP addresses for all Chromecasts on the local network.

use futures_util::{pin_mut, stream::StreamExt};
use mdns::{Error, Record, RecordKind};
use std::{net::IpAddr, time::Duration};


const SERVICE_NAME: &'static str = "_googlecast._tcp.local";

#[async_std::main]
async fn main() -> Result<(), Error> {
    // Iterate through responses from each Cast device, asking for new devices every 15s
    let stream = mdns::discover::all(SERVICE_NAME, Duration::from_secs(15))?.listen();
    pin_mut!(stream);

    while let Some(Ok(response)) = stream.next().await {
        let addr = response.records()
                           .filter_map(self::to_ip_addr)
                           .next();

        if let Some(addr) = addr {
            println!("found cast device at {}", addr);
        } else {
            println!("cast device does not advertise address");
        }
    }

    Ok(())
}

fn to_ip_addr(record: &Record) -> Option<IpAddr> {
    match record.kind {
        RecordKind::A(addr) => Some(addr.into()),
        RecordKind::AAAA(addr) => Some(addr.into()),
        _ => None,
    }
}

Core symbols most depended-on inside this repo

listen
called by 4
src/mdns.rs
all
called by 4
src/discover.rs
records
called by 4
src/response.rs
hostname
called by 4
src/response.rs
ip_addr
called by 3
src/response.rs
mdns_interface
called by 1
src/mdns.rs
create_socket
called by 1
src/mdns.rs
send_request
called by 1
src/mdns.rs

Shape

Method 17
Function 9
Class 6
Enum 3

Languages

Rust100%

Modules by API surface

src/response.rs13 symbols
src/mdns.rs6 symbols
src/discover.rs6 symbols
src/io.rs4 symbols
src/resolve.rs2 symbols
src/errors.rs1 symbols
examples/resolve_hosts.rs1 symbols
examples/http_discovery.rs1 symbols
examples/chromecast_discovery.rs1 symbols

For agents

$ claude mcp add mdns \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page