mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -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<()> {
|
fn download() -> anyhow::Result<()> {
|
||||||
debug!("Downloading ASN-IP Table");
|
tracing::warn!("Downloading ASN-IP Table");
|
||||||
let file_path = Self::file_path();
|
let file_path = Self::file_path();
|
||||||
let url = "https://stats.libreqos.io/geo2.bin";
|
let url = "https://stats.libreqos.io/geo2.bin";
|
||||||
let response = reqwest::blocking::get(url)?;
|
let response = reqwest::blocking::get(url)?;
|
||||||
|
@ -26,19 +26,16 @@ pub struct FlowAnalysisSystem {
|
|||||||
|
|
||||||
impl FlowAnalysisSystem {
|
impl FlowAnalysisSystem {
|
||||||
pub fn new() -> Self {
|
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(|| {
|
let _ = std::thread::Builder::new().name("GeoTable Updater".to_string()).spawn(|| {
|
||||||
loop {
|
let result = asn::GeoTable::load();
|
||||||
let result = asn::GeoTable::load();
|
match result {
|
||||||
match result {
|
Ok(table) => {
|
||||||
Ok(table) => {
|
ANALYSIS.asn_table.lock().unwrap().replace(table);
|
||||||
ANALYSIS.asn_table.lock().unwrap().replace(table);
|
}
|
||||||
}
|
Err(e) => {
|
||||||
Err(e) => {
|
error!("Failed to update ASN table: {e}");
|
||||||
error!("Failed to update ASN table: {e}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
std::thread::sleep(std::time::Duration::from_secs(60 * 60 * 24));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,6 +58,8 @@ impl FlowAnalysisSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_flow_analysis() -> anyhow::Result<()> {
|
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();
|
let e = ANALYSIS.asn_table.lock();
|
||||||
if e.is_err() {
|
if e.is_err() {
|
||||||
anyhow::bail!("Failed to lock ASN table");
|
anyhow::bail!("Failed to lock ASN table");
|
||||||
|
Loading…
Reference in New Issue
Block a user