Only include setup feature on Linux

This commit is contained in:
B. Blechschmidt 2023-04-10 20:59:54 +02:00
parent b669b9de22
commit cb1babebd4
2 changed files with 22 additions and 15 deletions

View file

@ -5,10 +5,12 @@ use std::net::IpAddr;
use std::process::ExitCode;
use tun2proxy::error::Error;
use tun2proxy::setup::{get_default_cidrs, Setup};
use tun2proxy::Options;
use tun2proxy::{main_entry, Proxy};
#[cfg(target_os = "linux")]
use tun2proxy::setup::{get_default_cidrs, Setup};
/// Tunnel interface to proxy
#[derive(Parser)]
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
@ -66,6 +68,8 @@ fn main() -> ExitCode {
}
if let Err(e) = (|| -> Result<(), Error> {
#[cfg(target_os = "linux")]
{
let mut setup: Setup;
if args.setup == Some(ArgSetup::Auto) {
let bypass_tun_ip = match args.setup_ip {
@ -83,6 +87,7 @@ fn main() -> ExitCode {
setup.drop_privileges()?;
}
}
main_entry(&args.tun, &args.proxy, options)?;

View file

@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]
use crate::error::Error;
use smoltcp::wire::IpCidr;
use std::convert::TryFrom;