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

@ -77,7 +77,7 @@ info_url = "https://www.quad9.net/service/service-addresses-and-features/"
aliases = ["q9","9999"] aliases = ["q9","9999"]
weight = 980 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" protocol = "tls"
tls_dns_name = "dns.quad9.net" tls_dns_name = "dns.quad9.net"
@ -85,18 +85,37 @@ tls_dns_name = "dns.quad9.net"
display_name = "Quad9 with ecs" display_name = "Quad9 with ecs"
info_url = "https://www.quad9.net/service/service-addresses-and-features/" info_url = "https://www.quad9.net/service/service-addresses-and-features/"
aliases = ["q9ecs","9999ecs","ecs"] 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" protocol = "tls"
tls_dns_name = "dns11.quad9.net" tls_dns_name = "dns11.quad9.net"
[dns.resolver.quad9_unvalidated] [dns.resolver.quad9_unvalidated]
display_name = "Quad9 Unvalidated" display_name = "Quad9 unvalidated"
info_url = "https://www.quad9.net/service/service-addresses-and-features/" info_url = "https://www.quad9.net/service/service-addresses-and-features/"
aliases = ["q9u","9999u"] 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" protocol = "tls"
tls_dns_name = "dns10.quad9.net" 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

@ -92,11 +92,12 @@ pub struct DigResult {
} }
struct ServiceSharedState { struct ServiceSharedState {
templating_engine: templating_engine::Engine, templating_engine: templating_engine::Engine,
dns_resolvers: HashMap<String,TokioAsyncResolver>, dns_resolvers: HashMap<String,TokioAsyncResolver>,
asn_db: geoip::MMDBCarrier, dns_resolver_aliases: HashMap<String,String>,
location_db: geoip::MMDBCarrier, asn_db: geoip::MMDBCarrier,
config: config::EchoIpServiceConfig, location_db: geoip::MMDBCarrier,
config: config::EchoIpServiceConfig,
} }
// Stores configuration that is derived from the original configuration // Stores configuration that is derived from the original configuration
@ -233,6 +234,7 @@ async fn main() {
let mut dns_resolver_selectables = Vec::<Selectable>::new(); let mut dns_resolver_selectables = Vec::<Selectable>::new();
let mut dns_resolver_map: HashMap<String,TokioAsyncResolver> = HashMap::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 { if config.dns.enable_system_resolver {
println!("Initalizing System resolver ..."); println!("Initalizing System resolver ...");
@ -265,6 +267,9 @@ async fn main() {
name: resolver_config.display_name.clone(), name: resolver_config.display_name.clone(),
weight: resolver_config.weight, 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; let listen_on = config.server.listen_on;
@ -274,8 +279,8 @@ async fn main() {
let shared_state = Arc::new( let shared_state = Arc::new(
ServiceSharedState { ServiceSharedState {
templating_engine: templating_engine, templating_engine: templating_engine,
//dns_resolver: dns_resolver,
dns_resolvers: dns_resolver_map, dns_resolvers: dns_resolver_map,
dns_resolver_aliases: dns_resolver_aliases,
asn_db: asn_db, asn_db: asn_db,
location_db: location_db, location_db: location_db,
config: config.clone(), config: config.clone(),
@ -491,6 +496,8 @@ async fn handle_search_request(
let state = Arc::clone(&arc_state); let state = Arc::clone(&arc_state);
if state.dns_resolvers.contains_key(&via) { if state.dns_resolvers.contains_key(&via) {
settings.dns_resolver_id = 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(); search_query = VIA_REGEX.replace(&search_query,"").trim().to_string();