mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-20 22:57:45 +00:00
Check user-agent in Patch server
This commit is contained in:
parent
d92f0033a9
commit
b3f5500d2f
2 changed files with 30 additions and 8 deletions
|
@ -61,9 +61,23 @@ fn list_patch_files(dir_path: &str) -> Vec<String> {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if it's a valid patch client connecting
|
||||||
|
fn check_valid_patch_client(headers: &HeaderMap) -> bool {
|
||||||
|
let Some(user_agent) = headers.get("User-Agent") else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
user_agent == "FFXIV PATCH CLIENT"
|
||||||
|
}
|
||||||
|
|
||||||
async fn verify_session(
|
async fn verify_session(
|
||||||
Path((platform, _, sid)): Path<(String, String, String)>,
|
headers: HeaderMap,
|
||||||
|
Path((platform, channel, game_version, sid)): Path<(String, String, String, String)>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
|
if !check_valid_patch_client(&headers) {
|
||||||
|
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||||
|
}
|
||||||
|
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
if !config.supports_platform(&platform) {
|
if !config.supports_platform(&platform) {
|
||||||
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||||
|
@ -75,8 +89,15 @@ async fn verify_session(
|
||||||
(headers).into_response()
|
(headers).into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify_boot(Path((platform, boot_version)): Path<(String, String)>) -> impl IntoResponse {
|
async fn verify_boot(
|
||||||
tracing::info!("Verifying boot components...");
|
headers: HeaderMap,
|
||||||
|
Path((platform, channel, boot_version)): Path<(String, String, String)>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
if !check_valid_patch_client(&headers) {
|
||||||
|
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
tracing::info!("Verifying boot components for {platform} {channel} {boot_version}...");
|
||||||
|
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
if !config.supports_platform(&platform) {
|
if !config.supports_platform(&platform) {
|
||||||
|
@ -123,13 +144,13 @@ async fn main() {
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route(
|
.route(
|
||||||
"/http/{platform}/ffxivneo_release_game/{game_version}/{sid}",
|
"/http/{platform}/{channel}/{game_version}/{sid}",
|
||||||
post(verify_session),
|
post(verify_session),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/http/{platform}/ffxivneo_release_boot/{*boot_version}",
|
"/http/{platform}/{channel}/{boot_version}",
|
||||||
get(verify_boot),
|
get(verify_boot),
|
||||||
); // NOTE: for future programmers, this is a wildcard because axum hates the /version/?time=blah format.
|
);
|
||||||
|
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||||
use kawari::common::timestamp_secs;
|
use kawari::common::timestamp_secs;
|
||||||
use kawari::common::{determine_initial_starting_zone, get_citystate, get_world_name, Position};
|
use kawari::common::{Position, determine_initial_starting_zone, get_citystate, get_world_name};
|
||||||
use kawari::config::get_config;
|
use kawari::config::get_config;
|
||||||
use kawari::lobby::CharaMake;
|
use kawari::lobby::CharaMake;
|
||||||
use kawari::oodle::OodleNetwork;
|
use kawari::oodle::OodleNetwork;
|
||||||
|
@ -17,7 +17,8 @@ use kawari::world::ipc::{
|
||||||
use kawari::world::{
|
use kawari::world::{
|
||||||
ChatHandler, Zone, ZoneConnection,
|
ChatHandler, Zone, ZoneConnection,
|
||||||
ipc::{
|
ipc::{
|
||||||
ActorControlCategory, ActorControlSelf, PlayerEntry, PlayerSetup, PlayerSpawn, PlayerStats, SocialList,
|
ActorControlCategory, ActorControlSelf, PlayerEntry, PlayerSetup, PlayerSpawn, PlayerStats,
|
||||||
|
SocialList,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use kawari::world::{PlayerData, WorldDatabase};
|
use kawari::world::{PlayerData, WorldDatabase};
|
||||||
|
|
Loading…
Add table
Reference in a new issue