Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(p2p): peer management cli config checks #1760

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
sistemd marked this conversation as resolved.
Show resolved Hide resolved
)
.exit()
}

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