diff --git a/echoip_test.toml b/echoip_test.toml index 94b1f94..0ae7830 100644 --- a/echoip_test.toml +++ b/echoip_test.toml @@ -77,7 +77,7 @@ info_url = "https://www.quad9.net/service/service-addresses-and-features/" aliases = ["q9","9999"] weight = 980 -servers = ["9.9.9.9:853","149.112.112.112:853","[2620:fe::fe]:853","[2620:fe::9]:853"] +servers = ["9.9.9.9:853", "149.112.112.112:853", "[2620:fe::fe]:853", "[2620:fe::9]:853"] protocol = "tls" tls_dns_name = "dns.quad9.net" @@ -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"] +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"] +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" diff --git a/src/main.rs b/src/main.rs index 3e3d1c1..62b0fee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,11 +92,12 @@ pub struct DigResult { } struct ServiceSharedState { - templating_engine: templating_engine::Engine, - dns_resolvers: HashMap, - asn_db: geoip::MMDBCarrier, - location_db: geoip::MMDBCarrier, - config: config::EchoIpServiceConfig, + templating_engine: templating_engine::Engine, + dns_resolvers: HashMap, + dns_resolver_aliases: HashMap, + asn_db: geoip::MMDBCarrier, + location_db: geoip::MMDBCarrier, + config: config::EchoIpServiceConfig, } // Stores configuration that is derived from the original configuration @@ -233,6 +234,7 @@ async fn main() { let mut dns_resolver_selectables = Vec::::new(); let mut dns_resolver_map: HashMap = HashMap::new(); + let mut dns_resolver_aliases: HashMap = 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();