Moved around

This commit is contained in:
641i130 2023-11-04 18:11:43 -05:00
parent 11d09e9368
commit 9d794f1b96
3 changed files with 77 additions and 47 deletions

View File

@ -29,6 +29,7 @@ use futures_util::future::FutureExt;
// Modules
mod routes;
use crate::routes::game_routes::game_stuff;
use crate::routes::card_routes::cardn;
// AES
mod cry;
use crate::cry::aes::{aes_en, aes_dec};
@ -74,6 +75,16 @@ async fn incomALL() -> HttpResponse {
resp!("1+1")
}
#[post("/service/incom/incom.php")]
async fn incom() -> HttpResponse {
resp!("1+1")
}
#[post("/service/incom/shop.php")]
async fn shop() -> HttpResponse {
resp!("1+1")
}
#[post("/service/respone/respone.php")]
async fn respone() -> HttpResponse {
resp!("1")
@ -103,53 +114,6 @@ async fn game_info() -> HttpResponse {
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
}
// Card Command Codes
#[derive(Debug, Deserialize)]
pub enum CardCmd {
READ = 256,
REGISTER = 512,
REISSUE = 1536,
}
impl CardCmd {
fn from_u16(cmd_str: u16) -> Option<Self> {
match cmd_str {
256 => Some(CardCmd::READ),
512 => Some(CardCmd::REGISTER),
1536 => Some(CardCmd::REISSUE),
_ => None, // Handle unknown values
}
}
}
#[derive(Debug, Deserialize)]
pub struct CardVals {
cmd_str: u16, // Commands for card functions
card_no: u64, // Example: 7020392002385103
}
#[post("/service/card/cardn.cgi")]
async fn cardn(web::Form(form): web::Form<CardVals>) -> HttpResponse {
dbg!(&form);
match CardCmd::from_u16(form.cmd_str) {
Some(CardCmd::READ) => {
println!("READ");
resp!(format!("1\n1,1\n{}",form.card_no))
},
Some(CardCmd::REISSUE) => {
println!("REISSUE");
resp!("27")
},
Some(CardCmd::REGISTER) => {
println!("REGISTER");
// Add user into database later
resp!(format!("1\n1,1\n{}",form.card_no))
},
_ => HttpResponse::NotFound().into()
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Certify {
pub gid: u32,
@ -220,6 +184,8 @@ async fn main() -> std::io::Result<()> {
.service(alive)
.service(alive_i)
.service(incomALL)
.service(incom)
.service(shop)
.service(respone)
.service(fire_alert)
.service(cursel)

View File

@ -1,3 +1,4 @@
pub mod game_routes;
pub mod nesys_routes;
pub mod card_routes;

63
src/routes/card_routes.rs Normal file
View File

@ -0,0 +1,63 @@
use colored::Colorize;
use actix_web::{web, HttpResponse, dev::Service, dev::ServiceRequest, dev::ServiceResponse, Error, Result, get, http::header::ContentType, post, App, HttpRequest, HttpServer};
// AES
use crate::cry::aes::{aes_en, aes_dec};
macro_rules! resp {
($str:expr) => {
//HttpResponse::Ok().append_header(ContentType(mime::TEXT_HTML)).body($str)
HttpResponse::Ok().append_header(ContentType::octet_stream()).body($str)
};
}
///////////////////////////////////////////////////////////////////////////////////////////
use serde::Deserialize;
// Card Command Codes
#[derive(Debug, Deserialize)]
pub enum CardCmd {
READ = 256,
REGISTER = 512,
REISSUE = 1536,
}
impl CardCmd {
fn from_u16(cmd_str: u16) -> Option<Self> {
match cmd_str {
256 => Some(CardCmd::READ),
512 => Some(CardCmd::REGISTER),
1536 => Some(CardCmd::REISSUE),
_ => None, // Handle unknown values
}
}
}
#[derive(Debug, Deserialize)]
pub struct CardVals {
cmd_str: u16, // Commands for card functions
card_no: u64, // Example: 7020392002385103
}
#[post("/service/card/cardn.cgi")]
async fn cardn(web::Form(form): web::Form<CardVals>) -> HttpResponse {
dbg!(&form);
match CardCmd::from_u16(form.cmd_str) {
Some(CardCmd::READ) => {
println!("READ");
resp!(format!("1\n1,1\n{}",form.card_no))
},
Some(CardCmd::REISSUE) => {
println!("REISSUE");
resp!("27")
},
Some(CardCmd::REGISTER) => {
println!("REGISTER");
// Add user into database later
resp!(format!("1\n1,1\n{}",form.card_no))
},
_ => HttpResponse::NotFound().into()
}
}