mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-23 07:19:08 +00:00
Only include setup feature on Linux
This commit is contained in:
parent
b669b9de22
commit
cb1babebd4
2 changed files with 22 additions and 15 deletions
35
src/main.rs
35
src/main.rs
|
@ -5,10 +5,12 @@ use std::net::IpAddr;
|
||||||
use std::process::ExitCode;
|
use std::process::ExitCode;
|
||||||
|
|
||||||
use tun2proxy::error::Error;
|
use tun2proxy::error::Error;
|
||||||
use tun2proxy::setup::{get_default_cidrs, Setup};
|
|
||||||
use tun2proxy::Options;
|
use tun2proxy::Options;
|
||||||
use tun2proxy::{main_entry, Proxy};
|
use tun2proxy::{main_entry, Proxy};
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use tun2proxy::setup::{get_default_cidrs, Setup};
|
||||||
|
|
||||||
/// Tunnel interface to proxy
|
/// Tunnel interface to proxy
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
|
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
|
||||||
|
@ -66,22 +68,25 @@ fn main() -> ExitCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = (|| -> Result<(), Error> {
|
if let Err(e) = (|| -> Result<(), Error> {
|
||||||
let mut setup: Setup;
|
#[cfg(target_os = "linux")]
|
||||||
if args.setup == Some(ArgSetup::Auto) {
|
{
|
||||||
let bypass_tun_ip = match args.setup_ip {
|
let mut setup: Setup;
|
||||||
Some(addr) => addr,
|
if args.setup == Some(ArgSetup::Auto) {
|
||||||
None => args.proxy.addr.ip(),
|
let bypass_tun_ip = match args.setup_ip {
|
||||||
};
|
Some(addr) => addr,
|
||||||
setup = Setup::new(
|
None => args.proxy.addr.ip(),
|
||||||
&args.tun,
|
};
|
||||||
&bypass_tun_ip,
|
setup = Setup::new(
|
||||||
get_default_cidrs(),
|
&args.tun,
|
||||||
args.setup_ip.is_some(),
|
&bypass_tun_ip,
|
||||||
);
|
get_default_cidrs(),
|
||||||
|
args.setup_ip.is_some(),
|
||||||
|
);
|
||||||
|
|
||||||
setup.configure()?;
|
setup.configure()?;
|
||||||
|
|
||||||
setup.drop_privileges()?;
|
setup.drop_privileges()?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_entry(&args.tun, &args.proxy, options)?;
|
main_entry(&args.tun, &args.proxy, options)?;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![cfg(target_os = "linux")]
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use smoltcp::wire::IpCidr;
|
use smoltcp::wire::IpCidr;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
Loading…
Add table
Reference in a new issue