♻️ refactor
parent
ca3145669d
commit
4ba35ee7d1
|
@ -37,9 +37,18 @@ async fn main () -> anyhow::Result <()> {
|
||||||
trace! ("Accepting bi streams from P3");
|
trace! ("Accepting bi streams from P3");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (mut relay_send, mut relay_recv) = bi_streams.next ().await.ok_or_else (|| anyhow::anyhow! ("Relay server didn't open a bi stream"))??;
|
let (relay_send, relay_recv) = bi_streams.next ().await.ok_or_else (|| anyhow::anyhow! ("Relay server didn't open a bi stream"))??;
|
||||||
|
|
||||||
tokio::spawn (async move {
|
tokio::spawn (handle_p2_connection (relay_send, relay_recv, local_tcp_port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_p2_connection (
|
||||||
|
mut relay_send: quinn::SendStream,
|
||||||
|
mut relay_recv: quinn::RecvStream,
|
||||||
|
local_tcp_port: u16,
|
||||||
|
) -> anyhow::Result <()>
|
||||||
|
{
|
||||||
let mut req_buf = [0, 0, 0, 0];
|
let mut req_buf = [0, 0, 0, 0];
|
||||||
relay_recv.read_exact (&mut req_buf).await?;
|
relay_recv.read_exact (&mut req_buf).await?;
|
||||||
assert_eq! (req_buf [0], Command::CONNECT_P2_TO_P4_STEP_2.0);
|
assert_eq! (req_buf [0], Command::CONNECT_P2_TO_P4_STEP_2.0);
|
||||||
|
@ -85,9 +94,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
ptth_conn.uplink_task.await??;
|
ptth_conn.uplink_task.await??;
|
||||||
ptth_conn.downlink_task.await??;
|
ptth_conn.downlink_task.await??;
|
||||||
|
|
||||||
Ok::<_, anyhow::Error> (())
|
Ok (())
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PtthNewConnection {
|
struct PtthNewConnection {
|
||||||
|
|
Loading…
Reference in New Issue