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
b635e648
There was an error fetching the commit references. Please try again later.
Unverified
Commit
b635e648
authored
2 years ago
by
GyDi
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: adjust reset proxy
parent
20a194b4
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/sysopt.rs
+22
-23
22 additions, 23 deletions
src-tauri/src/core/sysopt.rs
with
22 additions
and
23 deletions
src-tauri/src/core/sysopt.rs
+
22
−
23
View file @
b635e648
...
...
@@ -68,7 +68,7 @@ impl Sysopt {
self
.cur_sysproxy
.as_ref
()
.unwrap
()
.set_system_proxy
()
?
;
}
//
launchs
the system proxy guard
//
run
the system proxy guard
self
.guard_proxy
();
Ok
(())
}
...
...
@@ -99,29 +99,28 @@ impl Sysopt {
/// reset the sysproxy
pub
fn
reset_sysproxy
(
&
mut
self
)
->
Result
<
()
>
{
if
self
.cur_sysproxy
.is_none
()
{
return
Ok
(());
}
let
mut
cur
=
self
.cur_sysproxy
.take
()
.unwrap
();
match
self
.old_sysproxy
.take
()
{
Some
(
old
)
=>
{
// 如果原代理设置和当前的设置是一样的,需要关闭
// 否则就恢复原代理设置
if
old
.enable
&&
old
.host
==
cur
.host
&&
old
.port
==
cur
.port
{
cur
.enable
=
false
;
cur
.set_system_proxy
()
?
;
}
else
{
old
.set_system_proxy
()
?
;
}
}
None
=>
{
if
cur
.enable
{
cur
.enable
=
false
;
cur
.set_system_proxy
()
?
;
}
let
cur
=
self
.cur_sysproxy
.take
();
if
let
Some
(
mut
old
)
=
self
.old_sysproxy
.take
()
{
// 如果原代理和当前代理 端口一致,就disable关闭,否则就恢复原代理设置
// 当前没有设置代理的时候,不确定旧设置是否和当前一致,全关了
let
port_same
=
cur
.map_or
(
true
,
|
cur
|
old
.port
==
cur
.port
);
if
old
.enable
&&
port_same
{
old
.enable
=
false
;
log
::
info!
(
target
:
"app"
,
"reset proxy by disabling the original proxy"
);
}
else
{
log
::
info!
(
target
:
"app"
,
"reset proxy to the original proxy"
);
}
old
.set_system_proxy
()
?
;
}
else
if
let
Some
(
mut
cur
)
=
cur
{
// 没有原代理,就按现在的代理设置disable即可
log
::
info!
(
target
:
"app"
,
"reset proxy by disabling the current proxy"
);
cur
.enable
=
false
;
cur
.set_system_proxy
()
?
;
}
else
{
log
::
info!
(
target
:
"app"
,
"reset proxy with no action"
);
}
Ok
(())
...
...
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