diff --git a/wavebreaker_client/Cargo.toml b/wavebreaker_client/Cargo.toml index 8e3b0a9..ea5d8dc 100644 --- a/wavebreaker_client/Cargo.toml +++ b/wavebreaker_client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wavebreaker_client" -version = "3.3.0" +version = "3.4.0" edition = "2021" [lib] @@ -24,20 +24,20 @@ features = [ [dependencies] anyhow = "1.*" -serde = { version = "1.0.196", features = ["derive"] } +serde = { version = "1.0.*", features = ["derive"] } tracing = "0.*" tracing-appender = "0.*" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } figment = { version = "0.*", features = ["toml", "env"] } crochet = "0.2.3" -lofty = "0.19.0" +lofty = "0.20.0" url_encoded_data = "0.6.1" bass-sys = "2.3.0" rfd = "0.14.1" octocrab = "0.38.0" -semver = "1.0.22" -tokio = { version = "1.37.0", features = ["full"] } -open = "5.1.2" +semver = "1.0.23" +tokio = { version = "1.38.0", features = ["full"] } +open = "5.1.*" [build-dependencies] bindgen = "0.69.4" diff --git a/wavebreaker_client/src/config.rs b/wavebreaker_client/src/config.rs index 99f1d9b..62c4450 100644 --- a/wavebreaker_client/src/config.rs +++ b/wavebreaker_client/src/config.rs @@ -11,6 +11,7 @@ pub struct Config { pub struct Main { pub auto_update: bool, pub server: String, + pub base_path: Option, pub force_insecure: bool, } diff --git a/wavebreaker_client/src/hooking.rs b/wavebreaker_client/src/hooking.rs index 1f693d4..8c8c39e 100644 --- a/wavebreaker_client/src/hooking.rs +++ b/wavebreaker_client/src/hooking.rs @@ -276,9 +276,9 @@ unsafe fn connect_hook( #[crochet::hook(compile_check, "Wininet.dll", "HttpOpenRequestA")] unsafe fn openrequest_hook( - hconnect: c_int, + hconnect: *const c_void, verb: PCSTR, - object_name: PCSTR, + mut object_name: PCSTR, version: PCSTR, referrer: PCSTR, accept_types: *const PCSTR, @@ -292,7 +292,28 @@ unsafe fn openrequest_hook( flags ); + let path = &object_name.to_string().unwrap(); + let config = CONFIG.get().unwrap(); + if let Some(new_base_path) = &config.main.base_path { + if path.ends_with(".php") || path.ends_with(".cgr") { + debug!("Route seems to be for game server. base_path is set, rewriting path"); + + let mut new_base_path = new_base_path.to_owned(); + // If the path doesn't start with a slash, add one + // If the path ends with a slash, remove it + if !new_base_path.starts_with('/') { + new_base_path.insert(0, '/'); + } + if new_base_path.ends_with('/') { + new_base_path.pop(); + } + new_base_path.push_str(path); + let new_base_path = malloc_c_string(&new_base_path); + object_name = PCSTR(new_base_path.cast()); + } + } + if config.main.force_insecure { flags &= !INTERNET_FLAG_SECURE; } else {