mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 08:30:53 +00:00
Squashed code beautifications
commitd5fdf845bf
Author: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu Mar 23 23:21:22 2023 +0800 Update tun2proxy.rs commit2540daa423
Author: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu Mar 23 22:40:26 2023 +0800 Update main.rs commit9ef5efb864
Author: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu Mar 23 22:19:06 2023 +0800 Update main.rs commit017ea1a17a
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:
parent
d13c7ff61b
commit
8be40a1fbd
2 changed files with 10 additions and 11 deletions
|
@ -13,10 +13,11 @@ struct Args {
|
||||||
tun: String,
|
tun: String,
|
||||||
|
|
||||||
/// The proxy URL in the form proto://[username[:password]@]host:port
|
/// 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,
|
proxy: Proxy,
|
||||||
|
|
||||||
#[arg(short, long = "dns")]
|
/// Enable virtual DNS feature
|
||||||
|
#[arg(short = 'd', long = "dns")]
|
||||||
virtual_dns: bool,
|
virtual_dns: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,15 +48,13 @@ pub(crate) struct Destination {
|
||||||
impl TryFrom<Destination> for SocketAddr {
|
impl TryFrom<Destination> for SocketAddr {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(value: Destination) -> Result<Self, Self::Error> {
|
fn try_from(value: Destination) -> Result<Self, Self::Error> {
|
||||||
Ok(SocketAddr::new(
|
let ip = match value.host {
|
||||||
match value.host {
|
DestinationHost::Address(addr) => addr,
|
||||||
DestinationHost::Address(addr) => addr,
|
Hostname(e) => {
|
||||||
Hostname(e) => {
|
return Err(e.into());
|
||||||
return Err(e.into());
|
}
|
||||||
}
|
};
|
||||||
},
|
Ok(SocketAddr::new(ip, value.port))
|
||||||
value.port,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue