chore: update Rust to 2024 edition (#2066)

This commit is contained in:
Luna Yao
2026-04-09 18:22:12 +02:00
committed by GitHub
parent a8feb9ac2b
commit a879dd1b14
158 changed files with 1327 additions and 1231 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ use crate::{
port_forward_manage::PortForwardManageRpcService, proxy::TcpProxyRpcService,
stats::StatsRpcService, vpn_portal::VpnPortalRpcService,
},
tunnel::{tcp::TcpTunnelListener, TunnelListener},
tunnel::{TunnelListener, tcp::TcpTunnelListener},
web_client::{DefaultHooks, WebClientHooks},
};
+10 -11
View File
@@ -92,17 +92,16 @@ impl WebClientService for InstanceManageRpcService {
ConfigFileControl::new(None, ConfigFilePermission::default())
};
if !control.is_read_only() {
if let Some(config_file) = control.path.as_ref() {
if let Err(e) = std::fs::write(config_file, cfg.dump()) {
tracing::warn!(
"failed to write config file {}: {}",
config_file.display(),
e
);
control.set_read_only(true);
}
}
if !control.is_read_only()
&& let Some(config_file) = control.path.as_ref()
&& let Err(e) = std::fs::write(config_file, cfg.dump())
{
tracing::warn!(
"failed to write config file {}: {}",
config_file.display(),
e
);
control.set_read_only(true);
}
if let Err(e) = self.hooks.pre_run_network_instance(&cfg).await {
+5 -5
View File
@@ -1,4 +1,4 @@
use std::sync::{mpsc::Sender, Mutex, OnceLock};
use std::sync::{Mutex, OnceLock, mpsc::Sender};
use crate::proto::{
api::logger::{
@@ -72,10 +72,10 @@ impl LoggerRpc for LoggerRpcService {
}
// 更新当前日志级别
if let Some(current_level) = CURRENT_LOG_LEVEL.get() {
if let Ok(mut level) = current_level.lock() {
*level = Self::log_level_to_string(request.level());
}
if let Some(current_level) = CURRENT_LOG_LEVEL.get()
&& let Ok(mut level) = current_level.lock()
{
*level = Self::log_level_to_string(request.level());
}
Ok(SetLoggerConfigResponse {})
+4 -6
View File
@@ -100,12 +100,10 @@ fn get_instance_service(
if let Some(api::instance::instance_identifier::Selector::InstanceSelector(
selector,
)) = selector
&& let Some(name) = selector.name.as_ref()
&& v.get_inst_name() != *name
{
if let Some(name) = selector.name.as_ref() {
if v.get_inst_name() != *name {
return false;
}
}
return false;
}
true
})
@@ -118,7 +116,7 @@ fn get_instance_service(
return Err(anyhow::anyhow!(
"{} instances match the selector, please specify the instance ID",
ids.len()
))
));
}
}
};
+14 -17
View File
@@ -208,8 +208,8 @@ where
) -> Result<GetNetworkMetasResponse, RemoteClientError<E>> {
let mut metas = std::collections::HashMap::new();
if let Some(client) = self.get_rpc_client(identify.clone()) {
if let Ok(resp) = client
if let Some(client) = self.get_rpc_client(identify.clone())
&& let Ok(resp) = client
.list_network_instance_meta(
BaseController::default(),
ListNetworkInstanceMetaRequest {
@@ -217,12 +217,11 @@ where
},
)
.await
{
for meta in resp.metas {
if let Some(inst_id) = meta.inst_id.as_ref() {
let inst_id: uuid::Uuid = (*inst_id).into();
metas.insert(inst_id, meta);
}
{
for meta in resp.metas {
if let Some(inst_id) = meta.inst_id.as_ref() {
let inst_id: uuid::Uuid = (*inst_id).into();
metas.insert(inst_id, meta);
}
}
}
@@ -271,8 +270,8 @@ where
identify: T,
inst_id: uuid::Uuid,
) -> Result<NetworkConfig, RemoteClientError<E>> {
if let Some(client) = self.get_rpc_client(identify.clone()) {
if let Ok(resp) = client
if let Some(client) = self.get_rpc_client(identify.clone())
&& let Ok(resp) = client
.get_network_instance_config(
BaseController::default(),
GetNetworkInstanceConfigRequest {
@@ -280,11 +279,9 @@ where
},
)
.await
{
if let Some(config) = resp.config {
return Ok(config);
}
}
&& let Some(config) = resp.config
{
return Ok(config);
}
let inst_id = inst_id.to_string();
@@ -354,7 +351,7 @@ where
) -> Result<(), E>;
async fn delete_network_configs(&self, identify: T, network_inst_ids: &[Uuid])
-> Result<(), E>;
-> Result<(), E>;
async fn update_network_config_state(
&self,
@@ -364,7 +361,7 @@ where
) -> Result<(), E>;
async fn list_network_configs(&self, identify: T, props: ListNetworkProps)
-> Result<Vec<C>, E>;
-> Result<Vec<C>, E>;
async fn get_network_config(&self, identify: T, network_inst_id: &str) -> Result<Option<C>, E>;
}