Skip to content

Commit

Permalink
add base path redirect, bump version and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
RubberDuckShobe committed Jun 17, 2024
1 parent 06f3933 commit 1ba4e43
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
12 changes: 6 additions & 6 deletions wavebreaker_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wavebreaker_client"
version = "3.3.0"
version = "3.4.0"
edition = "2021"

[lib]
Expand All @@ -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"
1 change: 1 addition & 0 deletions wavebreaker_client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct Config {
pub struct Main {
pub auto_update: bool,
pub server: String,
pub base_path: Option<String>,
pub force_insecure: bool,
}

Expand Down
25 changes: 23 additions & 2 deletions wavebreaker_client/src/hooking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 1ba4e43

Please sign in to comment.