allow set routes manually and disable propagated routes (#191)

This commit is contained in:
Sijie.Sun
2024-07-24 22:45:55 +08:00
committed by GitHub
parent fc9812dd54
commit 5451b52daa
4 changed files with 73 additions and 8 deletions

View File

@@ -215,6 +215,14 @@ and the vpn client is in network of 10.14.14.0/24"
default_value = "false"
)]
use_smoltcp: bool,
#[arg(
long,
help = "assign routes cidr manually, will disable subnet proxy and
wireguard routes propogated from peers. e.g.: 192.168.0.0/16",
num_args = 0..
)]
manual_routes: Option<Vec<String>>,
}
impl Cli {
@@ -420,6 +428,21 @@ impl From<Cli> for TomlConfigLoader {
});
}
if cli.manual_routes.is_some() {
cfg.set_routes(Some(
cli.manual_routes
.clone()
.unwrap()
.iter()
.map(|s| {
s.parse()
.with_context(|| format!("failed to parse route: {}", s))
.unwrap()
})
.collect(),
));
}
let mut f = cfg.get_flags();
if cli.default_protocol.is_some() {
f.default_protocol = cli.default_protocol.as_ref().unwrap().clone();
@@ -532,6 +555,10 @@ pub async fn async_main(cli: Cli) {
print_event(format!("tun device ready. dev: {}", dev));
}
GlobalCtxEvent::TunDeviceError(err) => {
print_event(format!("tun device error. err: {}", err));
}
GlobalCtxEvent::Connecting(dst) => {
print_event(format!("connecting to peer. dst: {}", dst));
}