salvo is working
This commit is contained in:
+14
-7
@@ -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))]
|
||||
|
||||
Reference in New Issue
Block a user