Made the geoip database reloadable

This commit is contained in:
Slatian
2023-03-26 14:27:16 +02:00
parent 51f27be997
commit 6a57780490
4 changed files with 42 additions and 24 deletions

View File

@ -30,7 +30,6 @@ use trust_dns_resolver::{
use std::fs;
use std::net::IpAddr;
use std::sync::Arc;
use std::path::Path;
mod config;
mod geoip;
@ -205,23 +204,19 @@ async fn main() {
// Initalize GeoIP Database
let mut asn_db = geoip::MMDBCarrier {
mmdb: None,
name: "GeoIP ASN Database".to_string(),
};
match &config.geoip.asn_database {
Some(path) => { asn_db.load_database_from_path(Path::new(&path)).ok(); },
None => {},
}
let asn_db = geoip::MMDBCarrier::new(
"GeoIP ASN Database".to_string(),
config.geoip.asn_database.clone()
);
let mut location_db = geoip::MMDBCarrier {
mmdb: None,
name: "GeoIP Location Database".to_string(),
};
match &config.geoip.location_database {
Some(path) => { location_db.load_database_from_path(Path::new(&path)).ok(); },
None => {},
}
asn_db.reload_database().ok();
let location_db = geoip::MMDBCarrier::new(
"GeoIP Location Database".to_string(),
config.geoip.location_database.clone()
);
location_db.reload_database().ok();
// Initalize DNS resolver with os defaults
println!("Initalizing dns resolver ...");