Development #8
@@ -1,3 +1,8 @@
|
||||
## [unreleased]
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- Status Colors on Monitor tab now reflect status of host. Closes #7
|
||||
## [0.2.0] - 2026-09-24
|
||||
|
||||
### 🚀 Features
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::net::IpAddr;
|
||||
use tokio::task::JoinSet;
|
||||
|
||||
/// Perform reverse DNS lookup on a single IP.
|
||||
/// Returns the hostname if found, None otherwise.
|
||||
@@ -18,33 +17,4 @@ pub async fn reverse_lookup(ip: IpAddr) -> Option<String> {
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform reverse DNS lookups on a batch of IPs concurrently.
|
||||
/// Returns a Vec of (IpAddr, Option<hostname>) pairs.
|
||||
pub async fn reverse_lookup_batch(
|
||||
ips: &[IpAddr],
|
||||
max_concurrent: usize,
|
||||
) -> Vec<(IpAddr, Option<String>)> {
|
||||
let mut results = Vec::with_capacity(ips.len());
|
||||
|
||||
for chunk in ips.chunks(max_concurrent) {
|
||||
let mut join_set = JoinSet::new();
|
||||
|
||||
for &ip in chunk {
|
||||
join_set.spawn(async move {
|
||||
let hostname = reverse_lookup(ip).await;
|
||||
(ip, hostname)
|
||||
});
|
||||
}
|
||||
|
||||
while let Some(result) = join_set.join_next().await {
|
||||
match result {
|
||||
Ok(pair) => results.push(pair),
|
||||
Err(e) => tracing::warn!("DNS lookup task panicked: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results
|
||||
}
|
||||
Reference in New Issue
Block a user