Skip to content

Commit 8dfc2a3

Browse files
committed
completely removed unix socket based DNS resolving
ref shadowsocks/shadowsocks-android#2622
1 parent 4cf5473 commit 8dfc2a3

File tree

11 files changed

+82
-377
lines changed

11 files changed

+82
-377
lines changed

bin/common/validator/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use std::net::SocketAddr;
66

7-
#[cfg(feature = "local-dns")]
8-
use shadowsocks_service::config::NameServerAddr;
97
use shadowsocks_service::shadowsocks::{relay::socks5::Address, ManagerAddr, ServerAddr, ServerConfig};
108

119
macro_rules! validate_type {
@@ -31,12 +29,6 @@ validate_type!(
3129
ManagerAddr,
3230
"should be either ip:port, domain:port or /path/to/unix.sock"
3331
);
34-
#[cfg(feature = "local-dns")]
35-
validate_type!(
36-
validate_name_server_addr,
37-
NameServerAddr,
38-
"should be either ip:port, domain:port or /path/to/unix.sock"
39-
);
4032
validate_type!(validate_u64, u64, "should be unsigned integer");
4133
validate_type!(validate_u32, u32, "should be unsigned integer");
4234

bin/sslocal.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn main() {
142142
#[cfg(feature = "local-dns")]
143143
{
144144
app = clap_app!(@app (app)
145-
(@arg LOCAL_DNS_ADDR: --("local-dns-addr") +takes_value required_if("PROTOCOL", "dns") {validator::validate_name_server_addr} "Specify the address of local DNS server, send queries directly")
145+
(@arg LOCAL_DNS_ADDR: --("local-dns-addr") +takes_value required_if("PROTOCOL", "dns") {validator::validate_socket_addr} "Specify the address of local DNS server, send queries directly")
146146
(@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")
147147
(@arg DNS_LOCAL_ADDR: --("dns-addr") +takes_value requires_all(&["REMOTE_DNS_ADDR"]) {validator::validate_server_addr} "DNS address, listen to this address if specified")
148148
);
@@ -240,10 +240,10 @@ fn main() {
240240

241241
#[cfg(feature = "local-dns")]
242242
{
243-
use shadowsocks_service::config::NameServerAddr;
243+
use std::net::SocketAddr;
244244

245245
if let Some(local_dns_addr) = matches.value_of("LOCAL_DNS_ADDR") {
246-
let addr = local_dns_addr.parse::<NameServerAddr>().expect("local dns address");
246+
let addr = local_dns_addr.parse::<SocketAddr>().expect("local dns address");
247247
config.local_dns_addr = Some(addr);
248248
}
249249

@@ -263,12 +263,6 @@ fn main() {
263263
// A socket `protect_path` in CWD
264264
// Same as shadowsocks-libev's android.c
265265
config.outbound_vpn_protect_path = Some(From::from("protect_path"));
266-
267-
// Set default config.local_dns_addr
268-
#[cfg(feature = "local-dns")]
269-
if config.local_dns_addr.is_none() {
270-
config.local_dns_addr = Some(From::from("local_dns_path"));
271-
}
272266
}
273267

274268
if let Some(local_addr) = matches.value_of("LOCAL_ADDR") {

crates/shadowsocks-service/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dns-over-tls = ["trust-dns", "trust-dns-resolver/dns-over-tls", "trust-dns-resol
4242
dns-over-https = ["trust-dns", "trust-dns-resolver/dns-over-https"]
4343

4444
# Enable DNS-relay
45-
local-dns = ["local", "trust-dns-proto", "rand"]
45+
local-dns = ["local", "trust-dns", "trust-dns-proto", "rand"]
4646
# Backward compatibility, DO NOT USE
4747
local-dns-relay = ["local-dns"]
4848
# Enable client flow statistic report

crates/shadowsocks-service/src/config.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ use shadowsocks::{
7070
use trust_dns_resolver::config::{NameServerConfig, Protocol, ResolverConfig};
7171

7272
use crate::acl::AccessControl;
73-
#[cfg(feature = "local-dns")]
74-
pub use crate::local::dns::config::NameServerAddr;
7573

7674
#[cfg(feature = "trust-dns")]
7775
#[derive(Serialize, Deserialize, Debug)]
@@ -576,7 +574,7 @@ pub struct Config {
576574
///
577575
/// Sending DNS query directly to this address
578576
#[cfg(feature = "local-dns")]
579-
pub local_dns_addr: Option<NameServerAddr>,
577+
pub local_dns_addr: Option<SocketAddr>,
580578
/// Remote DNS's address
581579
///
582580
/// Sending DNS query through proxy to this address

crates/shadowsocks-service/src/local/dns/client_cache.rs

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl DnsClientCache {
121121
}
122122

123123
#[cfg(unix)]
124+
#[allow(dead_code)]
124125
pub async fn lookup_unix_stream<P: AsRef<Path>>(&self, ns: &P, msg: Message) -> Result<Message, ProtoError> {
125126
let mut last_err = None;
126127

crates/shadowsocks-service/src/local/dns/config.rs

-67
This file was deleted.

crates/shadowsocks-service/src/local/dns/dns_resolver.rs

-220
This file was deleted.

crates/shadowsocks-service/src/local/dns/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
pub use self::server::Dns;
44

55
mod client_cache;
6-
pub mod config;
7-
pub mod dns_resolver;
86
pub mod server;
97
mod upstream;

0 commit comments

Comments
 (0)