Skip to content

Commit 1ba4e43

Browse files
add base path redirect, bump version and update deps
1 parent 06f3933 commit 1ba4e43

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

wavebreaker_client/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wavebreaker_client"
3-
version = "3.3.0"
3+
version = "3.4.0"
44
edition = "2021"
55

66
[lib]
@@ -24,20 +24,20 @@ features = [
2424

2525
[dependencies]
2626
anyhow = "1.*"
27-
serde = { version = "1.0.196", features = ["derive"] }
27+
serde = { version = "1.0.*", features = ["derive"] }
2828
tracing = "0.*"
2929
tracing-appender = "0.*"
3030
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
3131
figment = { version = "0.*", features = ["toml", "env"] }
3232
crochet = "0.2.3"
33-
lofty = "0.19.0"
33+
lofty = "0.20.0"
3434
url_encoded_data = "0.6.1"
3535
bass-sys = "2.3.0"
3636
rfd = "0.14.1"
3737
octocrab = "0.38.0"
38-
semver = "1.0.22"
39-
tokio = { version = "1.37.0", features = ["full"] }
40-
open = "5.1.2"
38+
semver = "1.0.23"
39+
tokio = { version = "1.38.0", features = ["full"] }
40+
open = "5.1.*"
4141

4242
[build-dependencies]
4343
bindgen = "0.69.4"

wavebreaker_client/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct Config {
1111
pub struct Main {
1212
pub auto_update: bool,
1313
pub server: String,
14+
pub base_path: Option<String>,
1415
pub force_insecure: bool,
1516
}
1617

wavebreaker_client/src/hooking.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ unsafe fn connect_hook(
276276

277277
#[crochet::hook(compile_check, "Wininet.dll", "HttpOpenRequestA")]
278278
unsafe fn openrequest_hook(
279-
hconnect: c_int,
279+
hconnect: *const c_void,
280280
verb: PCSTR,
281-
object_name: PCSTR,
281+
mut object_name: PCSTR,
282282
version: PCSTR,
283283
referrer: PCSTR,
284284
accept_types: *const PCSTR,
@@ -292,7 +292,28 @@ unsafe fn openrequest_hook(
292292
flags
293293
);
294294

295+
let path = &object_name.to_string().unwrap();
296+
295297
let config = CONFIG.get().unwrap();
298+
if let Some(new_base_path) = &config.main.base_path {
299+
if path.ends_with(".php") || path.ends_with(".cgr") {
300+
debug!("Route seems to be for game server. base_path is set, rewriting path");
301+
302+
let mut new_base_path = new_base_path.to_owned();
303+
// If the path doesn't start with a slash, add one
304+
// If the path ends with a slash, remove it
305+
if !new_base_path.starts_with('/') {
306+
new_base_path.insert(0, '/');
307+
}
308+
if new_base_path.ends_with('/') {
309+
new_base_path.pop();
310+
}
311+
new_base_path.push_str(path);
312+
let new_base_path = malloc_c_string(&new_base_path);
313+
object_name = PCSTR(new_base_path.cast());
314+
}
315+
}
316+
296317
if config.main.force_insecure {
297318
flags &= !INTERNET_FLAG_SECURE;
298319
} else {

0 commit comments

Comments
 (0)