parent
963631ff96
commit
fd3c85fccd
|
@ -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 (())
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
pub mod client;
|
||||||
|
pub mod server;
|
||||||
|
|
||||||
|
mod loops;
|
Loading…
Reference in New Issue