mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-22 20:32:15 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0218267ed5 |
+2
-2
@@ -75,7 +75,7 @@
|
||||
"react-dom": "19.3.1",
|
||||
"react-error-boundary": "6.1.6",
|
||||
"react-hook-form": "^7.88.0",
|
||||
"react-i18next": "18.0.1",
|
||||
"react-i18next": "18.0.3",
|
||||
"react-markdown": "10.1.0",
|
||||
"react-router": "^8.4.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
@@ -116,7 +116,7 @@
|
||||
"https-proxy-agent": "^9.1.0",
|
||||
"husky": "^9.1.7",
|
||||
"jiti": "^2.7.0",
|
||||
"knip": "6.45.1",
|
||||
"knip": "6.47.0",
|
||||
"lint-staged": "^17.5.1",
|
||||
"sass": "^1.104.1",
|
||||
"tar": "^7.5.22",
|
||||
|
||||
Generated
+10
-10
@@ -284,8 +284,8 @@ importers:
|
||||
specifier: ^7.88.0
|
||||
version: 7.88.0(react@19.3.1)
|
||||
react-i18next:
|
||||
specifier: 18.0.1
|
||||
version: 18.0.1(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3)
|
||||
specifier: 18.0.3
|
||||
version: 18.0.3(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3)
|
||||
react-markdown:
|
||||
specifier: 10.1.0
|
||||
version: 10.1.0(@types/react@19.3.0)(react@19.3.1)(supports-color@7.2.0)
|
||||
@@ -402,8 +402,8 @@ importers:
|
||||
specifier: ^2.7.0
|
||||
version: 2.7.0
|
||||
knip:
|
||||
specifier: 6.45.1
|
||||
version: 6.45.1
|
||||
specifier: 6.47.0
|
||||
version: 6.47.0
|
||||
lint-staged:
|
||||
specifier: ^17.5.1
|
||||
version: 17.5.1
|
||||
@@ -3345,8 +3345,8 @@ packages:
|
||||
keyv@5.6.0:
|
||||
resolution: {integrity: sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==}
|
||||
|
||||
knip@6.45.1:
|
||||
resolution: {integrity: sha512-zp3zXKy2cZWiIttdlWU5fisKxVQaLSU6471ej0KGz1GdHdaHxpzTAO/LIyFNc3gU3v1W7LJaqvYumoO3l/u+6A==}
|
||||
knip@6.47.0:
|
||||
resolution: {integrity: sha512-nYmQnk0YqDXIJrYViJz88c8xw3tBDkpuAmofo58EkVPnKr6DnRKYtf6oIqcGVHZvXDE+gtmFuYx277/QsWng+A==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
hasBin: true
|
||||
|
||||
@@ -3792,8 +3792,8 @@ packages:
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17 || ^18 || ^19
|
||||
|
||||
react-i18next@18.0.1:
|
||||
resolution: {integrity: sha512-kPWXI0E/lrPj3+/umcKNzYZVnWmEedLiamMzDIHfbs+5ANf6yzvlZsjKou8f7kaGkfMMDLIZBejV+4aSN1CyBw==}
|
||||
react-i18next@18.0.3:
|
||||
resolution: {integrity: sha512-S84rtVuaKuiRtoCOspbGEaDlFjka+KvK/A5YCOr4LQ41XF3iJOrJ5rqQTD/jJHFVUf6X1i4ZMN5PGGgpz8NN6g==}
|
||||
engines: {node: '>=22'}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
@@ -7297,7 +7297,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@keyv/serialize': 1.1.1
|
||||
|
||||
knip@6.45.1:
|
||||
knip@6.47.0:
|
||||
dependencies:
|
||||
formatly: 0.11.4
|
||||
get-tsconfig: 4.14.3
|
||||
@@ -7883,7 +7883,7 @@ snapshots:
|
||||
dependencies:
|
||||
react: 19.3.1
|
||||
|
||||
react-i18next@18.0.1(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3):
|
||||
react-i18next@18.0.3(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3):
|
||||
dependencies:
|
||||
html-parse-stringify: 4.0.1
|
||||
i18next: 27.0.1(typescript@6.0.3)
|
||||
|
||||
@@ -112,10 +112,6 @@ pub struct IVerge {
|
||||
pub auto_switch_selector_group: Option<bool>,
|
||||
|
||||
pub auto_check_update: Option<bool>,
|
||||
|
||||
/// `auto`, `github` or `github_proxy`
|
||||
pub update_channel: Option<String>,
|
||||
|
||||
pub default_latency_test: Option<String>,
|
||||
|
||||
pub default_latency_timeout: Option<i16>,
|
||||
@@ -465,7 +461,6 @@ impl IVerge {
|
||||
patch_opt_field!(self, patch, auto_close_connection);
|
||||
patch_opt_field!(self, patch, auto_switch_selector_group);
|
||||
patch_opt_field!(self, patch, auto_check_update);
|
||||
patch_opt_field!(self, patch, update_channel);
|
||||
patch_opt_field!(self, patch, default_latency_test);
|
||||
patch_opt_field!(self, patch, default_latency_timeout);
|
||||
patch_opt_field!(self, patch, enable_auto_delay_detection);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use crate::{
|
||||
config::{Config, MixedPort},
|
||||
singleton,
|
||||
utils::dirs,
|
||||
};
|
||||
use crate::{config::Config, singleton, utils::dirs};
|
||||
use anyhow::{Context as _, Result};
|
||||
use chrono::Utc;
|
||||
use clash_verge_logging::{Type, logging};
|
||||
@@ -201,40 +197,16 @@ pub enum DownloadEvent {
|
||||
}
|
||||
|
||||
const MIRRORS: [&str; 2] = ["https://update.hwdns.net/", "https://gh-proxy.org/"];
|
||||
const GITHUB_ENDPOINT: &str =
|
||||
"https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update.json";
|
||||
/// A source delivering less than this per window is dropped for the next one.
|
||||
const MIN_PROGRESS: u64 = 1024 * 1024;
|
||||
const PROGRESS_WINDOW: Duration = Duration::from_secs(30);
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
enum UpdateChannel {
|
||||
/// The configured endpoints with mirror fallbacks.
|
||||
Auto,
|
||||
Github,
|
||||
/// GitHub through the Core's mixed port.
|
||||
GithubProxy,
|
||||
}
|
||||
|
||||
impl UpdateChannel {
|
||||
async fn current() -> Self {
|
||||
match Config::verge().await.latest_arc().update_channel.as_deref() {
|
||||
Some("github") => Self::Github,
|
||||
Some("github_proxy") => Self::GithubProxy,
|
||||
_ => Self::Auto,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The manifest's URL, then the other mirror, then GitHub itself; only GitHub outside `Auto`.
|
||||
fn download_sources(url: &tauri::Url, channel: UpdateChannel) -> Vec<tauri::Url> {
|
||||
/// The manifest's URL, then the other mirror, then GitHub itself.
|
||||
fn download_sources(url: &tauri::Url) -> Vec<tauri::Url> {
|
||||
let origin = MIRRORS
|
||||
.iter()
|
||||
.find_map(|mirror| url.as_str().strip_prefix(mirror))
|
||||
.unwrap_or(url.as_str());
|
||||
if channel != UpdateChannel::Auto {
|
||||
return vec![tauri::Url::parse(origin).unwrap_or_else(|_| url.clone())];
|
||||
}
|
||||
let mut sources = vec![url.clone()];
|
||||
if origin.starts_with("https://github.com/") {
|
||||
let candidates = MIRRORS.iter().map(|mirror| format!("{mirror}{origin}"));
|
||||
@@ -252,7 +224,7 @@ fn download_sources(url: &tauri::Url, channel: UpdateChannel) -> Vec<tauri::Url>
|
||||
/// Tries every source with a throughput floor, then again stopping only on a stall, so a link
|
||||
/// that is slow everywhere still finishes.
|
||||
async fn download(update: &Update, on_event: impl Fn(DownloadEvent) + Sync) -> Result<Vec<u8>> {
|
||||
let sources = download_sources(&update.download_url, UpdateChannel::current().await);
|
||||
let sources = download_sources(&update.download_url);
|
||||
let mut last_error = None;
|
||||
for floor in [MIN_PROGRESS, 1] {
|
||||
for url in &sources {
|
||||
@@ -310,16 +282,7 @@ impl SilentUpdater {
|
||||
/// Checks the server; Windows receives `/LANG` to suppress the NSIS language dialog,
|
||||
/// see `packages/windows/installer.nsi`.
|
||||
async fn check(app_handle: &tauri::AppHandle) -> Result<Option<Update>> {
|
||||
let channel = UpdateChannel::current().await;
|
||||
let mut updater_builder = app_handle.updater_builder();
|
||||
if channel != UpdateChannel::Auto {
|
||||
updater_builder = updater_builder.endpoints(vec![tauri::Url::parse(GITHUB_ENDPOINT)?])?;
|
||||
}
|
||||
if channel == UpdateChannel::GithubProxy {
|
||||
let port = MixedPort::desired().await;
|
||||
// The resulting `Update` keeps this proxy for its download.
|
||||
updater_builder = updater_builder.proxy(tauri::Url::parse(&format!("http://127.0.0.1:{port}"))?);
|
||||
}
|
||||
let updater_builder = app_handle.updater_builder();
|
||||
#[cfg(target_os = "windows")]
|
||||
let updater_builder = {
|
||||
let verge_lang = Config::verge().await.latest_arc().language.clone();
|
||||
@@ -620,7 +583,8 @@ impl SilentUpdater {
|
||||
|
||||
logging!(info, Type::System, "Silent updater: checking for updates...");
|
||||
|
||||
let update = match Self::check(app_handle).await {
|
||||
let updater = app_handle.updater()?;
|
||||
let update = match updater.check().await {
|
||||
Ok(Some(update)) => update,
|
||||
Ok(None) => {
|
||||
logging!(info, Type::System, "Silent updater: no update available");
|
||||
@@ -628,7 +592,7 @@ impl SilentUpdater {
|
||||
}
|
||||
Err(e) => {
|
||||
logging!(warn, Type::System, "Silent updater: check failed: {e}");
|
||||
return Err(e);
|
||||
return Err(e.into());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ verge_registry! {
|
||||
auto_close_connection => NoEffect;
|
||||
auto_switch_selector_group => NoEffect;
|
||||
auto_check_update => NoEffect;
|
||||
update_channel => NoEffect;
|
||||
default_latency_test => NoEffect;
|
||||
default_latency_timeout => NoEffect;
|
||||
enable_auto_delay_detection => NoEffect;
|
||||
|
||||
@@ -418,8 +418,6 @@ export type IVerge_Deserialize = {
|
||||
auto_close_connection?: boolean | null
|
||||
auto_switch_selector_group?: boolean | null
|
||||
auto_check_update?: boolean | null
|
||||
/** `auto`, `github` or `github_proxy` */
|
||||
update_channel?: string | null
|
||||
default_latency_test?: string | null
|
||||
default_latency_timeout?: number | null
|
||||
enable_auto_delay_detection?: boolean | null
|
||||
@@ -511,8 +509,6 @@ export type IVerge_Serialize = {
|
||||
auto_close_connection: boolean | null
|
||||
auto_switch_selector_group: boolean | null
|
||||
auto_check_update: boolean | null
|
||||
/** `auto`, `github` or `github_proxy` */
|
||||
update_channel: string | null
|
||||
default_latency_test: string | null
|
||||
default_latency_timeout: number | null
|
||||
enable_auto_delay_detection: boolean | null
|
||||
|
||||
Reference in New Issue
Block a user