Skip to content

Commit

Permalink
p2p peer management cli config checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sistemd committed Feb 13, 2024
1 parent 43b36fe commit 8d68de3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crates/pathfinder/src/bin/pathfinder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ Example:
long_help = "Comma separated list of IP addresses or IP address ranges (in CIDR) to whitelist for incoming connections. If not provided, all incoming connections are allowed.",
value_name = "LIST",
default_value = "0.0.0.0/0,::/0",
value_delimiter = ',',
env = "IP_WHITELIST"
)]
ip_whitelist: Vec<IpNet>,
Expand Down Expand Up @@ -650,6 +651,33 @@ impl P2PConfig {
})
};

if (1..25).contains(&args.max_inbound_direct_connections) {
Cli::command()
.error(
ErrorKind::ValueValidation,
"p2p.max-inbound-direct-connections must be zero or at least 25",
)
.exit()
}

if (1..25).contains(&args.max_inbound_relayed_connections) {
Cli::command()
.error(
ErrorKind::ValueValidation,
"p2p.max-inbound-relayed-connections must be zero or at least 25",
)
.exit()
}

if args.low_watermark > args.max_outbound_connections {
Cli::command()
.error(
ErrorKind::ValueValidation,
"p2p.low-watermark must be less than or equal to max_outbound_connections",
)
.exit()
}

Self {
max_inbound_direct_connections: args.max_inbound_direct_connections.try_into().unwrap(),
max_inbound_relayed_connections: args
Expand Down

0 comments on commit 8d68de3

Please sign in to comment.