Skip to content

Commit

Permalink
feat: cli option to disable tun
Browse files Browse the repository at this point in the history
  • Loading branch information
XOR-op committed Jul 2, 2024
1 parent e465c31 commit 8027681
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion boltconn/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl App {
config_path: PathBuf,
data_path: PathBuf,
cert_path: PathBuf,
enable_tun: Option<bool>,
) -> anyhow::Result<Self> {
// tracing
let stream_logger = StreamLoggerSend::new();
Expand Down Expand Up @@ -129,6 +130,7 @@ impl App {
};

// Create TUN
let will_enable_tun = enable_tun.unwrap_or(config.inbound.enable_tun);
let (tun_udp_tx, tun_udp_rx) = flume::bounded(4096);
let (udp_tun_tx, udp_tun_rx) = flume::bounded(4096);
let tun = {
Expand All @@ -154,7 +156,7 @@ impl App {
fake_dns_server,
tun.get_name(),
)));
if config.inbound.enable_tun {
if will_enable_tun {
tun_configure
.lock()
.unwrap()
Expand Down
2 changes: 2 additions & 0 deletions boltconn/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub(crate) struct StartOptions {
/// Path of certificate. Default to ${app_data}/cert
#[arg(long)]
pub cert: Option<PathBuf>,
#[arg(short = 't', long = "tun")]
pub enable_tun: Option<bool>,
}

#[derive(Debug, Args)]
Expand Down
7 changes: 6 additions & 1 deletion boltconn/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ fn main() -> ExitCode {
);
return ExitCode::FAILURE;
}
let app = match rt.block_on(App::create(config_path, data_path, cert_path)) {
let app = match rt.block_on(App::create(
config_path,
data_path,
cert_path,
cmds.enable_tun,
)) {
Ok(app) => app,
Err(e) => {
eprintln!("{e}");
Expand Down

0 comments on commit 8027681

Please sign in to comment.