mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-23 01:20:52 +00:00
Handle private IP addresses in setup
This commit is contained in:
parent
2a2b188c75
commit
76e0b6fe1d
2 changed files with 86 additions and 1 deletions
11
src/main.rs
11
src/main.rs
|
@ -1,5 +1,6 @@
|
|||
use clap::Parser;
|
||||
use env_logger::Env;
|
||||
use std::net::IpAddr;
|
||||
use std::process::ExitCode;
|
||||
|
||||
use tun2proxy::setup::{get_default_cidrs, Setup};
|
||||
|
@ -31,6 +32,10 @@ struct Args {
|
|||
/// Routing and system setup
|
||||
#[arg(short, long, value_name = "method", value_enum)]
|
||||
setup: Option<ArgSetup>,
|
||||
|
||||
/// Proxy IP as used in routing setup
|
||||
#[arg(long, value_name = "ip")]
|
||||
setup_ip: Option<IpAddr>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)]
|
||||
|
@ -60,7 +65,11 @@ fn main() -> ExitCode {
|
|||
|
||||
let mut setup: Setup;
|
||||
if args.setup == Some(ArgSetup::Auto) {
|
||||
setup = Setup::new(&args.tun, &args.proxy.addr.ip(), get_default_cidrs());
|
||||
let bypass_tun_ip = match args.setup_ip {
|
||||
Some(addr) => addr,
|
||||
None => args.proxy.addr.ip(),
|
||||
};
|
||||
setup = Setup::new(&args.tun, &bypass_tun_ip, get_default_cidrs());
|
||||
if let Err(e) = setup.setup() {
|
||||
log::error!("{e}");
|
||||
return ExitCode::FAILURE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue