diff options
Diffstat (limited to 'src/transport/libp2p/driver.rs')
| -rw-r--r-- | src/transport/libp2p/driver.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/transport/libp2p/driver.rs b/src/transport/libp2p/driver.rs index a0434a6..b8c8c37 100644 --- a/src/transport/libp2p/driver.rs +++ b/src/transport/libp2p/driver.rs @@ -21,6 +21,8 @@ pub(super) enum Command { /// Find out which peer relays at `address`, named without the relay's peer ID /// (`Book::finding`). FindRelay { address: Multiaddr }, + /// Where `--libp2p-internet-hosts` are now (`Routes::internet`). + Internet(Vec<std::net::IpAddr>), } /// Drives the swarm: dials what `commands` ask for and notes where we listen, until the @@ -97,6 +99,18 @@ pub(super) async fn run( } } _ = check.tick() => { + let hosts = { + let mut book = lock(&book); + book.recheck_routes(); + book.routes.internet_hosts.clone() + }; + // Names are resolved aside, not to hold up the swarm. + if !hosts.is_empty() { + let again = again.clone(); + tokio::spawn(async move { + let _ = again.send(Command::Internet(resolve_internet_hosts(&hosts).await)); + }); + } pick_relays(&mut swarm, &book, &relaying, &nat, &mut picked); retry_punches(&mut swarm, &book, relaying.local); } @@ -105,6 +119,7 @@ pub(super) async fn run( Some(Command::CheckRelays) => { pick_relays(&mut swarm, &book, &relaying, &nat, &mut picked); } + Some(Command::Internet(hosts)) => lock(&book).routes.internet(&hosts), Some(Command::Connect { peer, addresses, done }) => { if swarm.is_connected(&peer) { let _ = done.send(Ok(())); |
