Skip to content

Commit

Permalink
properly pass the ip_whitelist flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sistemd committed Feb 5, 2024
1 parent 875d49b commit ea94040
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
18 changes: 0 additions & 18 deletions crates/p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,6 @@ pub struct Config {
pub bootstrap: BootstrapConfig,
}

impl Config {
pub fn new(
max_inbound_direct_peers: usize,
max_inbound_relay_peers: usize,
bootstrap: BootstrapConfig,
) -> Self {
Self {
direct_connection_timeout: Duration::from_secs(30),
relay_connection_timeout: Duration::from_secs(10),
max_inbound_direct_peers,
max_inbound_relayed_peers: max_inbound_relay_peers,
ip_whitelist: vec!["::/0".parse().unwrap(), "0.0.0.0/0".parse().unwrap()],
bootstrap,
eviction_timeout: Duration::from_secs(15 * 60),
}
}
}

#[derive(Copy, Clone, Debug)]
pub struct BootstrapConfig {
pub start_offset: Duration,
Expand Down
10 changes: 9 additions & 1 deletion crates/p2p/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ impl TestPeer {
impl Default for TestPeer {
fn default() -> Self {
Self::new(
Config::new(10, 10, Default::default()),
Config {
direct_connection_timeout: Duration::from_secs(30),
relay_connection_timeout: Duration::from_secs(10),
max_inbound_direct_peers: 10,
max_inbound_relayed_peers: 10,
ip_whitelist: vec!["::/0".parse().unwrap(), "0.0.0.0/0".parse().unwrap()],
bootstrap: Default::default(),
eviction_timeout: Duration::from_secs(15 * 60),
},
Keypair::generate_ed25519(),
)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/pathfinder/src/bin/pathfinder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ pub struct P2PConfig {
pub predefined_peers: Vec<Multiaddr>,
pub max_inbound_direct_connections: usize,
pub max_inbound_relayed_connections: usize,
pub ip_whitelist: Vec<IpNet>,
}

#[cfg(not(feature = "p2p"))]
Expand Down Expand Up @@ -640,6 +641,7 @@ impl P2PConfig {
listen_on: args.listen_on,
bootstrap_addresses: parse_multiaddr_vec(args.bootstrap_addresses),
predefined_peers: parse_multiaddr_vec(args.predefined_peers),
ip_whitelist: args.ip_whitelist,
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions crates/pathfinder/src/bin/pathfinder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ async fn start_p2p(
use p2p::libp2p::identity::Keypair;
use pathfinder_lib::p2p_network::{client::HybridClient, P2PContext};
use serde::Deserialize;
use std::path::Path;
use std::{path::Path, time::Duration};
use zeroize::Zeroizing;

#[derive(Clone, Deserialize)]
Expand Down Expand Up @@ -381,11 +381,15 @@ async fn start_p2p(
};

let context = P2PContext {
cfg: p2p::Config::new(
config.max_inbound_direct_connections,
config.max_inbound_relayed_connections,
Default::default(),
),
cfg: p2p::Config {
direct_connection_timeout: Duration::from_secs(30),
relay_connection_timeout: Duration::from_secs(10),
max_inbound_direct_peers: config.max_inbound_direct_connections,
max_inbound_relayed_peers: config.max_inbound_relayed_connections,
ip_whitelist: config.ip_whitelist,
bootstrap: Default::default(),
eviction_timeout: Duration::from_secs(15 * 60),
},
chain_id,
storage,
proxy: config.proxy,
Expand Down

0 comments on commit ea94040

Please sign in to comment.