mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
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:
98
Cargo.lock
generated
98
Cargo.lock
generated
@@ -2552,37 +2552,6 @@ dependencies = [
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947"
|
||||
dependencies = [
|
||||
"derive_builder_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_core"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
|
||||
dependencies = [
|
||||
"darling 0.20.11",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_macro"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
|
||||
dependencies = [
|
||||
"derive_builder_core",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.99.20"
|
||||
@@ -3810,18 +3779,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getset"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cf0fc11e47561d47397154977bc219f4cf809b2974facc3ccb3b89e2436f912"
|
||||
dependencies = [
|
||||
"proc-macro-error2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ghash"
|
||||
version = "0.5.1"
|
||||
@@ -4552,6 +4509,16 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "if-addrs"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf39cc0423ee66021dc5eccface85580e4a001e0c5288bae8bea7ecb69225e90"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "if-watch"
|
||||
version = "3.2.1"
|
||||
@@ -4562,7 +4529,7 @@ dependencies = [
|
||||
"core-foundation 0.9.4",
|
||||
"fnv",
|
||||
"futures",
|
||||
"if-addrs",
|
||||
"if-addrs 0.10.2",
|
||||
"ipnet",
|
||||
"log",
|
||||
"netlink-packet-core",
|
||||
@@ -5453,11 +5420,11 @@ dependencies = [
|
||||
"fnv",
|
||||
"futures",
|
||||
"hex",
|
||||
"if-addrs 0.14.0",
|
||||
"itertools 0.10.5",
|
||||
"libp2p",
|
||||
"libp2p-mplex",
|
||||
"lighthouse_version",
|
||||
"local-ip-address",
|
||||
"logging",
|
||||
"lru 0.12.5",
|
||||
"lru_cache",
|
||||
@@ -5559,18 +5526,6 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "local-ip-address"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a60bf300a990b2d1ebdde4228e873e8e4da40d834adbf5265f3da1457ede652"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"neli",
|
||||
"thiserror 2.0.17",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.14"
|
||||
@@ -6048,35 +6003,6 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "neli"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e23bebbf3e157c402c4d5ee113233e5e0610cc27453b2f07eefce649c7365dcc"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"byteorder",
|
||||
"derive_builder",
|
||||
"getset",
|
||||
"libc",
|
||||
"log",
|
||||
"neli-proc-macros",
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "neli-proc-macros"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05d8d08c6e98f20a62417478ebf7be8e1425ec9acecc6f63e22da633f6b71609"
|
||||
dependencies = [
|
||||
"either",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "netlink-packet-core"
|
||||
version = "0.7.0"
|
||||
|
||||
@@ -22,11 +22,11 @@ fixed_bytes = { workspace = true }
|
||||
fnv = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
if-addrs = "0.14"
|
||||
itertools = { workspace = true }
|
||||
libp2p = { workspace = true }
|
||||
libp2p-mplex = { git = "https://github.com/libp2p/rust-libp2p.git" }
|
||||
lighthouse_version = { workspace = true }
|
||||
local-ip-address = "0.6"
|
||||
logging = { workspace = true }
|
||||
lru = { workspace = true }
|
||||
lru_cache = { workspace = true }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user