20 lines
504 B
Rust
20 lines
504 B
Rust
use std::net::IpAddr;
|
|
|
|
/// Perform reverse DNS lookup on a single IP.
|
|
/// Returns the hostname if found, None otherwise.
|
|
pub async fn reverse_lookup(ip: IpAddr) -> Option<String> {
|
|
let result = tokio::task::spawn_blocking(move || {
|
|
dns_lookup::lookup_addr(&ip)
|
|
}).await;
|
|
|
|
match result {
|
|
Ok(Ok(hostname)) => {
|
|
if hostname == ip.to_string() {
|
|
None
|
|
} else {
|
|
Some(hostname)
|
|
}
|
|
}
|
|
_ => None,
|
|
}
|
|
} |