♻️ refactor: reduced maximum indentation

main
_ 2021-07-17 08:02:53 +00:00
parent 67fc89e640
commit 82e2aae3d2
1 changed files with 34 additions and 22 deletions

View File

@ -157,7 +157,7 @@ async fn handle_p2_connection (
} = conn;
while let Some (bi_stream) = bi_streams.next ().await {
let (mut client_send, mut client_recv) = bi_stream?;
let (client_send, mut client_recv) = bi_stream?;
let relay_state = Arc::clone (&relay_state);
tokio::spawn (async move {
@ -168,7 +168,29 @@ async fn handle_p2_connection (
match cmd_type {
1 => {
let server_id = req_buf [1];
handle_request_p2_to_p4 (relay_state, client_id, server_id, client_send, client_recv).await?;
},
_ => bail! ("Unknown command type from P2"),
}
debug! ("Request ended for P2");
Ok::<_, anyhow::Error> (())
});
}
debug! ("P2 {} disconnected", client_id);
Ok (())
}
async fn handle_request_p2_to_p4 (
relay_state: Arc <Mutex <RelayState>>,
client_id: u8,
server_id: u8,
mut client_send: quinn::SendStream,
client_recv: quinn::RecvStream,
) -> anyhow::Result <()>
{
debug! ("P2 {} wants to connect to P4 {}", client_id, server_id);
// TODO: Auth checks
@ -189,17 +211,7 @@ async fn handle_p2_connection (
None => warn! ("That server isn't connected"),
}
}
},
_ => bail! ("Unknown command type from P2"),
}
debug! ("Request ended for P2");
Ok::<_, anyhow::Error> (())
});
}
debug! ("P2 {} disconnected", client_id);
Ok (())
}