1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-29 18:07:45 +00:00
kawari/src/bin/kawari-patch.rs

49 lines
1.5 KiB
Rust
Raw Normal View History

2023-10-06 17:46:58 -04:00
use std::net::SocketAddr;
use axum::{Form, Json, Router, routing::get};
use axum::extract::Query;
use axum::response::Html;
use axum::routing::post;
use serde::{Deserialize, Serialize};
2024-05-11 13:41:00 -04:00
use kawari::config::{Config, get_config};
2023-10-06 17:46:58 -04:00
use axum::extract::Path;
use axum::response::IntoResponse;
2024-05-11 13:41:00 -04:00
use axum::http::{HeaderMap, StatusCode};
async fn verify_session(Path((platform, game_version, sid)): Path<(String, String, String)>) -> impl IntoResponse {
let config = get_config();
if !config.supports_platform(&platform) {
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
}
2023-10-06 17:46:58 -04:00
let mut headers = HeaderMap::new();
headers.insert("X-Patch-Unique-Id", sid.parse().unwrap());
2024-05-11 13:41:00 -04:00
(headers).into_response()
2023-10-06 17:46:58 -04:00
}
2024-05-11 13:41:00 -04:00
async fn verify_boot(Path((platform, boot_version)): Path<(String, String)>) -> impl IntoResponse {
let config = get_config();
if !config.supports_platform(&platform) {
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
}
2023-10-06 17:46:58 -04:00
2024-05-11 13:41:00 -04:00
let mut headers = HeaderMap::new();
(headers).into_response()
2023-10-06 17:46:58 -04:00
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let app = Router::new()
2024-05-11 13:41:00 -04:00
.route("/http/:platform/ffxivneo_release_game/:game_version/:sid", post(verify_session))
.route("/http/:platform/ffxivneo_release_boot/:boot_version", get(verify_boot));
2023-10-06 17:46:58 -04:00
let addr = SocketAddr::from(([127, 0, 0, 1], 6900));
tracing::info!("Patch server started on {}", addr);
2023-10-06 17:46:58 -04:00
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}