gameconfig parsing correctly

This commit is contained in:
641i130 2023-11-05 10:49:14 -06:00
parent 99eb044062
commit 3f4b281841
2 changed files with 14 additions and 7 deletions

View File

@ -60,6 +60,7 @@ async fn basicinfo() -> HttpResponse {
#[get("/alive/{id}/Alive.txt")] #[get("/alive/{id}/Alive.txt")]
async fn alive(id: web::Path<String>, req: actix_web::HttpRequest) -> HttpResponse { async fn alive(id: web::Path<String>, req: actix_web::HttpRequest) -> HttpResponse {
println!("{}",format!("[+] Game started!").green());
resp!("") resp!("")
} }
@ -85,7 +86,7 @@ async fn shop() -> HttpResponse {
#[post("/service/respone/respone.php")] #[post("/service/respone/respone.php")]
async fn respone() -> HttpResponse { async fn respone() -> HttpResponse {
println!("[+] Machine started nesys service!"); println!("{}",format!("[+] Nesys service started!").green());
resp!("1") resp!("1")
} }
@ -124,6 +125,7 @@ pub struct Certify {
#[get("/server/certify.php")] #[get("/server/certify.php")]
async fn certify() -> HttpResponse { async fn certify() -> HttpResponse {
println!("{}",format!("[+] Certificates validated!").green());
//async fn certify(data: web::Query<Certify>, req: HttpRequest) -> HttpResponse { //async fn certify(data: web::Query<Certify>, req: HttpRequest) -> HttpResponse {
/* /*
dbg!(&data); dbg!(&data);

View File

@ -37,18 +37,24 @@ struct Terminal {
terminal_attrib: i32, terminal_attrib: i32,
terminal_id: String, 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")] #[post("/game")]
pub async fn game_stuff(body: web::Bytes, req: actix_web::HttpRequest) -> HttpResponse { 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! // 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!("{}",format!("Ciphertext:").black().on_red());
println!("{}", &ct.red()); println!("{}", &ct.red());
println!("{}",format!("Plaintext:").black().on_green()); println!("{}",format!("Plaintext:").black().on_green());
let pt = aes_dec(&body); 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()); println!("{}", &cleaned.green());
// Given the plaintext of the request body // Given the plaintext of the request body
// Attempt to deserialize the JSON into your custom struct // Attempt to deserialize the JSON into your custom struct
match serde_json::from_str::<GameData>(&cleaned) { match serde_json::from_str::<GameData>(&cleaned) {
@ -65,5 +71,4 @@ pub async fn game_stuff(body: web::Bytes, req: actix_web::HttpRequest) -> HttpRe
return resp!(""); return resp!("");
} }
} }
// } }
https://github.com/BocuD/LLServer/blob/2ab726cc298c613b5fa3d046ed95267c04486fd1/LLServer/Controllers/Game/GameController.cs