mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
refactor: clean up imports and remove unused initialization in NetworkManager
This commit is contained in:
@@ -8,7 +8,6 @@ use isahc::{
|
||||
},
|
||||
};
|
||||
use isahc::{config::SslOption, HttpClient};
|
||||
use std::sync::Once;
|
||||
use std::time::{Duration, Instant};
|
||||
use sysproxy::Sysproxy;
|
||||
use tokio::sync::Mutex;
|
||||
@@ -56,7 +55,6 @@ pub struct NetworkManager {
|
||||
self_proxy_client: Mutex<Option<HttpClient>>,
|
||||
system_proxy_client: Mutex<Option<HttpClient>>,
|
||||
no_proxy_client: Mutex<Option<HttpClient>>,
|
||||
init: Once,
|
||||
last_connection_error: Mutex<Option<(Instant, String)>>,
|
||||
connection_error_count: Mutex<usize>,
|
||||
}
|
||||
@@ -67,16 +65,11 @@ impl NetworkManager {
|
||||
self_proxy_client: Mutex::new(None),
|
||||
system_proxy_client: Mutex::new(None),
|
||||
no_proxy_client: Mutex::new(None),
|
||||
init: Once::new(),
|
||||
last_connection_error: Mutex::new(None),
|
||||
connection_error_count: Mutex::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(&self) {
|
||||
self.init.call_once(|| {});
|
||||
}
|
||||
|
||||
async fn record_connection_error(&self, error: &str) {
|
||||
let mut last_error = self.last_connection_error.lock().await;
|
||||
*last_error = Some((Instant::now(), error.to_string()));
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
logging, logging_error,
|
||||
module::lightweight::auto_lightweight_mode_init,
|
||||
process::AsyncHandler,
|
||||
utils::{init, logging::Type, network::NetworkManager, resolve::window::create_window, server},
|
||||
utils::{init, logging::Type, resolve::window::create_window, server},
|
||||
};
|
||||
|
||||
pub mod dns;
|
||||
@@ -22,9 +22,8 @@ pub fn resolve_setup_handle(app_handle: AppHandle) {
|
||||
|
||||
pub fn resolve_setup_sync() {
|
||||
AsyncHandler::spawn(|| async {
|
||||
AsyncHandler::spawn_blocking(|| init_scheme());
|
||||
AsyncHandler::spawn_blocking(|| init_embed_server());
|
||||
AsyncHandler::spawn_blocking(|| NetworkManager::new().init());
|
||||
AsyncHandler::spawn_blocking(init_scheme);
|
||||
AsyncHandler::spawn_blocking(init_embed_server);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user