diff --git a/src/main.rs b/src/main.rs index 02677a7..36ebf41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,10 +13,11 @@ struct Args { 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")] + #[arg(short, long, value_parser = Proxy::from_url, value_name = "URL")] proxy: Proxy, - #[arg(short, long = "dns")] + /// Enable virtual DNS feature + #[arg(short = 'd', long = "dns")] virtual_dns: bool, } diff --git a/src/tun2proxy.rs b/src/tun2proxy.rs index de27c2c..e61170b 100644 --- a/src/tun2proxy.rs +++ b/src/tun2proxy.rs @@ -48,15 +48,13 @@ pub(crate) struct Destination { impl TryFrom for SocketAddr { type Error = Error; fn try_from(value: Destination) -> Result { - Ok(SocketAddr::new( - match value.host { - DestinationHost::Address(addr) => addr, - Hostname(e) => { - return Err(e.into()); - } - }, - value.port, - )) + let ip = match value.host { + DestinationHost::Address(addr) => addr, + Hostname(e) => { + return Err(e.into()); + } + }; + Ok(SocketAddr::new(ip, value.port)) } }