Squashed code beautifications

commit d5fdf845bf
Author: ssrlive <30760636+ssrlive@users.noreply.github.com>
Date:   Thu Mar 23 23:21:22 2023 +0800

    Update tun2proxy.rs

commit 2540daa423
Author: ssrlive <30760636+ssrlive@users.noreply.github.com>
Date:   Thu Mar 23 22:40:26 2023 +0800

    Update main.rs

commit 9ef5efb864
Author: ssrlive <30760636+ssrlive@users.noreply.github.com>
Date:   Thu Mar 23 22:19:06 2023 +0800

    Update main.rs

commit 017ea1a17a
Author: ssrlive <30760636+ssrlive@users.noreply.github.com>
Date:   Thu Mar 23 22:15:00 2023 +0800

    Update main.rs
This commit is contained in:
B. Blechschmidt 2023-03-23 18:01:25 +01:00
parent d13c7ff61b
commit 8be40a1fbd
2 changed files with 10 additions and 11 deletions

View file

@ -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,
}

View file

@ -48,15 +48,13 @@ pub(crate) struct Destination {
impl TryFrom<Destination> for SocketAddr {
type Error = Error;
fn try_from(value: Destination) -> Result<Self, Self::Error> {
Ok(SocketAddr::new(
match value.host {
let ip = match value.host {
DestinationHost::Address(addr) => addr,
Hostname(e) => {
return Err(e.into());
}
},
value.port,
))
};
Ok(SocketAddr::new(ip, value.port))
}
}