Skip to content

Commit

Permalink
fix(network): fixed allow private addrs (#1618)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurinderu committed May 18, 2023
1 parent f5e0807 commit 7efb490
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 0 additions & 2 deletions crates/server-config/src/network_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub struct NetworkConfig {
pub kademlia_config: KademliaConfig,
pub particle_queue_buffer: usize,
pub bootstrap_frequency: usize,
pub allow_local_addresses: bool,
pub connectivity_metrics: Option<ConnectivityMetrics>,
pub connection_pool_metrics: Option<ConnectionPoolMetrics>,
#[allow(deprecated)]
Expand Down Expand Up @@ -66,7 +65,6 @@ impl NetworkConfig {
kademlia_config: config.kademlia.clone(),
particle_queue_buffer: config.particle_queue_buffer,
bootstrap_frequency: config.bootstrap_frequency,
allow_local_addresses: config.allow_local_addresses,
connectivity_metrics,
connection_pool_metrics,
connection_limits,
Expand Down
11 changes: 9 additions & 2 deletions particle-node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub struct Node<RT: AquaRuntime> {
pub builtins_management_peer_id: PeerId,

pub key_manager: KeyManager,

allow_local_addresses: bool,
}

impl<RT: AquaRuntime> Node<RT> {
Expand Down Expand Up @@ -164,6 +166,8 @@ impl<RT: AquaRuntime> Node<RT> {
connection_limits,
);

let allow_local_addresses = config.allow_local_addresses;

let (swarm, connectivity, particle_stream) = Self::swarm(
key_manager.get_host_peer_id(),
network_config,
Expand Down Expand Up @@ -319,6 +323,7 @@ impl<RT: AquaRuntime> Node<RT> {
config.metrics_listen_addr(),
builtins_peer_id,
key_manager,
allow_local_addresses,
))
}

Expand Down Expand Up @@ -386,6 +391,7 @@ impl<RT: AquaRuntime> Node<RT> {
metrics_listen_addr: SocketAddr,
builtins_management_peer_id: PeerId,
key_manager: KeyManager,
allow_local_addresses: bool,
) -> Box<Self> {
let node_service = Self {
particle_stream,
Expand All @@ -410,6 +416,7 @@ impl<RT: AquaRuntime> Node<RT> {

builtins_management_peer_id,
key_manager,
allow_local_addresses,
};

Box::new(node_service)
Expand Down Expand Up @@ -440,6 +447,7 @@ impl<RT: AquaRuntime> Node<RT> {
.map(|x| format!("node-{x}"))
.unwrap_or("node".to_owned());
let libp2p_metrics = self.libp2p_metrics;
let allow_local_addresses = self.allow_local_addresses;

task::Builder::new().name(&task_name.clone()).spawn(async move {
let mut metrics_fut= if let Some(registry) = registry {
Expand All @@ -457,14 +465,13 @@ impl<RT: AquaRuntime> Node<RT> {
let mut connectivity = connectivity.start();
let mut dispatcher = dispatcher.start(particle_stream, effects_stream);
let mut exit_inlet = Some(exit_inlet);

loop {
let exit_inlet = exit_inlet.as_mut().expect("Could not get exit inlet");
tokio::select! {
Some(e) = swarm.next() => {
if let Some(m) = libp2p_metrics.as_ref() { m.record(&e) }
if let SwarmEvent::Behaviour(FluenceNetworkBehaviourEvent::Identify(i)) = e {
swarm.behaviour_mut().inject_identify_event(i, true);
swarm.behaviour_mut().inject_identify_event(i, allow_local_addresses);
}
},
_ = &mut metrics_fut => {},
Expand Down

0 comments on commit 7efb490

Please sign in to comment.