support exit node (#121)

support exit node, proxy all traffic via one of node
NOTE: this patch has not implemented automatically route management.
This commit is contained in:
Sijie.Sun
2024-05-18 20:32:42 +08:00
committed by GitHub
parent 6efbb5cb3d
commit f64f58e2ae
8 changed files with 88 additions and 8 deletions

View File

@@ -3,7 +3,12 @@
#[cfg(test)]
mod tests;
use std::{backtrace, io::Write as _, net::SocketAddr, path::PathBuf};
use std::{
backtrace,
io::Write as _,
net::{Ipv4Addr, SocketAddr},
path::PathBuf,
};
use anyhow::Context;
use clap::Parser;
@@ -179,6 +184,20 @@ and the vpn client is in network of 10.14.14.0/24"
default_value = "false"
)]
latency_first: bool,
#[arg(
long,
help = "exit nodes to forward all traffic to, a virtual ipv4 address, priority is determined by the order of the list",
num_args = 0..
)]
exit_nodes: Vec<Ipv4Addr>,
#[arg(
long,
help = "allow this node to be an exit node, default is false",
default_value = "false"
)]
enable_exit_node: bool,
}
impl Cli {
@@ -394,8 +413,11 @@ impl From<Cli> for TomlConfigLoader {
if let Some(mtu) = cli.mtu {
f.mtu = mtu;
}
f.enable_exit_node = cli.enable_exit_node;
cfg.set_flags(f);
cfg.set_exit_nodes(cli.exit_nodes.clone());
cfg
}
}