Browse Source

Squashed code beautifications

commit d5fdf845bf
Author: ssrlive <[email protected]>
Date:   Thu Mar 23 23:21:22 2023 +0800

    Update tun2proxy.rs

commit 2540daa423
Author: ssrlive <[email protected]>
Date:   Thu Mar 23 22:40:26 2023 +0800

    Update main.rs

commit 9ef5efb864
Author: ssrlive <[email protected]>
Date:   Thu Mar 23 22:19:06 2023 +0800

    Update main.rs

commit 017ea1a17a
Author: ssrlive <[email protected]>
Date:   Thu Mar 23 22:15:00 2023 +0800

    Update main.rs
pull/15/head
B. Blechschmidt 3 years ago
parent
commit
8be40a1fbd
  1. 5
      src/main.rs
  2. 16
      src/tun2proxy.rs

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

16
src/tun2proxy.rs

@ -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 {
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))
}
}

Loading…
Cancel
Save