Skip to content

Commit

Permalink
chore(shadowsocks): renamed TrustDns to HickoryDns
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Nov 3, 2023
1 parent fec498f commit 82b523c
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions crates/shadowsocks/src/dns_resolver/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub trait DnsResolve {
}

#[cfg(feature = "hickory-dns")]
pub struct TrustDnsSystemResolver {
pub struct HickoryDnsSystemResolver {
resolver: ArcSwap<HickoryDnsResolver>,
#[cfg_attr(windows, allow(dead_code))]
connect_opts: ConnectOpts,
Expand All @@ -53,14 +53,14 @@ pub enum DnsResolver {
System,
/// Trust-DNS's system resolver
#[cfg(feature = "hickory-dns")]
TrustDnsSystem {
inner: Arc<TrustDnsSystemResolver>,
HickoryDnsSystem {
inner: Arc<HickoryDnsSystemResolver>,
#[cfg(all(feature = "hickory-dns", unix, not(target_os = "android")))]
abortable: JoinHandle<()>,
},
/// Trust-DNS resolver
#[cfg(feature = "hickory-dns")]
TrustDns(HickoryDnsResolver),
HickoryDns(HickoryDnsResolver),
/// Customized Resolver
Custom(Box<dyn DnsResolve + Send + Sync>),
}
Expand All @@ -76,9 +76,9 @@ impl Debug for DnsResolver {
match *self {
DnsResolver::System => f.write_str("System"),
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDnsSystem { .. } => f.write_str("TrustDnsSystem(..)"),
DnsResolver::HickoryDnsSystem { .. } => f.write_str("HickoryDnsSystem(..)"),
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDns(..) => f.write_str("TrustDns(..)"),
DnsResolver::HickoryDns(..) => f.write_str("HickoryDns(..)"),
DnsResolver::Custom(..) => f.write_str("Custom(..)"),
}
}
Expand All @@ -88,7 +88,7 @@ impl Debug for DnsResolver {
impl Drop for DnsResolver {
fn drop(&mut self) {
#[cfg(all(feature = "hickory-dns", unix, not(target_os = "android")))]
if let DnsResolver::TrustDnsSystem { ref abortable, .. } = *self {
if let DnsResolver::HickoryDnsSystem { ref abortable, .. } = *self {
abortable.abort();
}
}
Expand All @@ -99,8 +99,8 @@ cfg_if! {
/// Resolved result
enum EitherResolved<A, B, C, D> {
Tokio(A),
TrustDnsSystem(B),
TrustDns(C),
HickoryDnsSystem(B),
HickoryDns(C),
Custom(D),
}

Expand All @@ -116,8 +116,8 @@ cfg_if! {
fn next(&mut self) -> Option<SocketAddr> {
match *self {
EitherResolved::Tokio(ref mut a) => a.next(),
EitherResolved::TrustDnsSystem(ref mut b) => b.next(),
EitherResolved::TrustDns(ref mut c) => c.next(),
EitherResolved::HickoryDnsSystem(ref mut b) => b.next(),
EitherResolved::HickoryDns(ref mut c) => c.next(),
EitherResolved::Custom(ref mut d) => d.next(),
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ cfg_if! {
}

#[cfg(all(feature = "hickory-dns", unix, not(target_os = "android")))]
async fn hickory_dns_notify_update_dns(resolver: Arc<TrustDnsSystemResolver>) -> notify::Result<()> {
async fn hickory_dns_notify_update_dns(resolver: Arc<HickoryDnsSystemResolver>) -> notify::Result<()> {
use std::{path::Path, time::Duration};

use log::debug;
Expand Down Expand Up @@ -239,7 +239,7 @@ impl DnsResolver {

let resolver = create_resolver(None, opts.clone(), connect_opts.clone()).await?;

let inner = Arc::new(TrustDnsSystemResolver {
let inner = Arc::new(HickoryDnsSystemResolver {
resolver: ArcSwap::from(Arc::new(resolver)),
connect_opts,
opts,
Expand All @@ -256,9 +256,9 @@ impl DnsResolver {
})
};

Ok(DnsResolver::TrustDnsSystem { inner, abortable })
Ok(DnsResolver::HickoryDnsSystem { inner, abortable })
} else {
Ok(DnsResolver::TrustDnsSystem { inner })
Ok(DnsResolver::HickoryDnsSystem { inner })
}
}
}
Expand All @@ -271,7 +271,7 @@ impl DnsResolver {
connect_opts: ConnectOpts,
) -> io::Result<DnsResolver> {
use super::hickory_dns_resolver::create_resolver;
Ok(DnsResolver::TrustDns(
Ok(DnsResolver::HickoryDns(
create_resolver(Some(dns), opts, connect_opts).await?,
))
}
Expand Down Expand Up @@ -328,7 +328,7 @@ impl DnsResolver {
);
}
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDnsSystem { .. } | DnsResolver::TrustDns(..) => {
DnsResolver::HickoryDnsSystem { .. } | DnsResolver::HickoryDns(..) => {
trace!(
"DNS resolved {}:{} with hickory-dns {}s",
self.addr,
Expand All @@ -351,7 +351,7 @@ impl DnsResolver {
trace!("DNS resolved {}:{} with tokio", self.addr, self.port);
}
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDnsSystem { .. } | DnsResolver::TrustDns(..) => {
DnsResolver::HickoryDnsSystem { .. } | DnsResolver::HickoryDns(..) => {
trace!("DNS resolved {}:{} with hickory-dns", self.addr, self.port);
}
DnsResolver::Custom(..) => {
Expand All @@ -373,8 +373,8 @@ impl DnsResolver {
}
},
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDnsSystem { ref inner, .. } => match inner.resolver.load().lookup_ip(addr).await {
Ok(lookup_result) => Ok(EitherResolved::TrustDnsSystem(
DnsResolver::HickoryDnsSystem { ref inner, .. } => match inner.resolver.load().lookup_ip(addr).await {
Ok(lookup_result) => Ok(EitherResolved::HickoryDnsSystem(
lookup_result.into_iter().map(move |ip| SocketAddr::new(ip, port)),
)),
Err(err) => {
Expand All @@ -383,8 +383,8 @@ impl DnsResolver {
}
},
#[cfg(feature = "hickory-dns")]
DnsResolver::TrustDns(ref resolver) => match resolver.lookup_ip(addr).await {
Ok(lookup_result) => Ok(EitherResolved::TrustDns(
DnsResolver::HickoryDns(ref resolver) => match resolver.lookup_ip(addr).await {
Ok(lookup_result) => Ok(EitherResolved::HickoryDns(
lookup_result.into_iter().map(move |ip| SocketAddr::new(ip, port)),
)),
Err(err) => {
Expand Down

0 comments on commit 82b523c

Please sign in to comment.