adapt tun device to zerocopy (#57)

This commit is contained in:
Sijie.Sun
2024-04-25 23:25:37 +08:00
committed by GitHub
parent 3467890270
commit 57c9f11371
15 changed files with 405 additions and 150 deletions

View File

@@ -118,6 +118,13 @@ and the vpn client is in network of 10.14.14.0/24"
#[arg(long, help = "default protocol to use when connecting to peers")]
default_protocol: Option<String>,
#[arg(
long,
help = "use multi-thread runtime, default is single-thread",
default_value = "false"
)]
multi_thread: bool,
}
impl From<Cli> for TomlConfigLoader {
@@ -329,14 +336,8 @@ fn setup_panic_handler() {
}));
}
#[tokio::main(flavor = "current_thread")]
#[tracing::instrument]
pub async fn main() {
setup_panic_handler();
let cli = Cli::parse();
tracing::info!(cli = ?cli, "cli args parsed");
pub async fn async_main(cli: Cli) {
let cfg: TomlConfigLoader = cli.into();
init_logger(&cfg);
@@ -427,3 +428,24 @@ pub async fn main() {
inst.wait().await;
}
fn main() {
setup_panic_handler();
let cli = Cli::parse();
tracing::info!(cli = ?cli, "cli args parsed");
if cli.multi_thread {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(async move { async_main(cli).await })
} else {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async move { async_main(cli).await })
}
}