From 7221ac5e88ded08b9da1ba970d13e5053b0bdda1 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 14 Jan 2025 12:32:51 +0100 Subject: [PATCH] windows: don't discover default IP, removes winpcap dependency --- src/rpc/system.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/rpc/system.rs b/src/rpc/system.rs index df0e785b..ca07d3d4 100644 --- a/src/rpc/system.rs +++ b/src/rpc/system.rs @@ -863,17 +863,27 @@ impl NodeStatus { /// Obtain the list of currently available IP addresses on all non-loopback /// interfaces, optionally filtering them to be inside a given IpNet. fn get_default_ip(filter_ipnet: Option) -> Option { + // pnet creates a dependency on winpcap, which is a giant pain to get working with + // cross-compilation. + #[cfg(windows)] + { + None + } + + #[cfg(not(windows))] + { pnet_datalink::interfaces() - .into_iter() - // filter down and loopback interfaces - .filter(|i| i.is_up() && !i.is_loopback()) - // get all IPs - .flat_map(|e| e.ips) - // optionally, filter to be inside filter_ipnet - .find(|ipn| { - filter_ipnet.is_some_and(|ipnet| ipnet.contains(&ipn.ip())) || filter_ipnet.is_none() - }) - .map(|ipn| ipn.ip()) + .into_iter() + // filter down and loopback interfaces + .filter(|i| i.is_up() && !i.is_loopback()) + // get all IPs + .flat_map(|e| e.ips) + // optionally, filter to be inside filter_ipnet + .find(|ipn| { + filter_ipnet.is_some_and(|ipnet| ipnet.contains(&ipn.ip())) || filter_ipnet.is_none() + }) + .map(|ipn| ipn.ip()) + } } fn get_rpc_public_addr(config: &Config) -> Option {