chore: delete clash core, update CI, change profile name, change URL test link

This commit is contained in:
wonfen
2023-11-22 02:56:47 +08:00
parent b767caa704
commit 01be65a624
31 changed files with 1327 additions and 974 deletions

View File

@@ -45,7 +45,7 @@ impl Config {
Self::global().runtime_config.clone()
}
/// 初始化配置
/// 初始化订阅
pub fn init_config() -> Result<()> {
crate::log_err!(Self::generate());
if let Err(err) = Self::generate_file(ConfigType::Run) {
@@ -64,7 +64,7 @@ impl Config {
Ok(())
}
/// 将配置丢到对应的文件中
/// 将订阅丢到对应的文件中
pub fn generate_file(typ: ConfigType) -> Result<PathBuf> {
let path = match typ {
ConfigType::Run => dirs::app_home_dir()?.join(RUNTIME_CONFIG),
@@ -82,7 +82,7 @@ impl Config {
Ok(path)
}
/// 生成配置存好
/// 生成订阅存好
pub fn generate() -> Result<()> {
let (config, exists_keys, logs) = enhance::enhance();

View File

@@ -261,7 +261,7 @@ impl IProfiles {
Ok(current == uid)
}
/// 获取current指向的配置内容
/// 获取current指向的订阅内容
pub fn current_mapping(&self) -> Result<Mapping> {
match (self.current.as_ref(), self.items.as_ref()) {
(Some(current), Some(items)) => {

View File

@@ -5,7 +5,7 @@ use std::collections::HashMap;
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct IRuntime {
pub config: Option<Mapping>,
// 记录在配置包括merge和script生成的出现过的keys
// 记录在订阅包括merge和script生成的出现过的keys
// 这些keys不一定都生效
pub exists_keys: Vec<String>,
pub chain_logs: HashMap<String, Vec<(String, String)>>,

View File

@@ -48,7 +48,7 @@ pub async fn get_proxy_delay(name: String, test_url: Option<String>) -> Result<D
let (url, headers) = clash_client_info()?;
let url = format!("{url}/proxies/{name}/delay");
let default_url = "http://www.gstatic.com/generate_204";
let default_url = "http://1.1.1.1";
let test_url = test_url
.map(|s| if s.is_empty() { default_url.into() } else { s })
.unwrap_or(default_url.into());

View File

@@ -51,7 +51,7 @@ impl CoreManager {
Ok(())
}
/// 检查配置是否正确
/// 检查订阅是否正确
pub fn check_config(&self) -> Result<()> {
let config_path = Config::generate_file(ConfigType::Check)?;
let config_path = dirs::path_to_str(&config_path)?;
@@ -267,7 +267,7 @@ impl CoreManager {
Config::verge().draft().clash_core = Some(clash_core);
// 更新配置
// 更新订阅
Config::generate()?;
self.check_config()?;
@@ -295,13 +295,13 @@ impl CoreManager {
pub async fn update_config(&self) -> Result<()> {
log::debug!(target: "app", "try to update clash config");
// 更新配置
// 更新订阅
Config::generate()?;
// 检查配置是否正常
// 检查订阅是否正常
self.check_config()?;
// 更新运行时配置
// 更新运行时订阅
let path = Config::generate_file(ConfigType::Run)?;
let path = dirs::path_to_str(&path)?;

View File

@@ -18,9 +18,9 @@ use std::collections::HashSet;
type ResultLog = Vec<(String, String)>;
/// Enhance mode
/// 返回最终配置、该配置包含的键、和script执行的结果
/// 返回最终订阅、该订阅包含的键、和script执行的结果
pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
// config.yaml 的配置
// config.yaml 的订阅
let clash_config = { Config::clash().latest().0.clone() };
let (clash_core, enable_tun, enable_builtin, enable_filter) = {

View File

@@ -47,7 +47,7 @@ pub fn change_clash_mode(mode: String) {
match clash_api::patch_configs(&mapping).await {
Ok(_) => {
// 更新配置
// 更新订阅
Config::clash().data().patch_config(mapping);
if Config::clash().data().save_config().is_ok() {
@@ -156,7 +156,7 @@ pub fn disable_tun_mode() {
});
}
/// 修改clash的配置
/// 修改clash的订阅
pub async fn patch_clash(patch: Mapping) -> Result<()> {
Config::clash().draft().patch_config(patch.clone());
@@ -175,7 +175,7 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
}
};
// 激活配置
// 激活订阅
if mixed_port.is_some()
|| patch.get("secret").is_some()
|| patch.get("external-controller").is_some()
@@ -210,7 +210,7 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
}
}
/// 修改verge的配置
/// 修改verge的订阅
/// 一般都是一个个的修改
pub async fn patch_verge(patch: IVerge) -> Result<()> {
Config::verge().draft().patch_config(patch.clone());
@@ -278,7 +278,7 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
}
/// 更新某个profile
/// 如果更新当前配置就激活配置
/// 如果更新当前订阅就激活订阅
pub async fn update_profile(uid: String, option: Option<PrfOption>) -> Result<()> {
let url_opt = {
let profiles = Config::profiles();
@@ -316,7 +316,7 @@ pub async fn update_profile(uid: String, option: Option<PrfOption>) -> Result<()
Ok(())
}
/// 更新配置
/// 更新订阅
async fn update_core_config() -> Result<()> {
match CoreManager::global().update_config().await {
Ok(_) => {

View File

@@ -197,7 +197,7 @@ pub fn init_resources(package_info: &PackageInfo) -> Result<()> {
}
#[cfg(target_os = "windows")]
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat", "wintun.dll"];
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
#[cfg(not(target_os = "windows"))]
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];