👕 refactor: making PTTH_QUIC more testable

main
(on company time) 2022-12-19 13:21:46 -06:00
parent 415c8954c1
commit 605c15468a
2 changed files with 13 additions and 6 deletions

View File

@ -18,14 +18,14 @@ use crate::prelude::*;
use protocol::PeerId;
#[derive (Debug, StructOpt)]
pub struct Opt {
pub (crate) struct Opt {
#[structopt (long)]
listen_addr: Option <String>,
pub (crate) listen_addr: Option <String>,
#[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 (endpoint, server_cert) = make_server_endpoint (listen_addr)?;

View File

@ -6,9 +6,16 @@ fn end_to_end () -> anyhow::Result <()> {
}
async fn end_to_end_async () -> anyhow::Result <()> {
use crate::executable_relay_server as relay;
// let task_relay = crate::executable_relay_server::main ();
let relay_opt = relay::Opt {
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 (())
}