main
parent
ce817eab1a
commit
1024c15fbb
|
@ -19,6 +19,15 @@ async fn main () -> anyhow::Result <()> {
|
||||||
..
|
..
|
||||||
} = endpoint.connect (&server_addr, "localhost")?.await?;
|
} = endpoint.connect (&server_addr, "localhost")?.await?;
|
||||||
|
|
||||||
|
let (mut send, mut recv) = connection.open_bi ().await?;
|
||||||
|
|
||||||
|
let req_buf = [2u8, 42, 0, 0];
|
||||||
|
send.write_all (&req_buf).await?;
|
||||||
|
|
||||||
|
let mut resp_buf = [0u8, 0, 0, 0];
|
||||||
|
recv.read_exact (&mut resp_buf).await?;
|
||||||
|
|
||||||
|
if false {
|
||||||
debug! ("Waiting for local TCP client to connect to us");
|
debug! ("Waiting for local TCP client to connect to us");
|
||||||
|
|
||||||
let listener = TcpListener::bind ("127.0.0.1:30381").await?;
|
let listener = TcpListener::bind ("127.0.0.1:30381").await?;
|
||||||
|
@ -62,6 +71,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
|
|
||||||
uplink_task.await??;
|
uplink_task.await??;
|
||||||
downlink_task.await??;
|
downlink_task.await??;
|
||||||
|
}
|
||||||
|
|
||||||
Ok (())
|
Ok (())
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
|
|
||||||
let (mut send, mut recv) = connection.open_bi ().await?;
|
let (mut send, mut recv) = connection.open_bi ().await?;
|
||||||
|
|
||||||
let req_buf = [4u8, 0, 0, 0];
|
let req_buf = [4u8, 43, 0, 0];
|
||||||
send.write_all (&req_buf).await?;
|
send.write_all (&req_buf).await?;
|
||||||
|
|
||||||
let mut resp_buf = [0u8, 0, 0, 0];
|
let mut resp_buf = [0u8, 0, 0, 0];
|
||||||
|
|
|
@ -14,7 +14,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
while let Some (conn) = incoming.next ().await {
|
while let Some (conn) = incoming.next ().await {
|
||||||
let relay_state = Arc::clone (&relay_state);
|
let relay_state = Arc::clone (&relay_state);
|
||||||
|
|
||||||
// Each new connection gets its own task
|
// Each new peer QUIC connection gets its own task
|
||||||
tokio::spawn (async move {
|
tokio::spawn (async move {
|
||||||
let quinn::NewConnection {
|
let quinn::NewConnection {
|
||||||
connection,
|
connection,
|
||||||
|
@ -31,15 +31,28 @@ async fn main () -> anyhow::Result <()> {
|
||||||
let mut req_buf = [0u8; 4];
|
let mut req_buf = [0u8; 4];
|
||||||
recv.read_exact (&mut req_buf).await?;
|
recv.read_exact (&mut req_buf).await?;
|
||||||
|
|
||||||
match req_buf [0] {
|
let peer_type = req_buf [0];
|
||||||
4 => debug! ("Server-side proxy (P4) connected"),
|
let peer_id = req_buf [1];
|
||||||
2 => debug! ("Client-side proxy (P2) connected"),
|
|
||||||
|
match peer_type {
|
||||||
|
4 => debug! ("Server-side proxy (P4) connected, ID {}", peer_id),
|
||||||
|
2 => debug! ("Client-side proxy (P2) connected, ID {}", peer_id),
|
||||||
_ => bail! ("Unknown QUIC client type"),
|
_ => bail! ("Unknown QUIC client type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp_buf = [20u8, 0, 0, 0];
|
let resp_buf = [20u8, 0, 0, 0];
|
||||||
send.write_all (&resp_buf).await?;
|
send.write_all (&resp_buf).await?;
|
||||||
|
|
||||||
|
match peer_type {
|
||||||
|
2 => while let Some (bi_stream) = bi_streams.next ().await {
|
||||||
|
let (mut send, mut recv) = bi_stream?;
|
||||||
|
|
||||||
|
// Each new
|
||||||
|
},
|
||||||
|
4 => (),
|
||||||
|
_ => bail! ("Unknown QUIC client type"),
|
||||||
|
}
|
||||||
|
|
||||||
Ok::<_, anyhow::Error> (())
|
Ok::<_, anyhow::Error> (())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue