refactor: tun mode is turned on and off, does not depend on services, and does not affect other configurations

This commit is contained in:
huzibaca
2024-10-05 22:45:59 +08:00
parent 1178f7c892
commit 0541a0c69f
6 changed files with 28 additions and 158 deletions

View File

@@ -350,43 +350,3 @@ pub(super) async fn stop_core_by_service() -> Result<()> {
Ok(())
}
/// set dns by service
pub async fn set_dns_by_service() -> Result<()> {
let url = format!("{SERVICE_URL}/set_dns");
let res = reqwest::ClientBuilder::new()
.no_proxy()
.build()?
.post(url)
.send()
.await?
.json::<JsonResponse>()
.await
.context("failed to connect to the Clash Verge Service")?;
if res.code != 0 {
bail!(res.msg);
}
Ok(())
}
/// unset dns by service
pub async fn unset_dns_by_service() -> Result<()> {
let url = format!("{SERVICE_URL}/unset_dns");
let res = reqwest::ClientBuilder::new()
.no_proxy()
.build()?
.post(url)
.send()
.await?
.json::<JsonResponse>()
.await
.context("failed to connect to the Clash Verge Service")?;
if res.code != 0 {
bail!(res.msg);
}
Ok(())
}