nscd-lookup

Crates.ionscd-lookup
lib.rsnscd-lookup
version0.1.5
created_at2025-02-28 19:28:55.339888+00
updated_at2025-03-10 12:27:25.087162+00
descriptionLook up IP addresses using nscd
homepage
repositoryhttps://github.com/Kijewski/nscd-lookup
max_upload_size
id1573089
size74,222
René Kijewski (Kijewski)

documentation

README

nscd-lookup – look up IP addresses using nscd

GitHub Workflow Status Crates.io docs.rs

Explicitly querying nscd might come in handy if your program runs in a container or jail without direct internet access, but you still need to look up a domain name for some reason.

use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

use nscd_lookup::sync::lookup;

let localhost: Vec<IpAddr> = lookup("localhost", &mut Vec::new(), None)
    .expect("should be able to look up addresses")
    .expect("address list should not be empty")
    .collect();
assert!(localhost.contains(&IpAddr::V4(Ipv4Addr::LOCALHOST)));
assert!(localhost.contains(&IpAddr::V6(Ipv6Addr::LOCALHOST)));

Or with the feature "tokio":

use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

use nscd_lookup::tokio::lookup;

let localhost: Vec<IpAddr> = lookup("localhost", &mut Vec::new(), None)
    .await
    .expect("should be able to look up addresses")
    .expect("address list should not be empty")
    .collect();
assert!(localhost.contains(&IpAddr::V4(Ipv4Addr::LOCALHOST)));
assert!(localhost.contains(&IpAddr::V6(Ipv6Addr::LOCALHOST)));

The feature "reqwest" enables a resolver that can be used in reqwest clients.

Commit count: 8

cargo fmt