refactor: cleanup and decouple

This commit is contained in:
zhom
2026-02-20 04:44:35 +04:00
parent 0f579cb97d
commit e5663515a7
47 changed files with 4501 additions and 770 deletions
+22 -2
View File
@@ -243,8 +243,7 @@ impl ProxyManager {
.as_secs()
}
// Get geolocation for an IP address
async fn get_ip_geolocation(
pub async fn get_ip_geolocation(
ip: &str,
) -> Result<(Option<String>, Option<String>, Option<String>), String> {
// Use ip-api.com (free, no API key required)
@@ -1626,6 +1625,27 @@ impl ProxyManager {
delete_proxy_config(&config.id);
}
// Clean up orphaned VPN worker configs where the worker process is dead
{
use crate::proxy_storage::is_process_running;
use crate::vpn_worker_storage::{delete_vpn_worker_config, list_vpn_worker_configs};
let vpn_workers = list_vpn_worker_configs();
for worker in vpn_workers {
if let Some(pid) = worker.pid {
if !is_process_running(pid) {
log::info!(
"Cleaning up orphaned VPN worker config: {} (process PID {} is dead)",
worker.id,
pid
);
let _ = std::fs::remove_file(&worker.config_file_path);
delete_vpn_worker_config(&worker.id);
}
}
}
}
// Emit event for reactive UI updates
if let Err(e) = events::emit_empty("proxies-changed") {
log::error!("Failed to emit proxies-changed event: {e}");