Commit 9e0aae03 authored by Katharina Fey's avatar Katharina Fey

netmod-tcp: fixing a panic when sending a hello-ack

This is an issue when a connection is uni-directional (usually because
the reverse connection is blocked by a firewall or non-forwarded point).
parent ebfbd83a
......@@ -23,16 +23,15 @@ async fn main() {
let app = cfg::cli();
let cfg = cfg::match_fold(app);
if upnp::open_port(cfg.port).is_none() {
error!("Failed to open UPNP port; your router probably doesn't support it...");
}
// let _state = State::new(&cfg).await;
let _state = State::new(&cfg).await;
// !no_upnp means upnp has _not_ been disabled
// if !cfg.no_upnp {
// }
if !cfg.no_upnp {
if upnp::open_port(cfg.port).is_none() {
error!("Failed to open UPNP port; your router probably doesn't support it...");
}
}
// // Never return the main thread or it all dies
// let _: () = future::poll_fn(|_| Poll::Pending).await;
// Never return the main thread or it all dies
let _: () = future::poll_fn(|_| Poll::Pending).await;
}
......@@ -220,9 +220,10 @@ impl Server {
let s = Arc::clone(self);
task::spawn(async move {
let peer = s.routes.get_peer(id).await.unwrap();
task::sleep(Duration::from_secs(2)).await;
peer.send(Packet::Hello { port: s._port }).await;
if let Some(peer) = s.routes.get_peer(id).await {
task::sleep(Duration::from_secs(2)).await;
peer.send(Packet::Hello { port: s._port }).await;
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment