Fixed sslocal dns-addr local-dns-addr and remote-dns-addr requirements

This commit is contained in:
zonyitoo
2020-11-15 14:23:21 +08:00
committed by ty
parent ca7958b0f1
commit 19d3129cd0
3 changed files with 5 additions and 14 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ fn main() {
app = clap_app!(@app (app)
(@arg LOCAL_DNS_ADDR: --("local-dns-addr") +takes_value required_if("PROTOCOL", "dns") {validator::validate_local_dns_addr} "Specify the address of local DNS server, send queries directly")
(@arg REMOTE_DNS_ADDR: --("remote-dns-addr") +takes_value required_if("PROTOCOL", "dns") {validator::validate_address} "Specify the address of remote DNS server, send queries through shadowsocks' tunnel")
(@arg DNS_LOCAL_ADDR: --("dns-addr") +takes_value {validator::validate_server_addr} "DNS address, listen to this address if specified")
(@arg DNS_LOCAL_ADDR: --("dns-addr") +takes_value requires_all(&["LOCAL_DNS_ADDR", "REMOTE_DNS_ADDR"]) {validator::validate_server_addr} "DNS address, listen to this address if specified")
);
}
+1 -11
View File
@@ -1640,17 +1640,7 @@ impl Config {
/// Check if DNS Relay is enabled
#[cfg(feature = "local-dns")]
pub(crate) fn is_local_dns_relay(&self) -> bool {
if self.config_type == ConfigType::DnsLocal || self.local_dns_addr.is_some() {
return true;
}
cfg_if! {
if #[cfg(target_os = "android")] {
self.local_dns_path.is_some()
} else {
false
}
}
self.config_type == ConfigType::DnsLocal || self.dns_bind_addr.is_some()
}
}
+3 -2
View File
@@ -194,6 +194,7 @@ impl<Remote: upstream::Upstream> DnsRelay<Remote> {
let acl = self.context.acl();
let local = self.context.local_dns();
let remote = &self.remote_upstream;
// Start querying name servers
debug!(
"attempting lookup of {:?} {} with ns {:?} and {:?}",
@@ -355,14 +356,14 @@ async fn run_udp<Remote: upstream::Upstream + Send + Sync + 'static>(
}
};
debug!("received src: {}, query: {:?}", src, request);
trace!("DNS query from {}, {:?}", src, request);
let relay = relay.clone();
let tx = tx.clone();
tokio::spawn(async move {
let message = relay.resolve(request).await;
debug!("DNS src: {}, final response: {:?}", src, message);
trace!("DNS response to {}, {:?}", src, message);
match message.to_vec() {
Err(err) => {