mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Merge unstable 20230925 into deneb-free-blobs.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use clap::{App, Arg};
|
||||
use clap::{App, Arg, ArgGroup};
|
||||
use strum::VariantNames;
|
||||
use types::ProgressiveBalancesMode;
|
||||
|
||||
@@ -82,11 +82,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.help("The address lighthouse will listen for UDP and TCP connections. To listen \
|
||||
over IpV4 and IpV6 set this flag twice with the different values.\n\
|
||||
Examples:\n\
|
||||
- --listen-address '0.0.0.0' will listen over Ipv4.\n\
|
||||
- --listen-address '::' will listen over Ipv6.\n\
|
||||
- --listen-address '0.0.0.0' will listen over IPv4.\n\
|
||||
- --listen-address '::' will listen over IPv6.\n\
|
||||
- --listen-address '0.0.0.0' --listen-address '::' will listen over both \
|
||||
Ipv4 and Ipv6. The order of the given addresses is not relevant. However, \
|
||||
multiple Ipv4, or multiple Ipv6 addresses will not be accepted.")
|
||||
IPv4 and IPv6. The order of the given addresses is not relevant. However, \
|
||||
multiple IPv4, or multiple IPv6 addresses will not be accepted.")
|
||||
.multiple(true)
|
||||
.max_values(2)
|
||||
.default_value("0.0.0.0")
|
||||
@@ -96,9 +96,10 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
Arg::with_name("port")
|
||||
.long("port")
|
||||
.value_name("PORT")
|
||||
.help("The TCP/UDP port to listen on. The UDP port can be modified by the \
|
||||
--discovery-port flag. If listening over both Ipv4 and Ipv6 the --port flag \
|
||||
will apply to the Ipv4 address and --port6 to the Ipv6 address.")
|
||||
.help("The TCP/UDP ports to listen on. There are two UDP ports. \
|
||||
The discovery UDP port will be set to this value and the Quic UDP port will be set to this value + 1. The discovery port can be modified by the \
|
||||
--discovery-port flag and the quic port can be modified by the --quic-port flag. If listening over both IPv4 and IPv6 the --port flag \
|
||||
will apply to the IPv4 address and --port6 to the IPv6 address.")
|
||||
.default_value("9000")
|
||||
.takes_value(true),
|
||||
)
|
||||
@@ -106,8 +107,8 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
Arg::with_name("port6")
|
||||
.long("port6")
|
||||
.value_name("PORT")
|
||||
.help("The TCP/UDP port to listen on over IpV6 when listening over both Ipv4 and \
|
||||
Ipv6. Defaults to 9090 when required.")
|
||||
.help("The TCP/UDP ports to listen on over IPv6 when listening over both IPv4 and \
|
||||
IPv6. Defaults to 9090 when required. The Quic UDP port will be set to this value + 1.")
|
||||
.default_value("9090")
|
||||
.takes_value(true),
|
||||
)
|
||||
@@ -118,12 +119,27 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.help("The UDP port that discovery will listen on. Defaults to `port`")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("quic-port")
|
||||
.long("quic-port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port that quic will listen on. Defaults to `port` + 1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("discovery-port6")
|
||||
.long("discovery-port6")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port that discovery will listen on over IpV6 if listening over \
|
||||
both Ipv4 and IpV6. Defaults to `port6`")
|
||||
.help("The UDP port that discovery will listen on over IPv6 if listening over \
|
||||
both IPv4 and IPv6. Defaults to `port6`")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("quic-port6")
|
||||
.long("quic-port6")
|
||||
.value_name("PORT")
|
||||
.help("The UDP port that quic will listen on over IPv6 if listening over \
|
||||
both IPv4 and IPv6. Defaults to `port6` + 1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
@@ -166,7 +182,15 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.long("enr-udp-port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP4 port of the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IpV4.")
|
||||
can connect to your local node on this port over IPv4.")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("enr-quic-port")
|
||||
.long("enr-quic-port")
|
||||
.value_name("PORT")
|
||||
.help("The quic UDP4 port that will be set on the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IPv4.")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
@@ -174,7 +198,15 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.long("enr-udp6-port")
|
||||
.value_name("PORT")
|
||||
.help("The UDP6 port of the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IpV6.")
|
||||
can connect to your local node on this port over IPv6.")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("enr-quic6-port")
|
||||
.long("enr-quic6-port")
|
||||
.value_name("PORT")
|
||||
.help("The quic UDP6 port that will be set on the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IPv6.")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
@@ -182,7 +214,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.long("enr-tcp-port")
|
||||
.value_name("PORT")
|
||||
.help("The TCP4 port of the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IpV4. The --port flag is \
|
||||
can connect to your local node on this port over IPv4. The --port flag is \
|
||||
used if this is not set.")
|
||||
.takes_value(true),
|
||||
)
|
||||
@@ -191,7 +223,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.long("enr-tcp6-port")
|
||||
.value_name("PORT")
|
||||
.help("The TCP6 port of the local ENR. Set this only if you are sure other nodes \
|
||||
can connect to your local node on this port over IpV6. The --port6 flag is \
|
||||
can connect to your local node on this port over IPv6. The --port6 flag is \
|
||||
used if this is not set.")
|
||||
.takes_value(true),
|
||||
)
|
||||
@@ -232,11 +264,18 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
without an ENR.")
|
||||
.takes_value(true),
|
||||
)
|
||||
// NOTE: This is hidden because it is primarily a developer feature for testnets and
|
||||
// debugging. We remove it from the list to avoid clutter.
|
||||
.arg(
|
||||
Arg::with_name("disable-discovery")
|
||||
.long("disable-discovery")
|
||||
.help("Disables the discv5 discovery protocol. The node will not search for new peers or participate in the discovery protocol.")
|
||||
.takes_value(false),
|
||||
.hidden(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("disable-quic")
|
||||
.long("disable-quic")
|
||||
.help("Disables the quic transport. The node will rely solely on the TCP transport for libp2p connections.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("disable-peer-scoring")
|
||||
@@ -323,22 +362,25 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-address")
|
||||
.long("http-address")
|
||||
.requires("enable_http")
|
||||
.value_name("ADDRESS")
|
||||
.help("Set the listen address for the RESTful HTTP API server.")
|
||||
.default_value("127.0.0.1")
|
||||
.default_value_if("enable_http", None, "127.0.0.1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-port")
|
||||
.long("http-port")
|
||||
.requires("enable_http")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the RESTful HTTP API server.")
|
||||
.default_value("5052")
|
||||
.default_value_if("enable_http", None, "5052")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-allow-origin")
|
||||
.long("http-allow-origin")
|
||||
.requires("enable_http")
|
||||
.value_name("ORIGIN")
|
||||
.help("Set the value of the Access-Control-Allow-Origin response HTTP header. \
|
||||
Use * to allow any origin (not recommended in production). \
|
||||
@@ -349,11 +391,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-disable-legacy-spec")
|
||||
.long("http-disable-legacy-spec")
|
||||
.requires("enable_http")
|
||||
.hidden(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-spec-fork")
|
||||
.long("http-spec-fork")
|
||||
.requires("enable_http")
|
||||
.value_name("FORK")
|
||||
.help("Serve the spec for a specific hard fork on /eth/v1/config/spec. It should \
|
||||
not be necessary to set this flag.")
|
||||
@@ -371,6 +415,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-tls-cert")
|
||||
.long("http-tls-cert")
|
||||
.requires("enable_http")
|
||||
.help("The path of the certificate to be used when serving the HTTP API server \
|
||||
over TLS.")
|
||||
.takes_value(true)
|
||||
@@ -378,6 +423,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-tls-key")
|
||||
.long("http-tls-key")
|
||||
.requires("enable_http")
|
||||
.help("The path of the private key to be used when serving the HTTP API server \
|
||||
over TLS. Must not be password-protected.")
|
||||
.takes_value(true)
|
||||
@@ -385,6 +431,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-allow-sync-stalled")
|
||||
.long("http-allow-sync-stalled")
|
||||
.requires("enable_http")
|
||||
.help("Forces the HTTP to indicate that the node is synced when sync is actually \
|
||||
stalled. This is useful for very small testnets. TESTING ONLY. DO NOT USE ON \
|
||||
MAINNET.")
|
||||
@@ -392,8 +439,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-sse-capacity-multiplier")
|
||||
.long("http-sse-capacity-multiplier")
|
||||
.requires("enable_http")
|
||||
.takes_value(true)
|
||||
.default_value("1")
|
||||
.default_value_if("enable_http", None, "1")
|
||||
.value_name("N")
|
||||
.help("Multiplier to apply to the length of HTTP server-sent-event (SSE) channels. \
|
||||
Increasing this value can prevent messages from being dropped.")
|
||||
@@ -401,8 +449,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-duplicate-block-status")
|
||||
.long("http-duplicate-block-status")
|
||||
.requires("enable_http")
|
||||
.takes_value(true)
|
||||
.default_value("202")
|
||||
.default_value_if("enable_http", None, "202")
|
||||
.value_name("STATUS_CODE")
|
||||
.help("Status code to send when a block that is already known is POSTed to the \
|
||||
HTTP API.")
|
||||
@@ -410,13 +459,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.arg(
|
||||
Arg::with_name("http-enable-beacon-processor")
|
||||
.long("http-enable-beacon-processor")
|
||||
.requires("enable_http")
|
||||
.value_name("BOOLEAN")
|
||||
.help("The beacon processor is a scheduler which provides quality-of-service and \
|
||||
DoS protection. When set to \"true\", HTTP API requests will be queued and scheduled \
|
||||
alongside other tasks. When set to \"false\", HTTP API responses will be executed \
|
||||
immediately.")
|
||||
.takes_value(true)
|
||||
.default_value("true")
|
||||
.default_value_if("enable_http", None, "true")
|
||||
)
|
||||
/* Prometheus metrics HTTP server related arguments */
|
||||
.arg(
|
||||
@@ -429,22 +479,25 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
Arg::with_name("metrics-address")
|
||||
.long("metrics-address")
|
||||
.value_name("ADDRESS")
|
||||
.requires("metrics")
|
||||
.help("Set the listen address for the Prometheus metrics HTTP server.")
|
||||
.default_value("127.0.0.1")
|
||||
.default_value_if("metrics", None, "127.0.0.1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("metrics-port")
|
||||
.long("metrics-port")
|
||||
.requires("metrics")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the Prometheus metrics HTTP server.")
|
||||
.default_value("5054")
|
||||
.default_value_if("metrics", None, "5054")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("metrics-allow-origin")
|
||||
.long("metrics-allow-origin")
|
||||
.value_name("ORIGIN")
|
||||
.requires("metrics")
|
||||
.help("Set the value of the Access-Control-Allow-Origin response HTTP header. \
|
||||
Use * to allow any origin (not recommended in production). \
|
||||
If no value is supplied, the CORS allowed origin is set to the listen \
|
||||
@@ -1283,4 +1336,5 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.default_value("64")
|
||||
.takes_value(true)
|
||||
)
|
||||
.group(ArgGroup::with_name("enable_http").args(&["http", "gui", "staking"]).multiple(true))
|
||||
}
|
||||
|
||||
@@ -95,70 +95,70 @@ pub fn get_config<E: EthSpec>(
|
||||
* Http API server
|
||||
*/
|
||||
|
||||
if cli_args.is_present("http") {
|
||||
if cli_args.is_present("enable_http") {
|
||||
client_config.http_api.enabled = true;
|
||||
|
||||
if let Some(address) = cli_args.value_of("http-address") {
|
||||
client_config.http_api.listen_addr = address
|
||||
.parse::<IpAddr>()
|
||||
.map_err(|_| "http-address is not a valid IP address.")?;
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("http-port") {
|
||||
client_config.http_api.listen_port = port
|
||||
.parse::<u16>()
|
||||
.map_err(|_| "http-port is not a valid u16.")?;
|
||||
}
|
||||
|
||||
if let Some(allow_origin) = cli_args.value_of("http-allow-origin") {
|
||||
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
||||
// as late as when the first API response is produced.
|
||||
hyper::header::HeaderValue::from_str(allow_origin)
|
||||
.map_err(|_| "Invalid allow-origin value")?;
|
||||
|
||||
client_config.http_api.allow_origin = Some(allow_origin.to_string());
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-disable-legacy-spec") {
|
||||
warn!(
|
||||
log,
|
||||
"The flag --http-disable-legacy-spec is deprecated and will be removed"
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(fork_name) = clap_utils::parse_optional(cli_args, "http-spec-fork")? {
|
||||
client_config.http_api.spec_fork_name = Some(fork_name);
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-enable-tls") {
|
||||
client_config.http_api.tls_config = Some(TlsConfig {
|
||||
cert: cli_args
|
||||
.value_of("http-tls-cert")
|
||||
.ok_or("--http-tls-cert was not provided.")?
|
||||
.parse::<PathBuf>()
|
||||
.map_err(|_| "http-tls-cert is not a valid path name.")?,
|
||||
key: cli_args
|
||||
.value_of("http-tls-key")
|
||||
.ok_or("--http-tls-key was not provided.")?
|
||||
.parse::<PathBuf>()
|
||||
.map_err(|_| "http-tls-key is not a valid path name.")?,
|
||||
});
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-allow-sync-stalled") {
|
||||
client_config.http_api.allow_sync_stalled = true;
|
||||
}
|
||||
|
||||
client_config.http_api.sse_capacity_multiplier =
|
||||
parse_required(cli_args, "http-sse-capacity-multiplier")?;
|
||||
|
||||
client_config.http_api.enable_beacon_processor =
|
||||
parse_required(cli_args, "http-enable-beacon-processor")?;
|
||||
|
||||
client_config.http_api.duplicate_block_status_code =
|
||||
parse_required(cli_args, "http-duplicate-block-status")?;
|
||||
}
|
||||
|
||||
if let Some(address) = cli_args.value_of("http-address") {
|
||||
client_config.http_api.listen_addr = address
|
||||
.parse::<IpAddr>()
|
||||
.map_err(|_| "http-address is not a valid IP address.")?;
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("http-port") {
|
||||
client_config.http_api.listen_port = port
|
||||
.parse::<u16>()
|
||||
.map_err(|_| "http-port is not a valid u16.")?;
|
||||
}
|
||||
|
||||
if let Some(allow_origin) = cli_args.value_of("http-allow-origin") {
|
||||
// Pre-validate the config value to give feedback to the user on node startup, instead of
|
||||
// as late as when the first API response is produced.
|
||||
hyper::header::HeaderValue::from_str(allow_origin)
|
||||
.map_err(|_| "Invalid allow-origin value")?;
|
||||
|
||||
client_config.http_api.allow_origin = Some(allow_origin.to_string());
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-disable-legacy-spec") {
|
||||
warn!(
|
||||
log,
|
||||
"The flag --http-disable-legacy-spec is deprecated and will be removed"
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(fork_name) = clap_utils::parse_optional(cli_args, "http-spec-fork")? {
|
||||
client_config.http_api.spec_fork_name = Some(fork_name);
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-enable-tls") {
|
||||
client_config.http_api.tls_config = Some(TlsConfig {
|
||||
cert: cli_args
|
||||
.value_of("http-tls-cert")
|
||||
.ok_or("--http-tls-cert was not provided.")?
|
||||
.parse::<PathBuf>()
|
||||
.map_err(|_| "http-tls-cert is not a valid path name.")?,
|
||||
key: cli_args
|
||||
.value_of("http-tls-key")
|
||||
.ok_or("--http-tls-key was not provided.")?
|
||||
.parse::<PathBuf>()
|
||||
.map_err(|_| "http-tls-key is not a valid path name.")?,
|
||||
});
|
||||
}
|
||||
|
||||
if cli_args.is_present("http-allow-sync-stalled") {
|
||||
client_config.http_api.allow_sync_stalled = true;
|
||||
}
|
||||
|
||||
client_config.http_api.sse_capacity_multiplier =
|
||||
parse_required(cli_args, "http-sse-capacity-multiplier")?;
|
||||
|
||||
client_config.http_api.enable_beacon_processor =
|
||||
parse_required(cli_args, "http-enable-beacon-processor")?;
|
||||
|
||||
client_config.http_api.duplicate_block_status_code =
|
||||
parse_required(cli_args, "http-duplicate-block-status")?;
|
||||
|
||||
if let Some(cache_size) = clap_utils::parse_optional(cli_args, "shuffling-cache-size")? {
|
||||
client_config.chain.shuffling_cache_size = cache_size;
|
||||
}
|
||||
@@ -952,15 +952,15 @@ pub fn parse_listening_addresses(
|
||||
.map_err(|parse_error| format!("Failed to parse --port6 as an integer: {parse_error}"))?
|
||||
.unwrap_or(9090);
|
||||
|
||||
// parse the possible udp ports
|
||||
let maybe_udp_port = cli_args
|
||||
// parse the possible discovery ports.
|
||||
let maybe_disc_port = cli_args
|
||||
.value_of("discovery-port")
|
||||
.map(str::parse::<u16>)
|
||||
.transpose()
|
||||
.map_err(|parse_error| {
|
||||
format!("Failed to parse --discovery-port as an integer: {parse_error}")
|
||||
})?;
|
||||
let maybe_udp6_port = cli_args
|
||||
let maybe_disc6_port = cli_args
|
||||
.value_of("discovery-port6")
|
||||
.map(str::parse::<u16>)
|
||||
.transpose()
|
||||
@@ -968,6 +968,24 @@ pub fn parse_listening_addresses(
|
||||
format!("Failed to parse --discovery-port6 as an integer: {parse_error}")
|
||||
})?;
|
||||
|
||||
// parse the possible quic port.
|
||||
let maybe_quic_port = cli_args
|
||||
.value_of("quic-port")
|
||||
.map(str::parse::<u16>)
|
||||
.transpose()
|
||||
.map_err(|parse_error| {
|
||||
format!("Failed to parse --quic-port as an integer: {parse_error}")
|
||||
})?;
|
||||
|
||||
// parse the possible quic port.
|
||||
let maybe_quic6_port = cli_args
|
||||
.value_of("quic-port6")
|
||||
.map(str::parse::<u16>)
|
||||
.transpose()
|
||||
.map_err(|parse_error| {
|
||||
format!("Failed to parse --quic6-port as an integer: {parse_error}")
|
||||
})?;
|
||||
|
||||
// Now put everything together
|
||||
let listening_addresses = match (maybe_ipv4, maybe_ipv6) {
|
||||
(None, None) => {
|
||||
@@ -978,7 +996,7 @@ pub fn parse_listening_addresses(
|
||||
// A single ipv6 address was provided. Set the ports
|
||||
|
||||
if cli_args.is_present("port6") {
|
||||
warn!(log, "When listening only over IpV6, use the --port flag. The value of --port6 will be ignored.")
|
||||
warn!(log, "When listening only over IPv6, use the --port flag. The value of --port6 will be ignored.")
|
||||
}
|
||||
// use zero ports if required. If not, use the given port.
|
||||
let tcp_port = use_zero_ports
|
||||
@@ -986,20 +1004,32 @@ pub fn parse_listening_addresses(
|
||||
.transpose()?
|
||||
.unwrap_or(port);
|
||||
|
||||
if maybe_udp6_port.is_some() {
|
||||
warn!(log, "When listening only over IpV6, use the --discovery-port flag. The value of --discovery-port6 will be ignored.")
|
||||
if maybe_disc6_port.is_some() {
|
||||
warn!(log, "When listening only over IPv6, use the --discovery-port flag. The value of --discovery-port6 will be ignored.")
|
||||
}
|
||||
|
||||
if maybe_quic6_port.is_some() {
|
||||
warn!(log, "When listening only over IPv6, use the --quic-port flag. The value of --quic-port6 will be ignored.")
|
||||
}
|
||||
|
||||
// use zero ports if required. If not, use the specific udp port. If none given, use
|
||||
// the tcp port.
|
||||
let udp_port = use_zero_ports
|
||||
let disc_port = use_zero_ports
|
||||
.then(unused_port::unused_udp6_port)
|
||||
.transpose()?
|
||||
.or(maybe_udp_port)
|
||||
.or(maybe_disc_port)
|
||||
.unwrap_or(port);
|
||||
|
||||
let quic_port = use_zero_ports
|
||||
.then(unused_port::unused_udp6_port)
|
||||
.transpose()?
|
||||
.or(maybe_quic_port)
|
||||
.unwrap_or(port + 1);
|
||||
|
||||
ListenAddress::V6(lighthouse_network::ListenAddr {
|
||||
addr: ipv6,
|
||||
udp_port,
|
||||
quic_port,
|
||||
disc_port,
|
||||
tcp_port,
|
||||
})
|
||||
}
|
||||
@@ -1011,16 +1041,25 @@ pub fn parse_listening_addresses(
|
||||
.then(unused_port::unused_tcp4_port)
|
||||
.transpose()?
|
||||
.unwrap_or(port);
|
||||
// use zero ports if required. If not, use the specific udp port. If none given, use
|
||||
// use zero ports if required. If not, use the specific discovery port. If none given, use
|
||||
// the tcp port.
|
||||
let udp_port = use_zero_ports
|
||||
let disc_port = use_zero_ports
|
||||
.then(unused_port::unused_udp4_port)
|
||||
.transpose()?
|
||||
.or(maybe_udp_port)
|
||||
.or(maybe_disc_port)
|
||||
.unwrap_or(port);
|
||||
// use zero ports if required. If not, use the specific quic port. If none given, use
|
||||
// the tcp port + 1.
|
||||
let quic_port = use_zero_ports
|
||||
.then(unused_port::unused_udp4_port)
|
||||
.transpose()?
|
||||
.or(maybe_quic_port)
|
||||
.unwrap_or(port + 1);
|
||||
|
||||
ListenAddress::V4(lighthouse_network::ListenAddr {
|
||||
addr: ipv4,
|
||||
udp_port,
|
||||
disc_port,
|
||||
quic_port,
|
||||
tcp_port,
|
||||
})
|
||||
}
|
||||
@@ -1029,31 +1068,44 @@ pub fn parse_listening_addresses(
|
||||
.then(unused_port::unused_tcp4_port)
|
||||
.transpose()?
|
||||
.unwrap_or(port);
|
||||
let ipv4_udp_port = use_zero_ports
|
||||
let ipv4_disc_port = use_zero_ports
|
||||
.then(unused_port::unused_udp4_port)
|
||||
.transpose()?
|
||||
.or(maybe_udp_port)
|
||||
.or(maybe_disc_port)
|
||||
.unwrap_or(ipv4_tcp_port);
|
||||
let ipv4_quic_port = use_zero_ports
|
||||
.then(unused_port::unused_udp4_port)
|
||||
.transpose()?
|
||||
.or(maybe_quic_port)
|
||||
.unwrap_or(port + 1);
|
||||
|
||||
// Defaults to 9090 when required
|
||||
let ipv6_tcp_port = use_zero_ports
|
||||
.then(unused_port::unused_tcp6_port)
|
||||
.transpose()?
|
||||
.unwrap_or(port6);
|
||||
let ipv6_udp_port = use_zero_ports
|
||||
let ipv6_disc_port = use_zero_ports
|
||||
.then(unused_port::unused_udp6_port)
|
||||
.transpose()?
|
||||
.or(maybe_udp6_port)
|
||||
.or(maybe_disc6_port)
|
||||
.unwrap_or(ipv6_tcp_port);
|
||||
let ipv6_quic_port = use_zero_ports
|
||||
.then(unused_port::unused_udp6_port)
|
||||
.transpose()?
|
||||
.or(maybe_quic6_port)
|
||||
.unwrap_or(ipv6_tcp_port + 1);
|
||||
|
||||
ListenAddress::DualStack(
|
||||
lighthouse_network::ListenAddr {
|
||||
addr: ipv4,
|
||||
udp_port: ipv4_udp_port,
|
||||
disc_port: ipv4_disc_port,
|
||||
quic_port: ipv4_quic_port,
|
||||
tcp_port: ipv4_tcp_port,
|
||||
},
|
||||
lighthouse_network::ListenAddr {
|
||||
addr: ipv6,
|
||||
udp_port: ipv6_udp_port,
|
||||
disc_port: ipv6_disc_port,
|
||||
quic_port: ipv6_quic_port,
|
||||
tcp_port: ipv6_tcp_port,
|
||||
},
|
||||
)
|
||||
@@ -1169,6 +1221,14 @@ pub fn set_network_config(
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(enr_quic_port_str) = cli_args.value_of("enr-quic-port") {
|
||||
config.enr_quic4_port = Some(
|
||||
enr_quic_port_str
|
||||
.parse::<u16>()
|
||||
.map_err(|_| format!("Invalid quic port: {}", enr_quic_port_str))?,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(enr_tcp_port_str) = cli_args.value_of("enr-tcp-port") {
|
||||
config.enr_tcp4_port = Some(
|
||||
enr_tcp_port_str
|
||||
@@ -1185,6 +1245,14 @@ pub fn set_network_config(
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(enr_quic_port_str) = cli_args.value_of("enr-quic6-port") {
|
||||
config.enr_quic6_port = Some(
|
||||
enr_quic_port_str
|
||||
.parse::<u16>()
|
||||
.map_err(|_| format!("Invalid quic port: {}", enr_quic_port_str))?,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(enr_tcp_port_str) = cli_args.value_of("enr-tcp6-port") {
|
||||
config.enr_tcp6_port = Some(
|
||||
enr_tcp_port_str
|
||||
@@ -1194,9 +1262,9 @@ pub fn set_network_config(
|
||||
}
|
||||
|
||||
if cli_args.is_present("enr-match") {
|
||||
// Match the Ip and UDP port in the enr.
|
||||
// Match the IP and UDP port in the ENR.
|
||||
|
||||
// set the enr address to localhost if the address is unspecified
|
||||
// Set the ENR address to localhost if the address is unspecified.
|
||||
if let Some(ipv4_addr) = config.listen_addrs().v4().cloned() {
|
||||
let ipv4_enr_addr = if ipv4_addr.addr == Ipv4Addr::UNSPECIFIED {
|
||||
Ipv4Addr::LOCALHOST
|
||||
@@ -1204,7 +1272,7 @@ pub fn set_network_config(
|
||||
ipv4_addr.addr
|
||||
};
|
||||
config.enr_address.0 = Some(ipv4_enr_addr);
|
||||
config.enr_udp4_port = Some(ipv4_addr.udp_port);
|
||||
config.enr_udp4_port = Some(ipv4_addr.disc_port);
|
||||
}
|
||||
|
||||
if let Some(ipv6_addr) = config.listen_addrs().v6().cloned() {
|
||||
@@ -1214,7 +1282,7 @@ pub fn set_network_config(
|
||||
ipv6_addr.addr
|
||||
};
|
||||
config.enr_address.1 = Some(ipv6_enr_addr);
|
||||
config.enr_udp6_port = Some(ipv6_addr.udp_port);
|
||||
config.enr_udp6_port = Some(ipv6_addr.disc_port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1247,11 +1315,11 @@ pub fn set_network_config(
|
||||
// actually matters. Just use the udp port.
|
||||
|
||||
let port = match config.listen_addrs() {
|
||||
ListenAddress::V4(v4_addr) => v4_addr.udp_port,
|
||||
ListenAddress::V6(v6_addr) => v6_addr.udp_port,
|
||||
ListenAddress::V4(v4_addr) => v4_addr.disc_port,
|
||||
ListenAddress::V6(v6_addr) => v6_addr.disc_port,
|
||||
ListenAddress::DualStack(v4_addr, _v6_addr) => {
|
||||
// NOTE: slight preference for ipv4 that I don't think is of importance.
|
||||
v4_addr.udp_port
|
||||
v4_addr.disc_port
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1310,6 +1378,10 @@ pub fn set_network_config(
|
||||
warn!(log, "Discovery is disabled. New peers will not be found");
|
||||
}
|
||||
|
||||
if cli_args.is_present("disable-quic") {
|
||||
config.disable_quic_support = true;
|
||||
}
|
||||
|
||||
if cli_args.is_present("disable-upnp") {
|
||||
config.upnp_enabled = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user