alive works

ssl no worky
This commit is contained in:
Galileo 2023-01-30 22:48:43 -06:00
parent e297e28630
commit aaf8e90b57
2 changed files with 16 additions and 13 deletions

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
actix-web = {version = "4.3.0", features = ["rustls"]} actix-web = {version = "4.3.0", features = ["rustls"]}
mime = "0.3.16"
rustls = "0.20.8" rustls = "0.20.8"
rustls-pemfile = "1.0.2" rustls-pemfile = "1.0.2"
serde = {version = "1.0.152", features = ["derive"]} serde = {version = "1.0.152", features = ["derive"]}

View File

@ -1,9 +1,9 @@
#![allow(unused_variables)] #![allow(unused_variables)]
use actix_web::{web, get, App, HttpServer, HttpResponse, HttpRequest}; #![allow(non_snake_case)]
use rustls::ServerConfig; #![allow(dead_code)]
use rustls::Certificate; use actix_web::{web, get, App, HttpServer, HttpResponse, HttpRequest, http::{header::{ContentType, HeaderValue}, StatusCode}};
use rustls_pemfile::pkcs8_private_keys; use rustls::{ServerConfig, Certificate};
use rustls_pemfile::certs; use rustls_pemfile::{pkcs8_private_keys, certs};
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use serde::Deserialize; use serde::Deserialize;
@ -33,7 +33,6 @@ struct Alive {
game_hash: String, game_hash: String,
} }
async fn certify(req: HttpRequest, info: web::Path<(String, String, String, String, String)>) -> HttpResponse { async fn certify(req: HttpRequest, info: web::Path<(String, String, String, String, String)>) -> HttpResponse {
let id:u32 = req.match_info().query("user_id").parse().unwrap(); let id:u32 = req.match_info().query("user_id").parse().unwrap();
let (gid, mac, r, md, cn) = info.into_inner(); // not used let (gid, mac, r, md, cn) = info.into_inner(); // not used
@ -42,20 +41,23 @@ async fn certify(req: HttpRequest, info: web::Path<(String, String, String, Stri
// Can use = or : (it will use both) // Can use = or : (it will use both)
// if error is in the body, it will break and return an error // if error is in the body, it will break and return an error
// Probably used for tracking / telemetry... we don't care about that right now lmao // Probably used for tracking / telemetry... we don't care about that right now lmao
let res = format!("host=\ncard_id=7020392000147361,relay_addr=localhost,relay_port=80\nno=1337\nname=123\npref=nesys\naddr=nesys@home\nx-next-time=15\nx-img=http://localhost/news.png\nx-ranking=http://localhost/ranking.php\nticket=123456") let res = format!("host=\ncard_id=7020392000147361,relay_addr=localhost,relay_port=80\nno=1337\nname=123\npref=nesys\naddr=nesys@home\nx-next-time=15\nx-img=http://localhost/news.png\nx-ranking=http://localhost/ranking.php\nticket=123456");
;
HttpResponse::Ok().body(res) HttpResponse::Ok().body(res)
} }
#[get("/alive/{id}/alive.txt")] #[get("/alive/{id}/Alive.txt")]
async fn alive(info: web::Path<(String,)>, query: web::Query<Alive>) -> String { async fn alive(info: web::Path<(String,)>, _query: web::Query<Alive>) -> HttpResponse {
dbg!(&query);
//let (mac, ip, errcnt, errcode, errstr, access, speed, total_down, game_down, process_num, OS_Phys, OS_Virtual, AP_Phys, AP_Virtual, SV_Phys, SV_Virtual, free_space, uptime, ver, libver, game_hash) = query.into_inner(); //let (mac, ip, errcnt, errcode, errstr, access, speed, total_down, game_down, process_num, OS_Phys, OS_Virtual, AP_Phys, AP_Virtual, SV_Phys, SV_Virtual, free_space, uptime, ver, libver, game_hash) = query.into_inner();
println!("ALIVE REQUEST"); println!("ALIVE REQUEST");
/*
if info.0 == "303801" { if info.0 == "303801" {
return "1".to_string() return "".to_string()
} }
"0".to_string() "".to_string()*/
HttpResponse::Ok()
.append_header(ContentType(mime::TEXT_PLAIN))
.append_header(("Connection", "keep-alive"))
.finish()
} }
async fn fire_alert(info: web::Query<(u32, String, u32, u32)>) -> HttpResponse { async fn fire_alert(info: web::Query<(u32, String, u32, u32)>) -> HttpResponse {