renamed to koala clash

This commit is contained in:
coolcoala
2025-08-05 17:51:26 +03:00
parent 7be3cdeb65
commit e32e83d45e
36 changed files with 286 additions and 276 deletions

View File

@@ -129,7 +129,7 @@ impl IClashTemp {
help::save_yaml(
&dirs::clash_path()?,
&self.0,
Some("# Generated by Clash Verge"),
Some("# Generated by Koala Clash"),
)
}

View File

@@ -11,8 +11,8 @@ use once_cell::sync::OnceCell;
use std::path::PathBuf;
use tokio::time::{sleep, Duration};
pub const RUNTIME_CONFIG: &str = "clash-verge.yaml";
pub const CHECK_CONFIG: &str = "clash-verge-check.yaml";
pub const RUNTIME_CONFIG: &str = "koala-clash.yaml";
pub const CHECK_CONFIG: &str = "koala-clash-check.yaml";
pub struct Config {
clash_config: Draft<Box<IClashTemp>>,
@@ -141,7 +141,7 @@ impl Config {
.as_ref()
.ok_or(anyhow!("failed to get runtime config"))?;
help::save_yaml(&path, &config, Some("# Generated by Clash Verge"))?;
help::save_yaml(&path, &config, Some("# Generated by Koala Clash"))?;
Ok(path)
}

View File

@@ -4,11 +4,11 @@ use crate::utils::{
tmpl,
};
use anyhow::{bail, Context, Result};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use serde_yaml::Mapping;
use std::{fs, time::Duration};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use url::Url;
use super::Config;
@@ -407,7 +407,8 @@ impl PrfItem {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
if let Some(b64_data) = str_value.strip_prefix("base64:") {
STANDARD.decode(b64_data)
STANDARD
.decode(b64_data)
.ok()
.and_then(|bytes| String::from_utf8(bytes).ok())
} else {
@@ -423,7 +424,7 @@ impl PrfItem {
bail!(announce_msg.clone());
}
}
let announce_url = match header.get("announce-url") {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
@@ -436,7 +437,8 @@ impl PrfItem {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
if let Some(b64_data) = str_value.strip_prefix("base64:") {
STANDARD.decode(b64_data)
STANDARD
.decode(b64_data)
.ok()
.and_then(|bytes| String::from_utf8(bytes).ok())
} else {
@@ -448,7 +450,9 @@ impl PrfItem {
let uid = help::get_uid("R");
let file = format!("{uid}.yaml");
let name = name.or(profile_title).unwrap_or(filename.unwrap_or("Remote File".into()));
let name = name
.or(profile_title)
.unwrap_or(filename.unwrap_or("Remote File".into()));
let data = resp.text_with_charset("utf-8").await?;
// process the charset "UTF-8 with BOM"

View File

@@ -66,7 +66,7 @@ impl IProfiles {
help::save_yaml(
&dirs::profiles_path()?,
self,
Some("# Profiles Config for Clash Verge"),
Some("# Profiles Config for Koala Clash"),
)
}

View File

@@ -238,7 +238,7 @@ pub struct IVergeTheme {
impl IVerge {
/// 有效的clash核心名称
pub const VALID_CLASH_CORES: &'static [&'static str] = &["verge-mihomo", "verge-mihomo-alpha"];
pub const VALID_CLASH_CORES: &'static [&'static str] = &["koala-mihomo", "koala-mihomo-alpha"];
/// 验证并修正配置文件中的clash_core值
pub fn validate_and_fix_config() -> Result<()> {
@@ -257,10 +257,10 @@ impl IVerge {
warn,
Type::Config,
true,
"启动时发现无效的clash_core配置: '{}', 将自动修正为 'verge-mihomo'",
"启动时发现无效的clash_core配置: '{}', 将自动修正为 'koala-mihomo'",
core
);
config.clash_core = Some("verge-mihomo".to_string());
config.clash_core = Some("koala-mihomo".to_string());
needs_fix = true;
}
} else {
@@ -268,16 +268,16 @@ impl IVerge {
info,
Type::Config,
true,
"启动时发现未配置clash_core, 将设置为默认值 'verge-mihomo'"
"启动时发现未配置clash_core, 将设置为默认值 'koala-mihomo'"
);
config.clash_core = Some("verge-mihomo".to_string());
config.clash_core = Some("koala-mihomo".to_string());
needs_fix = true;
}
// 修正后保存配置
if needs_fix {
logging!(info, Type::Config, true, "正在保存修正后的配置文件...");
help::save_yaml(&config_path, &config, Some("# Clash Verge Config"))?;
help::save_yaml(&config_path, &config, Some("# Koala Clash Config"))?;
logging!(
info,
Type::Config,
@@ -321,7 +321,7 @@ impl IVerge {
pub fn get_valid_clash_core(&self) -> String {
self.clash_core
.clone()
.unwrap_or_else(|| "verge-mihomo".to_string())
.unwrap_or_else(|| "koala-mihomo".to_string())
}
fn get_system_language() -> String {
@@ -340,18 +340,15 @@ impl IVerge {
}
pub fn new() -> Self {
match dirs::verge_path().and_then(|path| help::read_yaml::<IVerge>(&path)) {
Ok(config) => config,
Err(err) => {
log::error!(target: "app", "{err}");
Self::template()
}
}
dirs::verge_path().and_then(|path| help::read_yaml::<IVerge>(&path)).unwrap_or_else(|err| {
log::error!(target: "app", "{err}");
Self::template()
})
}
pub fn template() -> Self {
Self {
clash_core: Some("verge-mihomo".into()),
clash_core: Some("koala-mihomo".into()),
language: Some(Self::get_system_language()),
theme_mode: Some("system".into()),
#[cfg(not(target_os = "windows"))]
@@ -415,7 +412,7 @@ impl IVerge {
/// Save IVerge App Config
pub fn save_file(&self) -> Result<()> {
help::save_yaml(&dirs::verge_path()?, &self, Some("# Clash Verge Config"))
help::save_yaml(&dirs::verge_path()?, &self, Some("# Koala Clash Config"))
}
/// patch verge config

View File

@@ -108,7 +108,7 @@ impl WebDavClient {
reqwest::Client::builder()
.danger_accept_invalid_certs(true)
.timeout(Duration::from_secs(op.timeout()))
.user_agent(format!("clash-verge/{APP_VERSION} ({OS} WebDAV-Client)"))
.user_agent(format!("koala-clash/{APP_VERSION} ({OS} WebDAV-Client)"))
.redirect(reqwest::redirect::Policy::custom(|attempt| {
// 允许所有请求类型的重定向包括PUT
if attempt.previous().len() >= 5 {

View File

@@ -146,7 +146,7 @@ impl CoreManager {
help::save_yaml(
&runtime_path,
&Config::clash().latest().0,
Some("# Clash Verge Runtime"),
Some("# Koala Clash Runtime"),
)?;
handle::Handle::notice_message(msg_type, msg_content);
Ok(())
@@ -443,7 +443,7 @@ impl CoreManager {
child_guard.as_ref().map(|child| child.pid())
};
let target_processes = ["verge-mihomo", "verge-mihomo-alpha"];
let target_processes = ["koala-mihomo", "koala-mihomo-alpha"];
// 并行查找所有目标进程
let mut process_futures = Vec::new();

View File

@@ -578,7 +578,7 @@ pub async fn check_ipc_service_status() -> Result<JsonResponse> {
}
Err(e) => {
logging!(error, Type::Service, true, "IPC通信失败: {}", e);
bail!("无法连接到Clash Verge Service: {}", e)
bail!("无法连接到Koala Clash Service: {}", e)
}
}
}
@@ -667,7 +667,7 @@ pub async fn check_service_version() -> Result<String> {
}
Err(e) => {
logging!(error, Type::Service, true, "IPC通信失败: {}", e);
bail!("无法连接到Clash Verge Service: {}", e)
bail!("无法连接到Koala Clash Service: {}", e)
}
}
}
@@ -814,7 +814,7 @@ pub(super) async fn start_with_existing_service(config_file: &PathBuf) -> Result
}
Err(e) => {
logging!(error, Type::Service, true, "启动核心IPC通信失败: {}", e);
bail!("无法连接到Clash Verge Service: {}", e)
bail!("无法连接到Koala Clash Service: {}", e)
}
}
}
@@ -910,7 +910,7 @@ pub(super) async fn stop_core_by_service() -> Result<()> {
let payload = serde_json::json!({});
let response = send_ipc_request(IpcCommand::StopClash, payload)
.await
.context("无法连接到Clash Verge Service")?;
.context("无法连接到Koala Clash Service")?;
if !response.success {
bail!(response.error.unwrap_or_else(|| "停止核心失败".to_string()));

View File

@@ -6,9 +6,9 @@ use sha2::{Digest, Sha256};
use std::time::{SystemTime, UNIX_EPOCH};
const IPC_SOCKET_NAME: &str = if cfg!(windows) {
r"\\.\pipe\clash-verge-service"
r"\\.\pipe\koala-clash-service"
} else {
"/tmp/clash-verge-service.sock"
"/tmp/koala-clash-service.sock"
};
// 定义命令类型
@@ -43,7 +43,7 @@ pub struct IpcResponse {
fn derive_secret_key() -> Vec<u8> {
// to do
// 从系统安全存储中获取或从程序安装时生成的密钥文件中读取
let unique_app_id = "clash-verge-app-secret-fuck-me-until-daylight";
let unique_app_id = "koala-clash-app-secret-fuck-me-until-daylight";
let mut hasher = Sha256::new();
hasher.update(unique_app_id.as_bytes());
hasher.finalize().to_vec()

View File

@@ -414,7 +414,7 @@ impl Tray {
if let Some(tray) = app_handle.tray_by_id("main") {
let _ = tray.set_tooltip(Some(&format!(
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
"Koala Clash {version}\n{}: {}\n{}: {}\n{}: {}",
t("SysProxy"),
switch_map[system_proxy],
t("TUN"),

View File

@@ -108,8 +108,8 @@ impl ChainSupport {
(self, core.as_str()),
(ChainSupport::All, _)
| (ChainSupport::Clash, "clash")
| (ChainSupport::ClashMeta, "verge-mihomo")
| (ChainSupport::ClashMetaAlpha, "verge-mihomo-alpha")
| (ChainSupport::ClashMeta, "koala-mihomo")
| (ChainSupport::ClashMetaAlpha, "koala-mihomo-alpha")
),
None => true,
}

View File

@@ -39,7 +39,7 @@ pub fn get_exe_path() -> Result<PathBuf> {
pub fn create_shortcut() -> Result<()> {
let exe_path = get_exe_path()?;
let startup_dir = get_startup_dir()?;
let shortcut_path = startup_dir.join("Clash-Verge.lnk");
let shortcut_path = startup_dir.join("Koala-Clash.lnk");
// 如果快捷方式已存在,直接返回成功
if shortcut_path.exists() {
@@ -77,7 +77,7 @@ pub fn create_shortcut() -> Result<()> {
#[cfg(target_os = "windows")]
pub fn remove_shortcut() -> Result<()> {
let startup_dir = get_startup_dir()?;
let shortcut_path = startup_dir.join("Clash-Verge.lnk");
let shortcut_path = startup_dir.join("Koala-Clash.lnk");
// 如果快捷方式不存在,直接返回成功
if !shortcut_path.exists() {
@@ -96,7 +96,7 @@ pub fn remove_shortcut() -> Result<()> {
#[cfg(target_os = "windows")]
pub fn is_shortcut_enabled() -> Result<bool> {
let startup_dir = get_startup_dir()?;
let shortcut_path = startup_dir.join("Clash-Verge.lnk");
let shortcut_path = startup_dir.join("Koala-Clash.lnk");
Ok(shortcut_path.exists())
}

View File

@@ -5,14 +5,14 @@ use std::{fs, path::PathBuf};
use tauri::Manager;
#[cfg(not(feature = "verge-dev"))]
pub static APP_ID: &str = "io.github.clash-verge-rev.clash-verge-rev";
pub static APP_ID: &str = "io.github.koala-clash";
#[cfg(not(feature = "verge-dev"))]
pub static BACKUP_DIR: &str = "clash-verge-rev-backup";
pub static BACKUP_DIR: &str = "io.github.koala-clash-backup";
#[cfg(feature = "verge-dev")]
pub static APP_ID: &str = "io.github.clash-verge-rev.clash-verge-rev.dev";
pub static APP_ID: &str = "io.github.koala-clash.dev";
#[cfg(feature = "verge-dev")]
pub static BACKUP_DIR: &str = "clash-verge-rev-backup-dev";
pub static BACKUP_DIR: &str = "io.github.koala-clash-backup-dev";
pub static PORTABLE_FLAG: OnceCell<bool> = OnceCell::new();
@@ -188,13 +188,13 @@ pub fn profiles_path() -> Result<PathBuf> {
#[cfg(target_os = "macos")]
pub fn service_path() -> Result<PathBuf> {
let res_dir = app_resources_dir()?;
Ok(res_dir.join("clash-verge-service"))
Ok(res_dir.join("koala-clash-service"))
}
#[cfg(windows)]
pub fn service_path() -> Result<PathBuf> {
let res_dir = app_resources_dir()?;
Ok(res_dir.join("clash-verge-service.exe"))
Ok(res_dir.join("koala-clash-service.exe"))
}
pub fn service_log_file() -> Result<PathBuf> {

View File

@@ -246,7 +246,7 @@ fn init_dns_config() -> Result<()> {
help::save_yaml(
&dns_path,
&default_dns_config,
Some("# Clash Verge DNS Config"),
Some("# Koala Clash DNS Config"),
)?;
}
@@ -274,14 +274,14 @@ pub fn init_config() -> Result<()> {
crate::log_err!(dirs::clash_path().map(|path| {
if !path.exists() {
help::save_yaml(&path, &IClashTemp::template().0, Some("# Clash Vergeasu"))?;
help::save_yaml(&path, &IClashTemp::template().0, Some("# Koala Clash"))?;
}
<Result<()>>::Ok(())
}));
crate::log_err!(dirs::verge_path().map(|path| {
if !path.exists() {
help::save_yaml(&path, &IVerge::template(), Some("# Clash Verge"))?;
help::save_yaml(&path, &IVerge::template(), Some("# Koala Clash"))?;
}
<Result<()>>::Ok(())
}));
@@ -291,7 +291,7 @@ pub fn init_config() -> Result<()> {
crate::log_err!(dirs::profiles_path().map(|path| {
if !path.exists() {
help::save_yaml(&path, &IProfiles::template(), Some("# Clash Verge"))?;
help::save_yaml(&path, &IProfiles::template(), Some("# Koala Clash"))?;
}
<Result<()>>::Ok(())
}));
@@ -371,8 +371,8 @@ pub fn init_scheme() -> Result<()> {
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let (clash, _) = hkcu.create_subkey("Software\\Classes\\Clash")?;
clash.set_value("", &"Clash Verge")?;
clash.set_value("URL Protocol", &"Clash Verge URL Scheme Protocol")?;
clash.set_value("", &"Koala Clash")?;
clash.set_value("URL Protocol", &"Koala Clash URL Scheme Protocol")?;
let (default_icon, _) = hkcu.create_subkey("Software\\Classes\\Clash\\DefaultIcon")?;
default_icon.set_value("", &app_exe)?;
let (command, _) = hkcu.create_subkey("Software\\Classes\\Clash\\Shell\\Open\\Command")?;
@@ -384,7 +384,7 @@ pub fn init_scheme() -> Result<()> {
pub fn init_scheme() -> Result<()> {
let output = std::process::Command::new("xdg-mime")
.arg("default")
.arg("clash-verge.desktop")
.arg("koala-clash.desktop")
.arg("x-scheme-handler/clash")
.output()?;
if !output.status.success() {

View File

@@ -8,6 +8,6 @@ pub mod network;
pub mod notification;
pub mod resolve;
pub mod server;
pub mod sys_info;
pub mod tmpl;
pub mod window_manager;
pub mod sys_info;

View File

@@ -40,7 +40,7 @@ impl NetworkManager {
// 创建专用的异步运行时线程数限制为4个
let runtime = Builder::new_multi_thread()
.worker_threads(4)
.thread_name("clash-verge-network")
.thread_name("koala-clash-network")
.enable_io()
.enable_time()
.build()
@@ -323,8 +323,8 @@ impl NetworkManager {
use crate::utils::resolve::VERSION;
let version = match VERSION.get() {
Some(v) => format!("clash-verge/v{v}"),
None => "clash-verge/unknown".to_string(),
Some(v) => format!("koala-clash/v{v}"),
None => "koala-clash/unknown".to_string(),
};
builder = builder.user_agent(version);

View File

@@ -549,7 +549,7 @@ pub async fn resolve_scheme(param: String) -> Result<()> {
}
};
if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" {
if link_parsed.scheme() == "clash" || link_parsed.scheme() == "koala-clash" {
let mut name: Option<String> = None;
let mut url_param: Option<String> = None;

View File

@@ -1,7 +1,7 @@
//! Some config file template
/// template for new a profile item
pub const ITEM_LOCAL: &str = "# Profile Template for Clash Verge
pub const ITEM_LOCAL: &str = "# Profile Template for Koala Clash
proxies: []
@@ -11,13 +11,13 @@ rules: []
";
/// enhanced profile
pub const ITEM_MERGE: &str = "# Profile Enhancement Merge Template for Clash Verge
pub const ITEM_MERGE: &str = "# Profile Enhancement Merge Template for Koala Clash
profile:
store-selected: true
";
pub const ITEM_MERGE_EMPTY: &str = "# Profile Enhancement Merge Template for Clash Verge
pub const ITEM_MERGE_EMPTY: &str = "# Profile Enhancement Merge Template for Koala Clash
";
@@ -30,7 +30,7 @@ function main(config, profileName) {
";
/// enhanced profile
pub const ITEM_RULES: &str = "# Profile Enhancement Rules Template for Clash Verge
pub const ITEM_RULES: &str = "# Profile Enhancement Rules Template for Koala Clash
prepend: []
@@ -40,7 +40,7 @@ delete: []
";
/// enhanced profile
pub const ITEM_PROXIES: &str = "# Profile Enhancement Proxies Template for Clash Verge
pub const ITEM_PROXIES: &str = "# Profile Enhancement Proxies Template for Koala Clash
prepend: []
@@ -50,7 +50,7 @@ delete: []
";
/// enhanced profile
pub const ITEM_GROUPS: &str = "# Profile Enhancement Groups Template for Clash Verge
pub const ITEM_GROUPS: &str = "# Profile Enhancement Groups Template for Koala Clash
prepend: []