👕 refactor: making PTTH_QUIC more testable
parent
415c8954c1
commit
605c15468a
|
@ -18,14 +18,14 @@ use crate::prelude::*;
|
||||||
use protocol::PeerId;
|
use protocol::PeerId;
|
||||||
|
|
||||||
#[derive (Debug, StructOpt)]
|
#[derive (Debug, StructOpt)]
|
||||||
pub struct Opt {
|
pub (crate) struct Opt {
|
||||||
#[structopt (long)]
|
#[structopt (long)]
|
||||||
listen_addr: Option <String>,
|
pub (crate) listen_addr: Option <String>,
|
||||||
#[structopt (long)]
|
#[structopt (long)]
|
||||||
tcp_listen_port: Option <u16>,
|
pub (crate) tcp_listen_port: Option <u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn main (opt: Opt) -> anyhow::Result <()>
|
pub (crate) async fn main (opt: Opt) -> anyhow::Result <()>
|
||||||
{
|
{
|
||||||
let listen_addr = opt.listen_addr.unwrap_or_else (|| String::from ("0.0.0.0:30380")).parse ()?;
|
let listen_addr = opt.listen_addr.unwrap_or_else (|| String::from ("0.0.0.0:30380")).parse ()?;
|
||||||
let (endpoint, server_cert) = make_server_endpoint (listen_addr)?;
|
let (endpoint, server_cert) = make_server_endpoint (listen_addr)?;
|
||||||
|
|
|
@ -6,9 +6,16 @@ fn end_to_end () -> anyhow::Result <()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn end_to_end_async () -> anyhow::Result <()> {
|
async fn end_to_end_async () -> anyhow::Result <()> {
|
||||||
|
use crate::executable_relay_server as relay;
|
||||||
|
|
||||||
|
let relay_opt = relay::Opt {
|
||||||
// let task_relay = crate::executable_relay_server::main ();
|
listen_addr: "127.0.0.1:30381".to_string ().into (),
|
||||||
|
tcp_listen_port: 8001.into (),
|
||||||
|
};
|
||||||
|
let task_relay = tokio::spawn (async move {
|
||||||
|
relay::main (relay_opt).await?;
|
||||||
|
Ok::<_, anyhow::Error> (())
|
||||||
|
});
|
||||||
|
|
||||||
Ok (())
|
Ok (())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue