mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Update discv5 to expand ipv6 support (#4319)
Done in different PRs so that they can reviewed independently, as it's likely this won't be merged before I leave Includes resolution for #4080 - [ ] #4299 - [ ] #4318 - [ ] #4320 Co-authored-by: Diva M <divma@protonmail.com> Co-authored-by: Age Manning <Age@AgeManning.com>
This commit is contained in:
@@ -163,7 +163,7 @@ impl Config {
|
||||
udp_port,
|
||||
tcp_port,
|
||||
});
|
||||
self.discv5_config.ip_mode = discv5::IpMode::Ip4;
|
||||
self.discv5_config.listen_config = discv5::ListenConfig::from_ip(addr.into(), udp_port);
|
||||
self.discv5_config.table_filter = |enr| enr.ip4().as_ref().map_or(false, is_global_ipv4)
|
||||
}
|
||||
|
||||
@@ -176,9 +176,8 @@ impl Config {
|
||||
udp_port,
|
||||
tcp_port,
|
||||
});
|
||||
self.discv5_config.ip_mode = discv5::IpMode::Ip6 {
|
||||
enable_mapped_addresses: false,
|
||||
};
|
||||
|
||||
self.discv5_config.listen_config = discv5::ListenConfig::from_ip(addr.into(), udp_port);
|
||||
self.discv5_config.table_filter = |enr| enr.ip6().as_ref().map_or(false, is_global_ipv6)
|
||||
}
|
||||
|
||||
@@ -206,10 +205,10 @@ impl Config {
|
||||
tcp_port: tcp6_port,
|
||||
},
|
||||
);
|
||||
self.discv5_config.listen_config = discv5::ListenConfig::default()
|
||||
.with_ipv4(v4_addr, udp4_port)
|
||||
.with_ipv6(v6_addr, udp6_port);
|
||||
|
||||
self.discv5_config.ip_mode = discv5::IpMode::Ip6 {
|
||||
enable_mapped_addresses: true,
|
||||
};
|
||||
self.discv5_config.table_filter = |enr| match (&enr.ip4(), &enr.ip6()) {
|
||||
(None, None) => false,
|
||||
(None, Some(ip6)) => is_global_ipv6(ip6),
|
||||
@@ -279,9 +278,17 @@ impl Default for Config {
|
||||
.build()
|
||||
.expect("The total rate limit has been specified"),
|
||||
);
|
||||
let listen_addresses = ListenAddress::V4(ListenAddr {
|
||||
addr: Ipv4Addr::UNSPECIFIED,
|
||||
udp_port: 9000,
|
||||
tcp_port: 9000,
|
||||
});
|
||||
|
||||
let discv5_listen_config =
|
||||
discv5::ListenConfig::from_ip(Ipv4Addr::UNSPECIFIED.into(), 9000);
|
||||
|
||||
// discv5 configuration
|
||||
let discv5_config = Discv5ConfigBuilder::new()
|
||||
let discv5_config = Discv5ConfigBuilder::new(discv5_listen_config)
|
||||
.enable_packet_filter()
|
||||
.session_cache_capacity(5000)
|
||||
.request_timeout(Duration::from_secs(1))
|
||||
@@ -304,12 +311,9 @@ impl Default for Config {
|
||||
// NOTE: Some of these get overridden by the corresponding CLI default values.
|
||||
Config {
|
||||
network_dir,
|
||||
listen_addresses: ListenAddress::V4(ListenAddr {
|
||||
addr: Ipv4Addr::UNSPECIFIED,
|
||||
udp_port: 9000,
|
||||
tcp_port: 9000,
|
||||
}),
|
||||
listen_addresses,
|
||||
enr_address: (None, None),
|
||||
|
||||
enr_udp4_port: None,
|
||||
enr_tcp4_port: None,
|
||||
enr_udp6_port: None,
|
||||
|
||||
Reference in New Issue
Block a user