add udp_over_tcp server to PTTH_QUIC relay server

maybe it'll work
main
(on company time) 2022-10-31 13:11:31 -05:00
parent 963631ff96
commit fd3c85fccd
2 changed files with 36 additions and 4 deletions

View File

@ -22,7 +22,7 @@ pub struct Opt {
#[structopt (long)] #[structopt (long)]
listen_addr: Option <String>, listen_addr: Option <String>,
#[structopt (long)] #[structopt (long)]
tcp_listen_addr: Option <String>, tcp_listen_port: Option <u16>,
} }
pub async fn main (opt: Opt) -> anyhow::Result <()> pub async fn main (opt: Opt) -> anyhow::Result <()>
@ -115,9 +115,37 @@ pub async fn main (opt: Opt) -> anyhow::Result <()>
debug! ("Serving HTTP on {:?}", http_addr); debug! ("Serving HTTP on {:?}", http_addr);
task_quic_server.await??; let task_tcp_over_udp_server = if let Some (tcp_listen_port) = opt.tcp_listen_port {
task_http_server.await??; tokio::spawn (async move {
task_direc_server.await??; let cfg = udp_over_tcp::server::Config {
tcp_port: tcp_listen_port,
udp_port: listen_addr.port (),
};
udp_over_tcp::server::main (cfg).await
})
}
else {
tokio::spawn (async move {
loop {
tokio::time::sleep (Duration::from_secs (3_600)).await;
}
})
};
tokio::select! {
_val = task_quic_server => {
eprintln! ("QUIC relay server exited, exiting");
},
_val = task_http_server => {
eprintln! ("HTTP server exited, exiting");
},
_val = task_direc_server => {
eprintln! ("PTTH_DIREC server exited, exiting");
},
_val = task_tcp_over_udp_server => {
eprintln! ("tcp_over_udp server exited, exiting");
}
}
Ok (()) Ok (())
} }

View File

@ -0,0 +1,4 @@
pub mod client;
pub mod server;
mod loops;