salvo is working

This commit is contained in:
2024-11-12 15:42:01 -07:00
parent 3c6a436690
commit a25cf64681
3 changed files with 19 additions and 10 deletions
+2 -2
View File
@@ -3,9 +3,9 @@ http_listen_address = "127.0.0.1:8080"
cert_path = "./cert.pem"
key_path = "./key.pem"
mumble_server_url = "voip.ohea.xyz:64738"
gui_path = "../target/dx/mumble-web2-gui/debug/web/public"
gui_path = "../target/dx/mumble-web2-gui/release/web/public"
[gui]
force_proxy = true
proxy_url = "https://localhost:4433/proxy"
proxy_url = "https://127.0.0.1:4433/proxy"
# cert_hash = [...]
+14 -7
View File
@@ -8,7 +8,7 @@ use salvo::proto::quic::BidiStream;
use serde::Deserialize;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use tokio::fs;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::TcpStream;
@@ -24,7 +24,7 @@ use tracing::{error, instrument};
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::EnvFilter;
#[derive(Clone, Deserialize)]
#[derive(Deserialize)]
struct Config {
https_listen_address: SocketAddr,
http_listen_address: Option<SocketAddr>,
@@ -33,7 +33,7 @@ struct Config {
mumble_server_url: String,
mumble_server_address: Option<SocketAddr>,
gui_path: PathBuf,
gui: GuiConfig,
gui: Mutex<GuiConfig>,
}
static CONFIG: OnceCell<Config> = OnceCell::new();
@@ -107,6 +107,11 @@ async fn main() -> Result<()> {
.push(Router::with_path("/proxy").goal(connect_proxy))
.push(Router::with_path("/gui").get(serve_gui_index_html))
.push(Router::with_path("/gui/<*+rest>").get(StaticDir::new(config.gui_path.clone())))
// right now dioxus assets don't properly handle base_url, so we are stuck with this
.push(
Router::with_path("/assets/<*+rest>")
.get(StaticDir::new(config.gui_path.join("assets"))),
)
.hoop(Logger::new());
// Read server certs
@@ -193,13 +198,15 @@ async fn connect_proxy(req: &mut Request, res: &mut Response) {
*/
let (outgoing, incoming) = bi.split();
tokio::spawn(async move {
let res = tokio::spawn(async move {
if let Err(error) = connect_proxy_impl(mumble_server_address, incoming, outgoing).await {
error!("error connecting proxy {error:?}")
}
});
res.render("connected");
})
.await;
if let Err(err) = res {
error!("crash in connected proxy {err:?}");
}
}
#[instrument(skip(incoming, outgoing))]