feat: update profile supports noproxy

This commit is contained in:
GyDi
2022-01-16 22:57:42 +08:00
parent ab82d2af4f
commit ce00fc502b
4 changed files with 29 additions and 17 deletions

View File

@@ -23,11 +23,20 @@ fn parse_string<T: FromStr>(target: &str, key: &str) -> Option<T> {
}
/// fetch and parse the profile
pub async fn fetch_profile(url: &str) -> Option<ProfileResponse> {
let resp = match reqwest::get(url).await {
Ok(res) => res,
pub async fn fetch_profile(url: &str, with_proxy: bool) -> Option<ProfileResponse> {
let builder = reqwest::ClientBuilder::new();
let client = match with_proxy {
true => builder.build(),
false => builder.no_proxy().build(),
};
let resp = match client {
Ok(client) => match client.get(url).send().await {
Ok(res) => res,
Err(_) => return None,
},
Err(_) => return None,
};
let header = resp.headers();
// parse the Subscription Userinfo