Skip to content

Commit

Permalink
Remove the reuse for UNIX stream DNS lookup.
Browse files Browse the repository at this point in the history
Our UNIX stream based DNS lookup doesn't support connection reuse.
  • Loading branch information
Max Lv committed Jul 6, 2021
1 parent e32c869 commit c8fc85c
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions crates/shadowsocks-service/src/local/dns/client_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DNS Client cache

#[cfg(unix)]
use std::path::{Path, PathBuf};
use std::path::Path;
use std::{
collections::{hash_map::Entry, HashMap, VecDeque},
future::Future,
Expand All @@ -23,8 +23,6 @@ use super::upstream::DnsClient;
enum DnsClientKey {
TcpLocal(SocketAddr),
UdpLocal(SocketAddr),
#[cfg(unix)]
UnixStream(PathBuf),
TcpRemote(Address),
UdpRemote(Address),
}
Expand Down Expand Up @@ -124,12 +122,8 @@ impl DnsClientCache {
pub async fn lookup_unix_stream<P: AsRef<Path>>(&self, ns: &P, msg: Message) -> Result<Message, ProtoError> {
let mut last_err = None;

let key = DnsClientKey::UnixStream(ns.as_ref().to_path_buf());
for _ in 0..self.retry_count {
let mut client = match self
.get_client_or_create(&key, async { DnsClient::connect_unix_stream(ns).await })
.await
{
let mut client = match DnsClient::connect_unix_stream(ns).await {
Ok(client) => client,
Err(err) => {
last_err = Some(From::from(err));
Expand All @@ -145,8 +139,6 @@ impl DnsClientCache {
}
};

self.save_client(key, client).await;

return Ok(res);
}

Expand Down

0 comments on commit c8fc85c

Please sign in to comment.