From 3f4b281841d3bcd7bfad6bf1ae2400591536bf54 Mon Sep 17 00:00:00 2001 From: 641i130 <46945263+641i130@users.noreply.github.com> Date: Sun, 5 Nov 2023 10:49:14 -0600 Subject: [PATCH] gameconfig parsing correctly --- src/main.rs | 4 +++- src/routes/game_routes.rs | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 65ede1d..20b7eba 100755 --- a/src/main.rs +++ b/src/main.rs @@ -60,6 +60,7 @@ async fn basicinfo() -> HttpResponse { #[get("/alive/{id}/Alive.txt")] async fn alive(id: web::Path, req: actix_web::HttpRequest) -> HttpResponse { + println!("{}",format!("[+] Game started!").green()); resp!("") } @@ -85,7 +86,7 @@ async fn shop() -> HttpResponse { #[post("/service/respone/respone.php")] async fn respone() -> HttpResponse { - println!("[+] Machine started nesys service!"); + println!("{}",format!("[+] Nesys service started!").green()); resp!("1") } @@ -124,6 +125,7 @@ pub struct Certify { #[get("/server/certify.php")] async fn certify() -> HttpResponse { + println!("{}",format!("[+] Certificates validated!").green()); //async fn certify(data: web::Query, req: HttpRequest) -> HttpResponse { /* dbg!(&data); diff --git a/src/routes/game_routes.rs b/src/routes/game_routes.rs index 7c337c6..d301df2 100644 --- a/src/routes/game_routes.rs +++ b/src/routes/game_routes.rs @@ -37,18 +37,24 @@ struct Terminal { terminal_attrib: i32, terminal_id: String, } - +fn clean_json_string(input: &str) -> String { + // Remove whitespace characters, including line breaks and extra spaces + let cleaned_str = input + .chars() + .filter(|c| !c.is_control() || c == &'\n' || c == &'\r') + .collect(); + cleaned_str +} #[post("/game")] pub async fn game_stuff(body: web::Bytes, req: actix_web::HttpRequest) -> HttpResponse { // For getting the game online, we need to give it a json type encrypted! - let ct = String::from_utf8_lossy(&body).trim().replace("\n", "").replace("\0", ""); + let ct = String::from_utf8_lossy(&body).trim().replace("\n", "").replace("\0", "").replace("\r","").replace("\t",""); println!("{}",format!("Ciphertext:").black().on_red()); println!("{}", &ct.red()); println!("{}",format!("Plaintext:").black().on_green()); let pt = aes_dec(&body); - let cleaned = &pt.trim().replace("\n", "").replace("\0", "").replace("\r", ""); + let cleaned = clean_json_string(&pt).replace("\n",""); println!("{}", &cleaned.green()); - // Given the plaintext of the request body // Attempt to deserialize the JSON into your custom struct match serde_json::from_str::(&cleaned) { @@ -65,5 +71,4 @@ pub async fn game_stuff(body: web::Bytes, req: actix_web::HttpRequest) -> HttpRe return resp!(""); } } -// } -https://github.com/BocuD/LLServer/blob/2ab726cc298c613b5fa3d046ed95267c04486fd1/LLServer/Controllers/Game/GameController.cs +}