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
600134a3
There was an error fetching the commit references. Please try again later.
Unverified
Commit
600134a3
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: fetch profile with system proxy, close #249
parent
df14af73
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/data/prfitem.rs
+18
-7
18 additions, 7 deletions
src-tauri/src/data/prfitem.rs
with
18 additions
and
7 deletions
src-tauri/src/data/prfitem.rs
+
18
−
7
View file @
600134a3
...
...
@@ -4,6 +4,7 @@ use reqwest::StatusCode;
use
serde
::{
Deserialize
,
Serialize
};
use
serde_yaml
::
Mapping
;
use
std
::
fs
;
use
sysproxy
::
Sysproxy
;
#[derive(Debug,
Clone,
Deserialize,
Serialize)]
pub
struct
PrfItem
{
...
...
@@ -187,12 +188,10 @@ impl PrfItem {
let
self_proxy
=
opt_ref
.map_or
(
false
,
|
o
|
o
.self_proxy
.unwrap_or
(
false
));
let
user_agent
=
opt_ref
.map_or
(
None
,
|
o
|
o
.user_agent
.clone
());
let
mut
builder
=
reqwest
::
ClientBuilder
::
new
();
let
mut
builder
=
reqwest
::
ClientBuilder
::
new
()
.no_proxy
()
;
if
!
with_proxy
&&
!
self_proxy
{
builder
=
builder
.no_proxy
();
}
else
if
self_proxy
{
// 使用软件自己的代理
// 使用软件自己的代理
if
self_proxy
{
let
data
=
super
::
Data
::
global
();
let
port
=
data
.clash
.lock
()
.info.port
.clone
();
let
port
=
port
.ok_or
(
anyhow
::
anyhow!
(
"failed to get clash info port"
))
?
;
...
...
@@ -208,6 +207,18 @@ impl PrfItem {
builder
=
builder
.proxy
(
proxy
);
}
}
// 使用系统代理
else
if
with_proxy
{
match
Sysproxy
::
get_system_proxy
()
{
Ok
(
p
@
Sysproxy
{
enable
:
true
,
..
})
=>
{
let
proxy_scheme
=
format!
(
"http://{}:{}"
,
p
.host
,
p
.port
);
if
let
Ok
(
proxy
)
=
reqwest
::
Proxy
::
http
(
&
proxy_scheme
)
{
builder
=
builder
.proxy
(
proxy
);
}
}
_
=>
{}
};
}
let
version
=
unsafe
{
dirs
::
APP_VERSION
};
let
version
=
format!
(
"clash-verge/{version}"
);
...
...
@@ -217,9 +228,9 @@ impl PrfItem {
let
status_code
=
resp
.status
();
if
!
StatusCode
::
is_success
(
&
status_code
)
{
bail!
(
"
Error requesting remote profile.
"
)
bail!
(
"
failed to fetch remote profile with status {status_code}
"
)
}
let
header
=
resp
.headers
();
// parse the Subscription Userinfo
...
...
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