mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
enforce non zero enr ports (#4776)
## Issue Addressed Right now lighthouse accepts zero as enr ports. Since enr ports should be reachable, zero ports should be rejected here ## Proposed Changes - update the config to use `NonZerou16` as an ENR port for all enr-related fields. - the enr builder from config now sets the enr to the listening port only if the enr port is not already set (prev behaviour) and the listening port is not zero (new behaviour) - reject zero listening ports when used with `enr-match`. - boot node now rejects listening port as zero, since those are advertised. - generate-bootnode-enr also rejected zero listening ports for the same reason. - update local network scripts ## Additional Info Unrelated, but why do we overwrite `enr-x-port` values with listening ports if `enr-match` is present? we prob should only do this for enr values that are not already set.
This commit is contained in:
@@ -11,6 +11,7 @@ use libp2p::Multiaddr;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::num::NonZeroU16;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -64,22 +65,22 @@ pub struct Config {
|
||||
pub enr_address: (Option<Ipv4Addr>, Option<Ipv6Addr>),
|
||||
|
||||
/// The udp ipv4 port to broadcast to peers in order to reach back for discovery.
|
||||
pub enr_udp4_port: Option<u16>,
|
||||
pub enr_udp4_port: Option<NonZeroU16>,
|
||||
|
||||
/// The quic ipv4 port to broadcast to peers in order to reach back for libp2p services.
|
||||
pub enr_quic4_port: Option<u16>,
|
||||
pub enr_quic4_port: Option<NonZeroU16>,
|
||||
|
||||
/// The tcp ipv4 port to broadcast to peers in order to reach back for libp2p services.
|
||||
pub enr_tcp4_port: Option<u16>,
|
||||
pub enr_tcp4_port: Option<NonZeroU16>,
|
||||
|
||||
/// The udp ipv6 port to broadcast to peers in order to reach back for discovery.
|
||||
pub enr_udp6_port: Option<u16>,
|
||||
pub enr_udp6_port: Option<NonZeroU16>,
|
||||
|
||||
/// The tcp ipv6 port to broadcast to peers in order to reach back for libp2p services.
|
||||
pub enr_tcp6_port: Option<u16>,
|
||||
pub enr_tcp6_port: Option<NonZeroU16>,
|
||||
|
||||
/// The quic ipv6 port to broadcast to peers in order to reach back for libp2p services.
|
||||
pub enr_quic6_port: Option<u16>,
|
||||
pub enr_quic6_port: Option<NonZeroU16>,
|
||||
|
||||
/// Target number of connected peers.
|
||||
pub target_peers: usize,
|
||||
|
||||
Reference in New Issue
Block a user