mirror of
https://github.com/domcyrus/rustnet.git
synced 2026-04-30 00:40:22 -05:00
fix: Correctly handle pnet_datalink::interfaces() return type
This commit is contained in:
+5
-11
@@ -217,19 +217,13 @@ impl NetworkMonitor {
|
||||
|
||||
// Get all local IP addresses
|
||||
let mut local_ips = std::collections::HashSet::new();
|
||||
match pnet_datalink::interfaces() {
|
||||
Ok(interfaces) => {
|
||||
for iface in interfaces {
|
||||
for ip_network in iface.ips {
|
||||
local_ips.insert(ip_network.ip());
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to get network interfaces: {}", e);
|
||||
// Continue without local IP knowledge, is_outgoing heuristic will be less reliable
|
||||
let interfaces = pnet_datalink::interfaces();
|
||||
for iface in interfaces {
|
||||
for ip_network in iface.ips {
|
||||
local_ips.insert(ip_network.ip());
|
||||
}
|
||||
}
|
||||
|
||||
if local_ips.is_empty() {
|
||||
log::warn!("Could not determine any local IP addresses. Connection directionality might be inaccurate.");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user