Skip to content

Commit

Permalink
fix: nothing is deflated or gzipped now besides downloaded files
Browse files Browse the repository at this point in the history
  • Loading branch information
amydevs committed Apr 9, 2024
1 parent a1640ab commit b1e4e79
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 104 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exalta_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
once_cell = "1.12"

reqwest = { version = "0.11.0", features = ["stream"] }
reqwest = { version = "0.11.0", features = ["stream", "deflate", "gzip"] }
futures-util = "0.3"
tokio = { version = "1", features = ["full"] }

Expand Down
6 changes: 5 additions & 1 deletion exalta_core/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ pub async fn verify_access_token(access_token: &str) -> Result<bool> {
]);
let userpassparams = [tokenparams, crate::DEFAULT_PARAMS.read().await.to_vec()].concat();
let resp = CLIENT
.post(get_base_url().await.join("account/verifyAccessTokenClient")?)
.post(
get_base_url()
.await
.join("account/verifyAccessTokenClient")?,
)
.form(&userpassparams)
.send()
.await?;
Expand Down
17 changes: 10 additions & 7 deletions exalta_core/src/download/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::{fs, path::PathBuf, sync::Arc};

use once_cell::sync::Lazy;
use reqwest::{header::HeaderMap, Method, Response, Url};
use reqwest::{
header::{HeaderMap, HeaderValue},
Method, Response, Url,
};
use tokio::sync::RwLock;

use crate::{download::err::UpdateError, CLIENT};
Expand All @@ -21,10 +24,7 @@ static BUILD_URL: Lazy<RwLock<Url>> =
pub async fn request_checksums(build_hash: &str, platform: &str) -> Result<ChecksumFiles> {
let url = get_base_url(build_hash, platform, "checksum.json").await?;

let resp = CLIENT
.request(Method::GET, url)
.send()
.await?;
let resp = CLIENT.request(Method::GET, url).send().await?;
let resp_text = resp.text().await?;

Ok(serde_json::from_str::<ChecksumFiles>(&resp_text)?)
Expand Down Expand Up @@ -115,6 +115,7 @@ pub async fn request_file(build_hash: &str, platform: &str, file: &str) -> Resul

let mut defheaders = HeaderMap::new();
defheaders.append("Host", BUILD_URL.read().await.host_str().unwrap().parse()?);
defheaders.append("Accept-Encoding", HeaderValue::from_static("gzip, deflate"));

let resp = CLIENT
.request(Method::GET, url)
Expand All @@ -129,6 +130,8 @@ async fn get_base_url(build_hash: &str, platform: &str, file: &str) -> Result<Ur
crate::Build::Production => "build-release",
crate::Build::Testing => "build",
};
Ok(BUILD_URL.try_read().unwrap().join(format!("{}/{}/{}/{}", build_branch, build_hash, platform, file).as_str())?)
Ok(BUILD_URL
.try_read()
.unwrap()
.join(format!("{}/{}/{}/{}", build_branch, build_hash, platform, file).as_str())?)
}

13 changes: 7 additions & 6 deletions exalta_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ pub mod auth;
pub mod download;
pub mod misc;

static BASE_URL_STRING: Lazy<Url> = Lazy::new(|| Url::parse("https://www.realmofthemadgod.com/").unwrap());
static TESTING_BASE_URL_STRING: Lazy<Url> = Lazy::new(|| Url::parse("https://test.realmofthemadgod.com/").unwrap());
static BASE_URL_STRING: Lazy<Url> =
Lazy::new(|| Url::parse("https://www.realmofthemadgod.com/").unwrap());
static TESTING_BASE_URL_STRING: Lazy<Url> =
Lazy::new(|| Url::parse("https://test.realmofthemadgod.com/").unwrap());

pub static BUILD_TYPE: Lazy<RwLock<Build>> = Lazy::new(|| RwLock::new(Build::Production));
static CLIENT_TOKEN: Lazy<RwLock<String>> = Lazy::new(|| RwLock::new(String::new()));
Expand All @@ -26,7 +28,6 @@ pub static DEFAULT_PARAMS: Lazy<RwLock<Vec<(String, String)>>> = Lazy::new(|| {
static CLIENT: Lazy<Client> = Lazy::new(|| {
let mut defheaders = HeaderMap::new();
defheaders.insert("Accept", "*/*".parse().unwrap());
defheaders.insert("Accept-Encoding", HeaderValue::from_static("gzip, deflate"));
defheaders.insert("X-Unity-Version", HeaderValue::from_static("2020.3.30f1"));
Client::builder()
.http1_title_case_headers()
Expand All @@ -39,7 +40,7 @@ static CLIENT: Lazy<Client> = Lazy::new(|| {
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Build {
Production,
Testing
Testing,
}
impl std::fmt::Display for Build {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand All @@ -56,7 +57,7 @@ pub fn get_base_url_force() -> &'static Url {
fn get_base_url_from_build_type(build_type: &Build) -> &'static Url {
return match *build_type {
Build::Production => &BASE_URL_STRING,
Build::Testing => &TESTING_BASE_URL_STRING
Build::Testing => &TESTING_BASE_URL_STRING,
};
}

Expand Down Expand Up @@ -88,4 +89,4 @@ pub fn coll_to_owned(vec: Vec<(&str, &str)>) -> Vec<(String, String)> {
vec.iter()
.map(|e| (e.0.to_owned(), e.1.to_owned()))
.collect()
}
}
6 changes: 5 additions & 1 deletion exalta_core/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ pub async fn init(game_net: Option<&str>, access_token: Option<&str>) -> Result<
}

let resp = CLIENT
.post(get_base_url().await.join("app/init?platform=standalonewindows64&key=9KnJFxtTvLu2frXv")?)
.post(
get_base_url()
.await
.join("app/init?platform=standalonewindows64&key=9KnJFxtTvLu2frXv")?,
)
.form(&params)
.send()
.await?;
Expand Down
24 changes: 12 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use exalta_core::{
auth::{account::Account, *},
download::err::UpdateError,
};
use main_ext::{LauncherAuth, ResultTimeWrapper, get_device_token, SavedLauncherAuth};
use main_ext::{get_device_token, LauncherAuth, ResultTimeWrapper, SavedLauncherAuth};
use pages::{config, HistoryVec, Route};
use poll_promise::Promise;
use tokio::{runtime::Runtime, sync::RwLock};
Expand Down Expand Up @@ -40,7 +40,7 @@ fn main() {
} else {
_cc.egui_ctx.set_visuals(egui::Visuals::light());
}
Box::new(ExaltaLauncher::default())
Box::<ExaltaLauncher>::default()
}),
);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ struct ExaltaLauncher {

impl Default for ExaltaLauncher {
fn default() -> Self {
let entry = keyring::Entry::new(&"exalt", &"jsondata");
let entry = keyring::Entry::new("exalt", "jsondata");

let mut run_res = ResultTimeWrapper::default();

Expand Down Expand Up @@ -109,13 +109,11 @@ impl Default for ExaltaLauncher {
config.build_hash = buildhash;
config.save()?;
}
} else {
if &registry_build_hash == &buildhash {
config.build_hash = buildhash;
config.save()?;
} else if &config.build_hash != &buildhash {
return Err(update_error);
}
} else if &registry_build_hash == &buildhash {
config.build_hash = buildhash;
config.save()?;
} else if &config.build_hash != &buildhash {
return Err(update_error);
}

#[cfg(not(windows))]
Expand Down Expand Up @@ -176,10 +174,12 @@ impl Default for ExaltaLauncher {
if let Ok(foundauthvec) = serde_json::from_str::<SavedLauncherAuth>(&val) {
self_inst.saved_auth = foundauthvec;
if self_inst.config.save_login {
if let Some(foundauth) = self_inst.saved_auth.saved.get(self_inst.saved_auth.current) {
if let Some(foundauth) =
self_inst.saved_auth.saved.get(self_inst.saved_auth.current)
{
self_inst.auth = foundauth.clone();
}

let res = self_inst.login();
if self_inst.run_res.result.is_ok() {
self_inst.run_res = ResultTimeWrapper::default();
Expand Down
58 changes: 25 additions & 33 deletions src/main_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,20 @@ use std::collections::HashMap;

#[derive(Serialize, Deserialize, Debug, Clone)]

#[derive(Default)]
pub struct SavedLauncherAuth {
pub saved: Vec<LauncherAuth>,
pub current: usize,
}
impl Default for SavedLauncherAuth {
fn default() -> Self {
Self {
saved: Vec::new(),
current: 0,
}
}
}


#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Default)]
pub struct LauncherAuth {
pub guid: String,
pub password: String,
}
impl Default for LauncherAuth {
fn default() -> Self {
Self {
guid: String::new(),
password: String::new()
}
}
}

pub struct ResultTimeWrapper {
pub result: Result<(), Box<dyn std::error::Error>>,
pub time: std::time::Instant,
Expand All @@ -43,8 +31,8 @@ impl Default for ResultTimeWrapper {
}

pub fn get_device_token() -> String {
use sha1::{Digest, Sha1};
use smbioslib::*;
use sha1::{Sha1, Digest};
let mut concat = String::new();

if let Ok(data) = table_load_from_device() {
Expand All @@ -59,8 +47,8 @@ pub fn get_device_token() -> String {
if concat.is_empty() {
concat += "None0"
}
if let Some(d) = get_product_id().ok() {

if let Ok(d) = get_product_id() {
concat += &d;
}

Expand All @@ -74,14 +62,15 @@ pub fn get_device_token() -> String {
#[cfg(windows)]
fn get_product_id() -> Result<String, Box<dyn std::error::Error>> {
use wmi::*;

let com_con = COMLibrary::new()?;
let wmi_con = WMIConnection::new(com_con.into())?;
let results: Vec<HashMap<String, Variant>> = wmi_con.raw_query("SELECT * FROM Win32_OperatingSystem")?;
let results: Vec<HashMap<String, Variant>> =
wmi_con.raw_query("SELECT * FROM Win32_OperatingSystem")?;
for os in results {
if let Some(var) = os.get("SerialNumber") {
if let Variant::String(s) = var {
return Ok(s.clone())
return Ok(s.clone());
}
}
}
Expand All @@ -92,23 +81,26 @@ fn get_product_id() -> Result<String, Box<dyn std::error::Error>> {
)))
}

#[cfg(target_os="linux")]
#[cfg(target_os = "linux")]
fn get_product_id() -> Result<String, Box<dyn std::error::Error>> {
use std::process::Command;

use regex::Regex;

let output= Command::new("wine")
.args(&["wmic", "os", "get" , "SerialNumber"])
let output = Command::new("wine")
.args(&["wmic", "os", "get", "SerialNumber"])
.output()?;
let out = String::from_utf8_lossy(
&output.stdout.clone()
.iter()
.filter(|e| **e != 0)
.map(|e| *e)
.collect::<Vec<u8>>()
).to_string();

&output
.stdout
.clone()
.iter()
.filter(|e| **e != 0)
.map(|e| *e)
.collect::<Vec<u8>>(),
)
.to_string();

if let Some(s) = Regex::new(r"SerialNumber\s*\r\n([^\s\\]*)")?.captures(&out) {
if let Some(e) = s.get(1) {
return Ok(e.as_str().to_string());
Expand All @@ -127,4 +119,4 @@ where
{
let mut i = 0;
move |item| (f(i, item), i += 1).0
}
}
4 changes: 2 additions & 2 deletions src/pages/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Default for AppConfig {
dark: false,
save_login: true,
build_hash: String::new(),
game_folder_path: game_folder_path,
game_folder_path,
}
}
}
Expand All @@ -36,7 +36,7 @@ impl AppConfig {
fn get_location() -> Result<PathBuf, Box<dyn std::error::Error>> {
let location = match ProjectDirs::from("com", "AyanAmy", "Exalta") {
Some(v) => {
std::fs::create_dir_all(&v.config_dir())?;
std::fs::create_dir_all(v.config_dir())?;
v.config_dir().to_path_buf()
}
None => std::env::current_dir()?,
Expand Down
Loading

0 comments on commit b1e4e79

Please sign in to comment.