mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2024-11-21 15:57:24 -06:00
Make geotable only load once.
This commit is contained in:
parent
11c8a25c1c
commit
0ce2c9ba6d
@ -62,7 +62,7 @@ impl GeoTable {
|
||||
}
|
||||
|
||||
fn download() -> anyhow::Result<()> {
|
||||
debug!("Downloading ASN-IP Table");
|
||||
tracing::warn!("Downloading ASN-IP Table");
|
||||
let file_path = Self::file_path();
|
||||
let url = "https://stats.libreqos.io/geo2.bin";
|
||||
let response = reqwest::blocking::get(url)?;
|
||||
|
@ -26,9 +26,8 @@ pub struct FlowAnalysisSystem {
|
||||
|
||||
impl FlowAnalysisSystem {
|
||||
pub fn new() -> Self {
|
||||
// Periodically update the ASN table
|
||||
// Moved from being periodically updated to being updated on startup
|
||||
let _ = std::thread::Builder::new().name("GeoTable Updater".to_string()).spawn(|| {
|
||||
loop {
|
||||
let result = asn::GeoTable::load();
|
||||
match result {
|
||||
Ok(table) => {
|
||||
@ -38,8 +37,6 @@ impl FlowAnalysisSystem {
|
||||
error!("Failed to update ASN table: {e}");
|
||||
}
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_secs(60 * 60 * 24));
|
||||
}
|
||||
});
|
||||
|
||||
Self {
|
||||
@ -61,6 +58,8 @@ impl FlowAnalysisSystem {
|
||||
}
|
||||
|
||||
pub fn setup_flow_analysis() -> anyhow::Result<()> {
|
||||
// This is locking the table, which triggers lazy-loading of the
|
||||
// data. It's not actually doing nothing.
|
||||
let e = ANALYSIS.asn_table.lock();
|
||||
if e.is_err() {
|
||||
anyhow::bail!("Failed to lock ASN table");
|
||||
|
Loading…
Reference in New Issue
Block a user