mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-08 22:17:49 +02:00
refactor: cleanup and decouple
This commit is contained in:
@@ -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}");
|
||||
|
||||
Reference in New Issue
Block a user