diff --git a/echoip_test.toml b/echoip_test.toml index 0ae7830..f8eae8e 100644 --- a/echoip_test.toml +++ b/echoip_test.toml @@ -28,6 +28,9 @@ allow_reverse_lookup = true # that end with one of these suffixes don't exist hidden_suffixes = [".com"] +# doesn't really work 🙁 +search = ["org","net"] + [geoip] # Path to geoip databses # Currently only the mmdb format is supported diff --git a/src/config/dns.rs b/src/config/dns.rs index b776f92..1bd64ce 100644 --- a/src/config/dns.rs +++ b/src/config/dns.rs @@ -88,7 +88,10 @@ impl Into for DnsProtocol { } impl DnsResolverConfig { - pub fn to_trust_resolver_config(&self) -> trust_dns_resolver::config::ResolverConfig { + pub fn to_trust_resolver_config( + &self, + additional_search: &Vec, + ) -> trust_dns_resolver::config::ResolverConfig { let mut resolver = trust_dns_resolver::config::ResolverConfig::new(); for server in &self.servers { resolver.add_name_server(trust_dns_resolver::config::NameServerConfig{ @@ -105,6 +108,11 @@ impl DnsResolverConfig { resolver.add_search(name); } } + for search in additional_search { + if let Ok(name) = Name::from_str_relaxed(search) { + resolver.add_search(name); + } + } return resolver; } } diff --git a/src/main.rs b/src/main.rs index 62b0fee..761cc27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -258,7 +258,7 @@ async fn main() { for (key, resolver_config) in &config.dns.resolver { println!("Initalizing {} resolver ...", key); let resolver = TokioAsyncResolver::tokio( - resolver_config.to_trust_resolver_config(), + resolver_config.to_trust_resolver_config(&config.dns.search), Default::default() ).unwrap(); dns_resolver_map.insert(key.clone(), resolver);