mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:53:44 +08:00
Feat: Provide a switch for allowing invalid certificates (#450)
This commit is contained in:
parent
c309410965
commit
66db0a4751
@ -84,6 +84,12 @@ pub struct PrfOption {
|
|||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub update_interval: Option<u64>,
|
pub update_interval: Option<u64>,
|
||||||
|
|
||||||
|
/// for `remote` profile
|
||||||
|
/// disable certificate validation
|
||||||
|
/// default is `false`
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub danger_accept_invalid_certs: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrfOption {
|
impl PrfOption {
|
||||||
@ -93,6 +99,7 @@ impl PrfOption {
|
|||||||
a.user_agent = b.user_agent.or(a.user_agent);
|
a.user_agent = b.user_agent.or(a.user_agent);
|
||||||
a.with_proxy = b.with_proxy.or(a.with_proxy);
|
a.with_proxy = b.with_proxy.or(a.with_proxy);
|
||||||
a.self_proxy = b.self_proxy.or(a.self_proxy);
|
a.self_proxy = b.self_proxy.or(a.self_proxy);
|
||||||
|
a.danger_accept_invalid_certs = b.danger_accept_invalid_certs.or(a.danger_accept_invalid_certs);
|
||||||
a.update_interval = b.update_interval.or(a.update_interval);
|
a.update_interval = b.update_interval.or(a.update_interval);
|
||||||
Some(a)
|
Some(a)
|
||||||
}
|
}
|
||||||
@ -170,6 +177,7 @@ impl PrfItem {
|
|||||||
let opt_ref = option.as_ref();
|
let opt_ref = option.as_ref();
|
||||||
let with_proxy = opt_ref.map_or(false, |o| o.with_proxy.unwrap_or(false));
|
let with_proxy = opt_ref.map_or(false, |o| o.with_proxy.unwrap_or(false));
|
||||||
let self_proxy = opt_ref.map_or(false, |o| o.self_proxy.unwrap_or(false));
|
let self_proxy = opt_ref.map_or(false, |o| o.self_proxy.unwrap_or(false));
|
||||||
|
let accept_invalid_certs = opt_ref.map_or(false, |o| o.danger_accept_invalid_certs.unwrap_or(false));
|
||||||
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
||||||
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
||||||
|
|
||||||
@ -216,6 +224,7 @@ impl PrfItem {
|
|||||||
None => "clash-verge/unknown".to_string(),
|
None => "clash-verge/unknown".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
builder = builder.danger_accept_invalid_certs(accept_invalid_certs);
|
||||||
builder = builder.user_agent(user_agent.unwrap_or(version));
|
builder = builder.user_agent(user_agent.unwrap_or(version));
|
||||||
|
|
||||||
let resp = builder.build()?.get(url).send().await?;
|
let resp = builder.build()?.get(url).send().await?;
|
||||||
|
@ -243,6 +243,7 @@ pub async fn resolve_scheme(param: String) {
|
|||||||
user_agent: None,
|
user_agent: None,
|
||||||
with_proxy: Some(true),
|
with_proxy: Some(true),
|
||||||
self_proxy: None,
|
self_proxy: None,
|
||||||
|
danger_accept_invalid_certs: None,
|
||||||
update_interval: None,
|
update_interval: None,
|
||||||
};
|
};
|
||||||
if let Ok(item) = PrfItem::from_url(url, None, None, Some(option)).await {
|
if let Ok(item) = PrfItem::from_url(url, None, None, Some(option)).await {
|
||||||
|
@ -269,6 +269,17 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
</StyledBox>
|
</StyledBox>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="option.danger_accept_invalid_certs"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<StyledBox>
|
||||||
|
<InputLabel>{t("Accept Invalid Certs (Danger)")}</InputLabel>
|
||||||
|
<Switch checked={field.value} {...field} color="primary" />
|
||||||
|
</StyledBox>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
"Update Interval": "Update Interval",
|
"Update Interval": "Update Interval",
|
||||||
"Use System Proxy": "Use System Proxy",
|
"Use System Proxy": "Use System Proxy",
|
||||||
"Use Clash Proxy": "Use Clash Proxy",
|
"Use Clash Proxy": "Use Clash Proxy",
|
||||||
|
"Accept Invalid Certs (Danger)": "Allows Invalid Certificates (Danger)",
|
||||||
|
|
||||||
"Settings": "Settings",
|
"Settings": "Settings",
|
||||||
"Clash Setting": "Clash Setting",
|
"Clash Setting": "Clash Setting",
|
||||||
|
@ -65,6 +65,9 @@
|
|||||||
"Descriptions": "Описания",
|
"Descriptions": "Описания",
|
||||||
"Subscription URL": "URL подписки",
|
"Subscription URL": "URL подписки",
|
||||||
"Update Interval": "Интервал обновления",
|
"Update Interval": "Интервал обновления",
|
||||||
|
"Use System Proxy": "Использовать системный прокси для обновления",
|
||||||
|
"Use Clash Proxy": "Использовать прокси Clash для обновления",
|
||||||
|
"Accept Invalid Certs (Danger)": "Принимать недействительные сертификаты (Опасно)",
|
||||||
|
|
||||||
"Settings": "Настройки",
|
"Settings": "Настройки",
|
||||||
"Clash Setting": "Настройки Clash",
|
"Clash Setting": "Настройки Clash",
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
"Update Interval": "更新间隔",
|
"Update Interval": "更新间隔",
|
||||||
"Use System Proxy": "使用系统代理更新",
|
"Use System Proxy": "使用系统代理更新",
|
||||||
"Use Clash Proxy": "使用Clash代理更新",
|
"Use Clash Proxy": "使用Clash代理更新",
|
||||||
|
"Accept Invalid Certs (Danger)": "允许无效证书 (危险)",
|
||||||
|
|
||||||
"Settings": "设置",
|
"Settings": "设置",
|
||||||
"Clash Setting": "Clash 设置",
|
"Clash Setting": "Clash 设置",
|
||||||
|
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@ -173,6 +173,7 @@ interface IProfileOption {
|
|||||||
with_proxy?: boolean;
|
with_proxy?: boolean;
|
||||||
self_proxy?: boolean;
|
self_proxy?: boolean;
|
||||||
update_interval?: number;
|
update_interval?: number;
|
||||||
|
danger_accept_invalid_certs?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProfilesConfig {
|
interface IProfilesConfig {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user