mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 16:14:11 +00:00
ignore mode in local-dns local resolver
ref shadowsocks/shadowsocks-android#2635
This commit is contained in:
Generated
+3
-3
@@ -2061,7 +2061,7 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
|
||||
[[package]]
|
||||
name = "trust-dns-proto"
|
||||
version = "0.20.0-alpha.3"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#540906be77b03dc59494aef453b2dbcc875a2a0a"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cfg-if 1.0.0",
|
||||
@@ -2085,7 +2085,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trust-dns-resolver"
|
||||
version = "0.20.0-alpha.3"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#540906be77b03dc59494aef453b2dbcc875a2a0a"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"futures-util",
|
||||
@@ -2109,7 +2109,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trust-dns-rustls"
|
||||
version = "0.20.0-alpha.3"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#540906be77b03dc59494aef453b2dbcc875a2a0a"
|
||||
source = "git+https://github.com/bluejekyll/trust-dns.git?branch=main#57245de7d73008c9f960ba8c952e2dbcee54bb84"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-io",
|
||||
|
||||
@@ -678,36 +678,28 @@ impl DnsClient {
|
||||
message.set_recursion_desired(true);
|
||||
message.add_query(query.clone());
|
||||
|
||||
let mut last_err = io::Error::new(ErrorKind::InvalidData, "resolve empty");
|
||||
|
||||
// Query UDP then TCP
|
||||
|
||||
if self.mode.enable_udp() {
|
||||
match self
|
||||
.client_cache
|
||||
.lookup_udp_local(local_addr, message.clone(), self.context.connect_opts_ref())
|
||||
.await
|
||||
{
|
||||
Ok(msg) => return Ok(msg),
|
||||
Err(err) => {
|
||||
last_err = err.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
let udp_query =
|
||||
self.client_cache
|
||||
.lookup_udp_local(local_addr, message.clone(), self.context.connect_opts_ref());
|
||||
let tcp_query = async move {
|
||||
// Send TCP query after 500ms, because UDP will always return faster than TCP, there is no need to send queries simutaneously
|
||||
time::sleep(Duration::from_millis(500)).await;
|
||||
|
||||
if self.mode.enable_tcp() {
|
||||
match self
|
||||
.client_cache
|
||||
self.client_cache
|
||||
.lookup_tcp_local(local_addr, message, self.context.connect_opts_ref())
|
||||
.await
|
||||
{
|
||||
Ok(msg) => return Ok(msg),
|
||||
Err(err) => {
|
||||
last_err = err.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Err(last_err)
|
||||
tokio::pin!(udp_query);
|
||||
tokio::pin!(tcp_query);
|
||||
|
||||
match future::select(udp_query, tcp_query).await {
|
||||
Either::Left((Ok(m), ..)) => Ok(m),
|
||||
Either::Left((Err(..), next)) => next.await.map_err(From::from),
|
||||
Either::Right((Ok(m), ..)) => Ok(m),
|
||||
Either::Right((Err(..), next)) => next.await.map_err(From::from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user