fix: improve Service connection method and permissions for Windows and Unix

This commit is contained in:
Tunglies
2025-10-11 23:40:37 +08:00
parent 4f1d61a56e
commit d531432f4a
16 changed files with 535 additions and 779 deletions

View File

@@ -144,21 +144,6 @@ pub fn service_path() -> Result<PathBuf> {
Ok(res_dir.join("clash-verge-service.exe"))
}
// TODO 迁移 Service日志后删除
pub fn service_log_file() -> Result<PathBuf> {
use chrono::Local;
let log_dir = app_logs_dir()?.join("service");
let local_time = Local::now().format("%Y-%m-%d-%H%M").to_string();
let log_file = format!("{local_time}.log");
let log_file = log_dir.join(log_file);
let _ = std::fs::create_dir_all(&log_dir);
Ok(log_file)
}
pub fn sidecar_log_dir() -> Result<PathBuf> {
let log_dir = app_logs_dir()?.join("sidecar");
let _ = std::fs::create_dir_all(&log_dir);
@@ -207,7 +192,7 @@ pub fn get_encryption_key() -> Result<Vec<u8>> {
#[cfg(unix)]
pub fn ensure_mihomo_safe_dir() -> Option<PathBuf> {
["/var/tmp", "/tmp"]
["/tmp"]
.iter()
.map(PathBuf::from)
.find(|path| path.exists())