Added aliases and some servers to test them

This commit is contained in:
Slatian 2023-08-06 01:19:02 +02:00
parent a334eb428a
commit e7eba57cb2
2 changed files with 38 additions and 12 deletions

View File

@ -85,18 +85,37 @@ tls_dns_name = "dns.quad9.net"
display_name = "Quad9 with ecs"
info_url = "https://www.quad9.net/service/service-addresses-and-features/"
aliases = ["q9ecs","9999ecs","ecs"]
weight = 980
weight = 970
servers = ["9.9.9.11:853", "149.112.112.11:853", "[2620:fe::fe:11]:853", "[2620:fe::11]:853"]
protocol = "tls"
tls_dns_name = "dns11.quad9.net"
[dns.resolver.quad9_unvalidated]
display_name = "Quad9 Unvalidated"
display_name = "Quad9 unvalidated"
info_url = "https://www.quad9.net/service/service-addresses-and-features/"
aliases = ["q9u","9999u"]
weight = 980
weight = 960
servers = ["9.9.9.10:853", "149.112.112.10:853", "[2620:fe::fe:10]:853", "[2620:fe::10]:853"]
protocol = "tls"
tls_dns_name = "dns10.quad9.net"
[dns.resolver.cloudflare]
display_name = "Cloudflare"
info_url = "https://www.cloudflare.com/dns/"
aliases = ["cf","1111"]
weight = 450
servers = ["1.1.1.1:853", "1.0.0.1:853", "[2606:4700:4700::1111]:853", "[2606:4700:4700::1001]:853"]
protocol = "tls"
tls_dns_name = "cloudflare-dns.com"
[dns.resolver.google]
display_name = "Google"
info_url = "https://www.cloudflare.com/dns/"
aliases = ["goo","8888"]
weight = 440
servers = ["8.8.8.8:53", "8.4.4.8:53", "[2001:4860:4860::8888]:53", "[2001:4860:4860::8844]:53"]
protocol = "udp"

View File

@ -94,6 +94,7 @@ pub struct DigResult {
struct ServiceSharedState {
templating_engine: templating_engine::Engine,
dns_resolvers: HashMap<String,TokioAsyncResolver>,
dns_resolver_aliases: HashMap<String,String>,
asn_db: geoip::MMDBCarrier,
location_db: geoip::MMDBCarrier,
config: config::EchoIpServiceConfig,
@ -233,6 +234,7 @@ async fn main() {
let mut dns_resolver_selectables = Vec::<Selectable>::new();
let mut dns_resolver_map: HashMap<String,TokioAsyncResolver> = HashMap::new();
let mut dns_resolver_aliases: HashMap<String,String> = HashMap::new();
if config.dns.enable_system_resolver {
println!("Initalizing System resolver ...");
@ -265,6 +267,9 @@ async fn main() {
name: resolver_config.display_name.clone(),
weight: resolver_config.weight,
});
for alias in &resolver_config.aliases {
dns_resolver_aliases.insert(alias.clone(),key.clone());
}
}
let listen_on = config.server.listen_on;
@ -274,8 +279,8 @@ async fn main() {
let shared_state = Arc::new(
ServiceSharedState {
templating_engine: templating_engine,
//dns_resolver: dns_resolver,
dns_resolvers: dns_resolver_map,
dns_resolver_aliases: dns_resolver_aliases,
asn_db: asn_db,
location_db: location_db,
config: config.clone(),
@ -491,6 +496,8 @@ async fn handle_search_request(
let state = Arc::clone(&arc_state);
if state.dns_resolvers.contains_key(&via) {
settings.dns_resolver_id = via;
} else if let Some(alias) = state.dns_resolver_aliases.get(&via) {
settings.dns_resolver_id = alias.clone();
}
}
search_query = VIA_REGEX.replace(&search_query,"").trim().to_string();