Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
4ff625f2
There was an error fetching the commit references. Please try again later.
Unverified
Commit
4ff625f2
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: enable customize guard duration
parent
e38dcd85
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src-tauri/src/core/verge.rs
+16
-3
16 additions, 3 deletions
src-tauri/src/core/verge.rs
with
16 additions
and
3 deletions
src-tauri/src/core/verge.rs
+
16
−
3
View file @
4ff625f2
...
...
@@ -31,6 +31,9 @@ pub struct VergeConfig {
/// set system proxy bypass
pub
system_proxy_bypass
:
Option
<
String
>
,
/// proxy guard duration
pub
proxy_guard_duration
:
Option
<
u64
>
,
}
static
VERGE_CONFIG
:
&
str
=
"verge.yaml"
;
...
...
@@ -105,7 +108,7 @@ impl Verge {
}
// launchs the system proxy guard
Verge
::
guard_proxy
(
10
,
self
.guard_state
.clone
());
Verge
::
guard_proxy
(
self
.guard_state
.clone
());
}
/// reset the sysproxy
...
...
@@ -248,10 +251,13 @@ impl Verge {
if
patch
.enable_proxy_guard
.is_some
()
{
self
.config.enable_proxy_guard
=
patch
.enable_proxy_guard
;
}
if
patch
.proxy_guard_duration
.is_some
()
{
self
.config.proxy_guard_duration
=
patch
.proxy_guard_duration
;
}
// relaunch the guard
if
patch
.enable_system_proxy
.is_some
()
||
patch
.enable_proxy_guard
.is_some
()
{
Verge
::
guard_proxy
(
10
,
self
.guard_state
.clone
());
Verge
::
guard_proxy
(
self
.guard_state
.clone
());
}
self
.config
.save_file
()
...
...
@@ -261,7 +267,7 @@ impl Verge {
impl
Verge
{
/// launch a system proxy guard
/// read config from file directly
pub
fn
guard_proxy
(
wait_secs
:
u64
,
guard_state
:
Arc
<
Mutex
<
bool
>>
)
{
pub
fn
guard_proxy
(
guard_state
:
Arc
<
Mutex
<
bool
>>
)
{
use
tokio
::
time
::{
sleep
,
Duration
};
tauri
::
async_runtime
::
spawn
(
async
move
{
...
...
@@ -273,6 +279,9 @@ impl Verge {
*
state
=
true
;
std
::
mem
::
drop
(
state
);
// default duration is 10s
let
mut
wait_secs
=
10u64
;
loop
{
sleep
(
Duration
::
from_secs
(
wait_secs
))
.await
;
...
...
@@ -282,6 +291,10 @@ impl Verge {
let
enable_proxy
=
verge
.config.enable_system_proxy
.unwrap_or
(
false
);
let
enable_guard
=
verge
.config.enable_proxy_guard
.unwrap_or
(
false
);
let
guard_duration
=
verge
.config.proxy_guard_duration
.unwrap_or
(
10
);
// update duration
wait_secs
=
guard_duration
;
// stop loop
if
!
enable_guard
||
!
enable_proxy
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment