feat(updater) support proxy (#891)

* add proxy support

Signed-off-by: San Zhang <sanzhang@mail.com>

* 1. change string to url for proxy type
2. add proxy option in js api

Signed-off-by: San Zhang <sanzhang@mail.com>

* fix fmt issue

Signed-off-by: San Zhang <sanzhang@mail.com>

* Update plugins/updater/guest-js/index.ts

---------

Signed-off-by: San Zhang <sanzhang@mail.com>
This commit is contained in:
Zhang San
2024-01-17 22:47:26 +08:00
committed by GitHub
parent 8a3db790b8
commit 4e2e77580c
3 changed files with 45 additions and 7 deletions
+6
View File
@@ -11,6 +11,7 @@ use std::{
sync::atomic::{AtomicBool, Ordering},
time::Duration,
};
use url::Url;
#[derive(Debug, Serialize)]
#[serde(tag = "event", content = "data")]
@@ -42,6 +43,7 @@ pub(crate) async fn check<R: Runtime>(
pending: State<'_, PendingUpdate>,
headers: Option<Vec<(String, String)>>,
timeout: Option<u64>,
proxy: Option<String>,
target: Option<String>,
) -> Result<Metadata> {
let mut builder = app.updater_builder();
@@ -53,6 +55,10 @@ pub(crate) async fn check<R: Runtime>(
if let Some(timeout) = timeout {
builder = builder.timeout(Duration::from_secs(timeout));
}
if let Some(ref proxy) = proxy {
let url = Url::parse(proxy.as_str())?;
builder = builder.proxy(url);
}
if let Some(target) = target {
builder = builder.target(target);
}