1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-23 07:37:46 +00:00

Make patch-dl URL configurable

This commit is contained in:
Joshua Goins 2025-03-23 07:35:11 -04:00
parent b3f5500d2f
commit 65500d15ad
3 changed files with 17 additions and 8 deletions

View file

@ -18,7 +18,7 @@ async fn root() -> Html<String> {
let environment = setup_default_environment(); let environment = setup_default_environment();
let template = environment.get_template("admin.html").unwrap(); let template = environment.get_template("admin.html").unwrap();
Html(template.render(context! { worlds_open => config.frontier.worlds_open, login_open => config.frontier.login_open, boot_patch_location => config.boot_patches_location }).unwrap()) Html(template.render(context! { worlds_open => config.frontier.worlds_open, login_open => config.frontier.login_open, boot_patch_location => config.patch.patches_location }).unwrap())
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -47,7 +47,7 @@ async fn apply(Form(input): Form<Input>) -> Redirect {
} }
if let Some(boot_patch_location) = input.boot_patch_location { if let Some(boot_patch_location) = input.boot_patch_location {
config.boot_patches_location = boot_patch_location; config.patch.patches_location = boot_patch_location;
} }
serde_yaml_ng::to_writer(&std::fs::File::create("config.yaml").unwrap(), &config) serde_yaml_ng::to_writer(&std::fs::File::create("config.yaml").unwrap(), &config)

View file

@ -108,7 +108,7 @@ async fn verify_boot(
let actual_boot_version = boot_version.split("?time").collect::<Vec<&str>>()[0]; let actual_boot_version = boot_version.split("?time").collect::<Vec<&str>>()[0];
// check if we need any patching // check if we need any patching
let patches = list_patch_files(&config.boot_patches_location); let patches = list_patch_files(&config.patch.patches_location);
for patch in patches { for patch in patches {
let patch_str: &str = &patch; let patch_str: &str = &patch;
if actual_boot_version.partial_cmp(patch_str).unwrap() == Ordering::Less { if actual_boot_version.partial_cmp(patch_str).unwrap() == Ordering::Less {
@ -119,7 +119,7 @@ async fn verify_boot(
patch_length: todo!(), patch_length: todo!(),
content_location: todo!(), content_location: todo!(),
patches: vec![PatchEntry { patches: vec![PatchEntry {
url: format!("http://{}", patch).to_string(), url: format!("http://{}/{}", config.patch.patch_dl_url, patch).to_string(),
version: "2023.09.15.0000.0000".to_string(), version: "2023.09.15.0000.0000".to_string(),
hash_block_size: 50000000, hash_block_size: 50000000,
length: 1479062470, length: 1479062470,

View file

@ -118,6 +118,17 @@ impl LoginConfig {
pub struct PatchConfig { pub struct PatchConfig {
pub port: u16, pub port: u16,
pub listen_address: String, pub listen_address: String,
/// Publicly accessible URL to download patches from.
/// For example, "patch-dl.ffxiv.localhost". Patch files must be served so they're accessible as: "http://patch-dl.ffxiv.localhost/game/ex4/somepatchfilename.patch"
pub patch_dl_url: String,
/// Location of the patches directory on disk. Must be setup like so:
/// ```
/// <channel> (e.g. ffxivneo_release_game) /
/// game/
/// ex1/
/// ...
/// ```
pub patches_location: String,
} }
impl Default for PatchConfig { impl Default for PatchConfig {
@ -125,6 +136,8 @@ impl Default for PatchConfig {
Self { Self {
port: 6900, port: 6900,
listen_address: "127.0.0.1".to_string(), listen_address: "127.0.0.1".to_string(),
patch_dl_url: "patch-dl.ffxiv.localhost".to_string(),
patches_location: String::new(),
} }
} }
} }
@ -201,9 +214,6 @@ pub struct Config {
#[serde(default = "default_supported_platforms")] #[serde(default = "default_supported_platforms")]
pub supported_platforms: Vec<String>, pub supported_platforms: Vec<String>,
#[serde(default)]
pub boot_patches_location: String,
#[serde(default)] #[serde(default)]
pub game_location: String, pub game_location: String,
@ -232,7 +242,6 @@ pub struct Config {
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
Self { Self {
boot_patches_location: String::new(),
supported_platforms: default_supported_platforms(), supported_platforms: default_supported_platforms(),
game_location: String::new(), game_location: String::new(),
admin: AdminConfig::default(), admin: AdminConfig::default(),