mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-22 14:59:09 +00:00
This commit does two things: First, it implements a first, unfinished version of the virtual DNS functionality. This feature is incomplete and has known bugs. Since it needs to be enabled manually, this is not a huge issue so far. Second, the commit fixes a bug where TCP streams where not properly relayed, causing TCP connections to stall.
37 lines
1 KiB
Rust
37 lines
1 KiB
Rust
use clap::Parser;
|
|
use env_logger::Env;
|
|
|
|
use tun2proxy::tun2proxy::Options;
|
|
use tun2proxy::{main_entry, Proxy};
|
|
|
|
/// Tunnel interface to proxy
|
|
#[derive(Parser)]
|
|
#[command(author, version, about = "Tunnel interface to proxy.", long_about = None)]
|
|
struct Args {
|
|
/// Name of the tun interface
|
|
#[arg(short, long, value_name = "name", default_value = "tun0")]
|
|
tun: String,
|
|
|
|
/// The proxy URL in the form proto://[username[:password]@]host:port
|
|
#[arg(short, long = "proxy", value_parser = Proxy::from_url, value_name = "URL")]
|
|
proxy: Proxy,
|
|
|
|
#[arg(short, long = "dns")]
|
|
virtual_dns: bool,
|
|
}
|
|
|
|
fn main() {
|
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
|
let args = Args::parse();
|
|
|
|
let addr = args.proxy.addr;
|
|
let proxy_type = args.proxy.proxy_type;
|
|
log::info!("Proxy {proxy_type} server: {addr}");
|
|
|
|
let mut options = Options::new();
|
|
if args.virtual_dns {
|
|
options = options.with_virtual_dns();
|
|
}
|
|
|
|
main_entry(&args.tun, args.proxy, options);
|
|
}
|