Use if-addrs instead of local_ip_address (#8659)

Swaps out the `local_ip_address` dependency for `if-addrs`. The reason for this is that is that `local_ip_address` is a relatively heavy dependency (depends on `neli`) compared to `if-addrs` and we only use it to check the presence of an IPv6 interface. This is an experiment to see if we can use the more lightweight `if-addrs` instead.


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2026-02-06 19:40:09 +04:00
committed by GitHub
parent bb133d510d
commit e4bc650097
3 changed files with 18 additions and 92 deletions

View File

@@ -5,8 +5,8 @@ use crate::{Enr, PeerIdSerialized};
use directory::{
DEFAULT_BEACON_NODE_DIR, DEFAULT_HARDCODED_NETWORK, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR,
};
use if_addrs::get_if_addrs;
use libp2p::{Multiaddr, gossipsub};
use local_ip_address::local_ipv6;
use network_utils::listen_addr::{ListenAddr, ListenAddress};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
@@ -262,13 +262,13 @@ impl Config {
/// A helper function to check if the local host has a globally routeable IPv6 address. If so,
/// returns true.
pub fn is_ipv6_supported() -> bool {
// If IPv6 is supported
let Ok(std::net::IpAddr::V6(local_ip)) = local_ipv6() else {
let Ok(addrs) = get_if_addrs() else {
return false;
};
// If its globally routable, return true
is_global_ipv6(&local_ip)
addrs.iter().any(
|iface| matches!(iface.addr, if_addrs::IfAddr::V6(ref v6) if is_global_ipv6(&v6.ip)),
)
}
pub fn listen_addrs(&self) -> &ListenAddress {