https://github.com/kijewski/nscd-lookup
Look up IP addresses using nscd
https://github.com/kijewski/nscd-lookup
Last synced: 4 months ago
JSON representation
Look up IP addresses using nscd
- Host: GitHub
- URL: https://github.com/kijewski/nscd-lookup
- Owner: Kijewski
- License: apache-2.0
- Created: 2025-02-27T18:19:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-10T12:27:11.000Z (about 1 year ago)
- Last Synced: 2025-10-08T13:47:35.028Z (8 months ago)
- Language: Rust
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# nscd-lookup – look up IP addresses using nscd
[](https://github.com/Kijewski/nscd-lookup/actions/workflows/ci.yml)
[](https://crates.io/crates/nscd-lookup)
[](https://docs.rs/nscd-lookup/)
Explicitly querying [`nscd`](https://man7.org/linux/man-pages/man8/nscd.8.html) 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.
```rust,ignore
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use nscd_lookup::sync::lookup;
let localhost: Vec = 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"`:
```rust,ignore
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use nscd_lookup::tokio::lookup;
let localhost: Vec = 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.