simplify proxy and update readme

This commit is contained in:
2025-10-25 20:14:26 -06:00
parent 55a91b1459
commit 134e42e69f
4 changed files with 13 additions and 58 deletions
+10 -18
View File
@@ -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": <CERTIFICATE HASH HERE>, "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="<https://localhost:64444/config>" dx serve -p mumble-web2-gui --platform web
3. connect to <https://localhost:64444>
4. fill in the proxy url as <https://127.0.0.1:4433/proxy> (this should autofill but is currently broken)
+1
View File
@@ -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
-3
View File
@@ -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]
+2 -37
View File
@@ -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<Config> = 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(
"</head>",
&format!(
"<script>window.config = {}</script>\n</head>",
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)));
}