diff --git a/ant-bootstrap/src/initial_peers.rs b/ant-bootstrap/src/initial_peers.rs index 946c60c07f..16f71890b0 100644 --- a/ant-bootstrap/src/initial_peers.rs +++ b/ant-bootstrap/src/initial_peers.rs @@ -121,16 +121,10 @@ impl PeersArgs { let mut bootstrap_addresses = vec![]; - // Read from `ANT_PEERS` environment variable if present - if let Ok(addrs) = std::env::var(ANT_PEERS_ENV) { - for addr_str in addrs.split(',') { - if let Some(addr) = craft_valid_multiaddr_from_str(addr_str, false) { - info!("Adding addr from environment variable: {addr}"); - bootstrap_addresses.push(BootstrapAddr::new(addr)); - } else { - warn!("Invalid multiaddress format from environment variable: {addr_str}"); - } - } + // Read from ANT_PEERS environment variable if present + bootstrap_addresses.extend(Self::read_bootstrap_addr_from_env()); + + if !bootstrap_addresses.is_empty() { return Ok(bootstrap_addresses); } @@ -150,9 +144,6 @@ impl PeersArgs { } } - // Read from ANT_PEERS environment variable if present - bootstrap_addresses.extend(Self::read_bootstrap_addr_from_env()); - if let Some(count) = count { if bootstrap_addresses.len() >= count { bootstrap_addresses.sort_by_key(|addr| addr.failure_rate() as u64); diff --git a/ant-networking/src/event/swarm.rs b/ant-networking/src/event/swarm.rs index 3bf65eb6d9..f52b7de986 100644 --- a/ant-networking/src/event/swarm.rs +++ b/ant-networking/src/event/swarm.rs @@ -358,6 +358,19 @@ impl SwarmDriver { } => { event_string = "incoming"; debug!("IncomingConnection ({connection_id:?}) with local_addr: {local_addr:?} send_back_addr: {send_back_addr:?}"); + // Client/Node that got peer inserted into RT manually then dial, + // will cause the peer receive such IncomingConnection Event + // Only node shall hit such situation, and currently from client only + // The peer_id is unknown, hence don't know whether dialed or not. + if !self.is_client { + if let Err(err) = self.swarm.dial( + DialOpts::unknown_peer_id() + .address(send_back_addr.clone()) + .build(), + ) { + warn!(?send_back_addr, "dialing error: {err:?}"); + } + } } SwarmEvent::ConnectionEstablished { peer_id, diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 0a3ecc9b99..2dd2278225 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -103,7 +103,7 @@ impl Client { let peers = if let Some(peers) = config.peers { peers } else { - match peers_args.get_addrs(None).await { + match peers_args.get_addrs(None, None).await { Ok(peers) => peers, Err(e) => return Err(e), }