From 134e42e69f826c8fde7baabb2e8ec20d95003f1c Mon Sep 17 00:00:00 2001 From: Sam Sartor Date: Sat, 25 Oct 2025 20:14:26 -0600 Subject: [PATCH] simplify proxy and update readme --- README.md | 28 ++++++++++------------------ config.toml.example | 1 + docker/proxy-config.toml | 3 --- proxy/src/main.rs | 39 ++------------------------------------- 4 files changed, 13 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 31edf24..e36b8c4 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,19 @@ 1. `cargo install dioxus-cli --version 0.6.3` 2. `dx run -p mumble-web2-gui --platform desktop --release` -## Running Web + +## Running Web (development) + +1. `cargo install dioxus-cli --version 0.6.3` +3. `dx serve -p mumble-web2-gui --platform web` +2. `cd docker && docker compose up` +4. connect to `https://localhost:64444` +5. fill in the proxy url as `https://127.0.0.1:4433/proxy` (this should autofill) + +## Running Web (with `proxy` only) 1. `cargo install dioxus-cli --version 0.6.3` 2. `dx build -p mumble-web2-gui --platform web --release` 3. `cp config.toml.example config.toml` 4. `cargo run -p mumble-web2-proxy` in the background 5. connect to `localhost:8080` - -## Running Web (with `dx serve`) - -1. `cargo install dioxus-cli --version 0.6.3` -2. `cp config.toml.example config.toml` -3. `cargo run -p mumble-web2-proxy` in the background -4. `cargo install cargo install wtransport --example gencert` -5. `export 'MUMBLE_WEB2_GUI_CONFIG={"cert_hash": , "proxy_url": "https://localhost:4433"}'` -6. `dx serve -p mumble-web2-gui --platform web` -7. connect to `localhost:8080` - -## Running the dev stack with a docker based proxy - -1. cd docker && sudo docker compose up -d -2. MUMBLE_WEB2_GUI_CONFIG_URL="" dx serve -p mumble-web2-gui --platform web -3. connect to -4. fill in the proxy url as (this should autofill but is currently broken) diff --git a/config.toml.example b/config.toml.example index 7f1df48..11eca30 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,6 +1,7 @@ https_listen_address = "127.0.0.1:4433" http_listen_address = "127.0.0.1:8080" mumble_server_url = "[SERVER_URL_HERE]" +gui_path = "target/dx/mumble-web2-gui/release/web/public" [gui] force_proxy = true diff --git a/docker/proxy-config.toml b/docker/proxy-config.toml index 3528a3e..64c7137 100644 --- a/docker/proxy-config.toml +++ b/docker/proxy-config.toml @@ -1,8 +1,5 @@ https_listen_address = "127.0.0.1:4433" http_listen_address = "127.0.0.1:4400" -#cert_path = "./cert.pem" -#key_path = "./key.pem" -#mumble_server_url = "voip.ohea.xyz:64738" mumble_server_url = "127.0.0.1:64738" [gui] diff --git a/proxy/src/main.rs b/proxy/src/main.rs index ba92ab1..96efcf0 100644 --- a/proxy/src/main.rs +++ b/proxy/src/main.rs @@ -1,8 +1,6 @@ use color_eyre::eyre::{anyhow, bail, Context, Result}; -use color_eyre::owo_colors::OwoColorize; use mumble_web2_common::GuiConfig; use once_cell::sync::OnceCell; -use rcgen::date_time_ymd; use salvo::conn::rustls::{Keycert, RustlsConfig}; use salvo::cors::{AllowOrigin, Cors}; use salvo::logging::Logger; @@ -47,40 +45,6 @@ struct Config { static CONFIG: OnceCell = OnceCell::new(); -#[handler] -#[instrument] -async fn serve_gui_index_html(req: &Request, res: &mut Response) { - let config = CONFIG.get().unwrap(); - - let path = match &config.gui_path { - Some(p) => p.join("index.html"), - None => { - res.status_code(StatusCode::NOT_FOUND); - return; - } - }; - - // Load the HTML file - let html = match fs::read_to_string(&path).await { - Ok(content) => content, - Err(err) => { - error!("could not load {}: {:?}", path.display(), err); - res.status_code(StatusCode::INTERNAL_SERVER_ERROR); - return; - } - }; - - // Insert the script tag with configuration - let modified_html = html.replace( - "", - &format!( - "\n", - serde_json::to_string(&config.gui).unwrap(), - ), - ); - res.render(Text::Html(modified_html)); -} - fn init_config() -> Result<()> { let mut config: Config = toml::from_str( &std::fs::read_to_string("./config.toml") @@ -160,11 +124,12 @@ async fn main() -> Result<()> { // Server routing let mut router = Router::new() - .get(serve_gui_index_html) .push(Router::with_path("/proxy").goal(connect_proxy)) .push(Router::with_path("/config").get(config_craft.get_config())) .hoop(Logger::new()); if let Some(gui_path) = config.gui_path.clone() { + router = + router.push(Router::with_path("/").get(StaticFile::new(gui_path.join("index.html")))); router = router.push(Router::with_path("/<*+rest>").get(StaticDir::new(gui_path))); }