mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-15 13:33:28 +02:00
Added aliases and some servers to test them
This commit is contained in:
19
src/main.rs
19
src/main.rs
@ -92,11 +92,12 @@ pub struct DigResult {
|
||||
}
|
||||
|
||||
struct ServiceSharedState {
|
||||
templating_engine: templating_engine::Engine,
|
||||
dns_resolvers: HashMap<String,TokioAsyncResolver>,
|
||||
asn_db: geoip::MMDBCarrier,
|
||||
location_db: geoip::MMDBCarrier,
|
||||
config: config::EchoIpServiceConfig,
|
||||
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,
|
||||
}
|
||||
|
||||
// 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_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();
|
||||
|
Reference in New Issue
Block a user