Implemented global search config

This commit is contained in:
Slatian 2023-08-06 01:42:49 +02:00
parent fef954f6c1
commit cf806ad8f5
3 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -88,7 +88,10 @@ impl Into<Protocol> 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<String>,
) -> 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;
}
}

View File

@ -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);