From f6ef6031fca4168901b71d3410ce9d353ba002cd Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:37:06 -0500 Subject: [PATCH] Add iOS jp asset hash --- src/router/global.rs | 5 +++-- src/router/start.rs | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/router/global.rs b/src/router/global.rs index 58594a7..112cb53 100644 --- a/src/router/global.rs +++ b/src/router/global.rs @@ -10,8 +10,9 @@ use std::time::{SystemTime, UNIX_EPOCH}; pub const ASSET_VERSION: &str = "13177023d4b7ad41ff52af4cefba5c55"; pub const ASSET_HASH: &str = "9fbfeda43a5cbf744ef23c06c22170aa"; -pub const ASSET_VERSION_JP: &str = "4c921d2443335e574a82e04ec9ea243c"; -pub const ASSET_HASH_JP: &str = "67f8f261c16b3cca63e520a25aad6c1c"; +pub const ASSET_VERSION_JP: &str = "4c921d2443335e574a82e04ec9ea243c"; +pub const ASSET_HASH_ANDROID_JP: &str = "67f8f261c16b3cca63e520a25aad6c1c"; +pub const ASSET_HASH_IOS_JP: &str = "b8975be8300013a168d061d3fdcd4a16"; pub fn get_login(headers: &HeaderMap) -> String { let blank_header = HeaderValue::from_static(""); diff --git a/src/router/start.rs b/src/router/start.rs index 0c02de0..7c21c74 100644 --- a/src/router/start.rs +++ b/src/router/start.rs @@ -2,17 +2,27 @@ use json; use json::object; use crate::router::global; use crate::encryption; -use actix_web::{HttpResponse, HttpRequest}; +use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue}; use crate::router::userdata; -pub fn asset_hash(_req: HttpRequest, body: String) -> HttpResponse { +pub fn asset_hash(req: HttpRequest, body: String) -> HttpResponse { let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap(); if body["asset_version"].to_string() != global::ASSET_VERSION && body["asset_version"].to_string() != global::ASSET_VERSION_JP { println!("Warning! Asset version is not what was expected. (Did the app update?)"); } + + let blank_header = HeaderValue::from_static(""); + let key = req.headers().get("aoharu-platform").unwrap_or(&blank_header).to_str().unwrap_or(""); + let android = !key.to_lowercase().contains("iphone"); + let hash = if body["asset_version"].to_string() == global::ASSET_VERSION_JP { - global::ASSET_HASH_JP + if android { + global::ASSET_HASH_ANDROID_JP + } else { + global::ASSET_HASH_IOS_JP + } } else { + //todo - ios global::ASSET_HASH }; @@ -37,8 +47,16 @@ pub fn start(req: HttpRequest, body: String) -> HttpResponse { user["user"]["last_login_time"] = global::timestamp().into(); user["stamina"]["last_updated_time"] = global::timestamp().into(); + let blank_header = HeaderValue::from_static(""); + let key = req.headers().get("aoharu-platform").unwrap_or(&blank_header).to_str().unwrap_or(""); + let android = !key.to_lowercase().contains("iphone"); + let hash = if body["asset_version"].to_string() == global::ASSET_VERSION_JP { - global::ASSET_HASH_JP + if android { + global::ASSET_HASH_ANDROID_JP + } else { + global::ASSET_HASH_IOS_JP + } } else { global::ASSET_HASH };