mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: windows ipc errors
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -1104,6 +1104,7 @@ dependencies = [
|
||||
"tungstenite 0.26.2",
|
||||
"users",
|
||||
"warp",
|
||||
"winapi",
|
||||
"winreg 0.55.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@@ -85,6 +85,7 @@ hex = "0.4.3"
|
||||
runas = "=1.2.0"
|
||||
deelevate = "0.2.0"
|
||||
winreg = "0.55.0"
|
||||
winapi = { version = "0.3", features = ["winbase", "fileapi", "winnt", "handleapi", "errhandlingapi", "minwindef", "winerror"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
users = "0.11.0"
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::{
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
const REQUIRED_SERVICE_VERSION: &str = "1.0.7"; // 定义所需的服务版本号
|
||||
const REQUIRED_SERVICE_VERSION: &str = "1.0.8"; // 定义所需的服务版本号
|
||||
|
||||
// 限制重装时间和次数的常量
|
||||
const REINSTALL_COOLDOWN_SECS: u64 = 300; // 5分钟冷却期
|
||||
|
||||
@@ -56,7 +56,6 @@ pub fn create_signed_request(
|
||||
payload: serde_json::Value,
|
||||
) -> Result<IpcRequest> {
|
||||
let id = nanoid::nanoid!(32);
|
||||
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
@@ -123,12 +122,9 @@ pub async fn send_ipc_request(
|
||||
use std::io::{Read, Write};
|
||||
use std::os::windows::io::{FromRawHandle, RawHandle};
|
||||
use std::ptr;
|
||||
use winapi::um::fileapi::CreateFileA;
|
||||
use winapi::um::winbase::{PIPE_READMODE_MESSAGE, PIPE_TYPE_MESSAGE, PIPE_WAIT};
|
||||
use winapi::um::winnt::OPEN_EXISTING;
|
||||
use winapi::um::winnt::{
|
||||
FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_READ, GENERIC_WRITE, HANDLE,
|
||||
};
|
||||
use winapi::um::fileapi::{CreateFileA, OPEN_EXISTING};
|
||||
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
|
||||
use winapi::um::winnt::{FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_READ, GENERIC_WRITE};
|
||||
|
||||
logging!(
|
||||
info,
|
||||
@@ -196,7 +192,7 @@ pub async fn send_ipc_request(
|
||||
)
|
||||
};
|
||||
|
||||
if handle == winapi::um::handleapi::INVALID_HANDLE_VALUE {
|
||||
if handle == INVALID_HANDLE_VALUE {
|
||||
let error = std::io::Error::last_os_error();
|
||||
logging!(error, Type::Service, true, "连接到命名管道失败: {}", error);
|
||||
return Err(anyhow::anyhow!("无法连接到服务命名管道: {}", error));
|
||||
@@ -306,7 +302,7 @@ pub async fn send_ipc_request(
|
||||
);
|
||||
Ok(response)
|
||||
})
|
||||
.await?;
|
||||
.await??;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user