1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-24 08:07:45 +00:00

Add basic patch server implementation

This commit is contained in:
Joshua Goins 2023-10-06 17:46:58 -04:00
parent e3ac03ffc4
commit 1178ecdd61
4 changed files with 149 additions and 2 deletions

View file

@ -14,4 +14,5 @@ tasks:
echo "StrictHostKeyChecking=no" >> ~/.ssh/config
rsync -e 'ssh -p 38901' -Wvr kawari/target/release/kawari-frontier deploy@ryne.moe:/opt/kawari/
rsync -e 'ssh -p 38901' -Wvr kawari/target/release/kawari-admin deploy@ryne.moe:/opt/kawari/
rsync -e 'ssh -p 38901' -Wvr kawari/target/release/kawari-login deploy@ryne.moe:/opt/kawari/
rsync -e 'ssh -p 38901' -Wvr kawari/target/release/kawari-login deploy@ryne.moe:/opt/kawari/
rsync -e 'ssh -p 38901' -Wvr kawari/target/release/kawari-patch deploy@ryne.moe:/opt/kawari/

102
Cargo.lock generated
View file

@ -39,6 +39,7 @@ dependencies = [
"bitflags",
"bytes",
"futures-util",
"headers",
"http",
"http-body",
"hyper",
@ -92,12 +93,27 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "bytes"
version = "1.5.0"
@ -119,6 +135,35 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cpufeatures"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -167,12 +212,46 @@ dependencies = [
"pin-utils",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "gimli"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "headers"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
dependencies = [
"base64",
"bytes",
"headers-core",
"http",
"httpdate",
"mime",
"sha1",
]
[[package]]
name = "headers-core"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
dependencies = [
"http",
]
[[package]]
name = "hermit-abi"
version = "0.3.3"
@ -456,6 +535,17 @@ dependencies = [
"serde",
]
[[package]]
name = "sha1"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
@ -603,12 +693,24 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "want"
version = "0.3.1"

View file

@ -12,6 +12,9 @@ name = "kawari-admin"
[[bin]]
name = "kawari-login"
[[bin]]
name = "kawari-patch"
[profile.release]
lto = true
strip = true
@ -20,7 +23,7 @@ codegen-units = 1
panic = "abort"
[dependencies]
axum = { version = "0.6.20", features = ["json", "tokio", "http1", "form", "query"], default-features = false }
axum = { version = "0.6.20", features = ["json", "tokio", "http1", "form", "query", "headers"], default-features = false }
serde_json = { version = "1.0.91", default-features = false }
tokio = { version = "1.32.0", features = ["macros", "rt", "rt-multi-thread"], default-features = false }
tracing = { version = "0.1.37", default-features = false }

41
src/bin/kawari-patch.rs Normal file
View file

@ -0,0 +1,41 @@
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};
use kawari::config::Config;
use axum::extract::Path;
use axum::response::IntoResponse;
use axum::http::HeaderMap;
async fn verify_session(Path(game_version): Path<String>, Path(sid): Path<String>) -> impl IntoResponse {
let mut headers = HeaderMap::new();
headers.insert("X-Patch-Unique-Id", sid.parse().unwrap());
(headers)
}
async fn verify_boot(Path(boot_version): Path<String>) -> impl IntoResponse {
let mut headers = HeaderMap::new();
headers.insert("X-Patch-Unique-Id", sid.parse().unwrap());
(headers)
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let app = Router::new()
.route("/http/win32/ffxivneo_release_game/:game_version/:sid", post(verify_session))
.route("/http/win32/ffxivneo_release_boot/:boot_version", post(verify_boot));
let addr = SocketAddr::from(([127, 0, 0, 1], 6900));
tracing::info!("Frontier server started on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}