diff --git a/src/global.rs b/src/global.rs index a1d46cc..6efb696 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1,12 +1,12 @@ +use crate::http_async; use crate::structs::PrintPrefix; use colored::Colorize; use once_cell::sync::Lazy; -use std::collections::HashMap; -use std::sync::Mutex; -use std::pin::Pin; -use std::future::Future; -use crate::http_async; use serde_json::Value; +use std::collections::HashMap; +use std::future::Future; +use std::pin::Pin; +use std::sync::Mutex; pub const GH_OWNER: &str = "mxve"; pub const GH_REPO: &str = "alterware-launcher"; @@ -15,9 +15,7 @@ pub const GH_IW4X_REPO: &str = "iw4x-client"; pub const DEFAULT_MASTER: &str = "https://cdn.alterware.ovh"; pub const BACKUP_MASTER: &str = "https://cdn.iw4x.getserve.rs"; -pub static MASTER_URL: Lazy> = Lazy::new(|| { - Mutex::new(String::from(DEFAULT_MASTER)) -}); +pub static MASTER_URL: Lazy> = Lazy::new(|| Mutex::new(String::from(DEFAULT_MASTER))); pub static IS_OFFLINE: Lazy> = Lazy::new(|| Mutex::new(false)); @@ -61,7 +59,9 @@ pub static PREFIXES: Lazy> = Lazy::new(|| { ]) }); -pub fn check_connectivity(master_url: Option) -> Pin + Send>> { +pub fn check_connectivity( + master_url: Option, +) -> Pin + Send>> { Box::pin(async move { let retry = master_url.is_some(); if !retry { @@ -75,7 +75,8 @@ pub fn check_connectivity(master_url: Option) -> Pin = http_async::get_json("https://ip2asn.getserve.rs/v1/as/ip/self").await; + let asn_response: Result = + http_async::get_json("https://ip2asn.getserve.rs/v1/as/ip/self").await; let mut switched_to_backup = false; @@ -83,7 +84,10 @@ pub fn check_connectivity(master_url: Option) -> Pin(url: &str) -> Result(&body) - .map_err(|e| format!("Failed to parse JSON: {}", e)) + serde_json::from_slice::(&body).map_err(|e| format!("Failed to parse JSON: {}", e)) } diff --git a/src/main.rs b/src/main.rs index 6b9f181..87a909a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -703,7 +703,7 @@ async fn main() { cfg.offline = true; arg_remove(&mut args, "--offline"); } - + if arg_bool(&args, "--skip-connectivity-check") { cfg.skip_connectivity_check = true; arg_remove(&mut args, "--skip-connectivity-check");