Skip to content

Commit 840c591

Browse files
committed
Use if-watch instead of local_ip_address
1 parent f584521 commit 840c591

File tree

3 files changed

+16
-62
lines changed

3 files changed

+16
-62
lines changed

Cargo.lock

Lines changed: 10 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/lighthouse_network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ fnv = { workspace = true }
2626
futures = { workspace = true }
2727
gossipsub = { workspace = true }
2828
hex = { workspace = true }
29+
if-watch = "3.2.1"
2930
itertools = { workspace = true }
3031
libp2p-mplex = "0.43"
3132
lighthouse_version = { workspace = true }
32-
local-ip-address = "0.6"
3333
logging = { workspace = true }
3434
lru = { workspace = true }
3535
lru_cache = { workspace = true }

beacon_node/lighthouse_network/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::{Enr, PeerIdSerialized};
55
use directory::{
66
DEFAULT_BEACON_NODE_DIR, DEFAULT_HARDCODED_NETWORK, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR,
77
};
8+
use if_watch::{IpNet, tokio::IfWatcher};
89
use libp2p::Multiaddr;
9-
use local_ip_address::local_ipv6;
1010
use network_utils::listen_addr::{ListenAddr, ListenAddress};
1111
use serde::{Deserialize, Serialize};
1212
use sha2::{Digest, Sha256};
@@ -262,13 +262,13 @@ impl Config {
262262
/// A helper function to check if the local host has a globally routeable IPv6 address. If so,
263263
/// returns true.
264264
pub fn is_ipv6_supported() -> bool {
265-
// If IPv6 is supported
266-
let Ok(std::net::IpAddr::V6(local_ip)) = local_ipv6() else {
265+
let Ok(watcher) = IfWatcher::new() else {
267266
return false;
268267
};
269268

270-
// If its globally routable, return true
271-
is_global_ipv6(&local_ip)
269+
watcher
270+
.iter()
271+
.any(|addr| matches!(addr, IpNet::V6(ip) if is_global_ipv6(&ip.addr())))
272272
}
273273

274274
pub fn listen_addrs(&self) -> &ListenAddress {

0 commit comments

Comments
 (0)