Merge pull request #69 from uqbar-dao/dr/net-timeout-when-recv

fix: make connection receiver always time out
This commit is contained in:
dr-frmr 2023-11-17 13:09:46 -05:00 committed by GitHub
commit 863cb78741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -387,23 +387,30 @@ async fn direct_networking(
if let Ok(websocket) = accept_async(MaybeTlsStream::Plain(stream)).await {
print_debug(&print_tx, "net: received new websocket connection").await;
let (peer_id, routing_for, conn) =
match recv_connection(
match time::timeout(TIMEOUT, recv_connection(
&our,
&our_ip,
&pki,
&peers,
&mut pending_passthroughs,
&keypair,
websocket).await
websocket)).await
{
Ok(res) => res,
Err(e) => {
Ok(Ok(res)) => res,
Ok(Err(e)) => {
print_tx.send(Printout {
verbosity: 0,
content: format!("net: recv_connection failed: {e}"),
}).await?;
continue;
}
Err(e) => {
print_tx.send(Printout {
verbosity: 0,
content: "net: recv_connection timed out".into(),
}).await?;
continue;
}
};
// TODO if their handshake indicates they want us to proxy
// for them (aka act as a router for them) we can choose