1 Commits

Author SHA1 Message Date
samuel127849 2bb6648654 Update logs and variable names
Build Mumble Web 2 / linux_build (push) Successful in 1m31s
Build Mumble Web 2 / windows_build (push) Successful in 2m26s
2026-01-10 17:36:34 -07:00
5 changed files with 40 additions and 41 deletions
+3 -2
View File
@@ -2,8 +2,9 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize, Default)] #[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct ProxyOverides { pub struct ProxyOverides {
pub proxy_url: String, pub proxy_url: Option<String>,
pub cert_hash: Vec<u8>, pub cert_hash: Option<Vec<u8>>,
pub any_server: bool,
} }
#[derive(Debug, Clone, Deserialize, Serialize, Default)] #[derive(Debug, Clone, Deserialize, Serialize, Default)]
+12 -18
View File
@@ -309,7 +309,7 @@ pub fn ChatView() -> Element {
} }
#[component] #[component]
pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element { pub fn ControlView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle(); let net: Coroutine<Command> = use_coroutine_handle();
let status = &STATE.status; let status = &STATE.status;
let server = STATE.server.read(); let server = STATE.server.read();
@@ -331,8 +331,7 @@ pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element {
let proxy_url = config let proxy_url = config
.read_unchecked() .read_unchecked()
.as_ref() .as_ref()
.and_then(|opt| opt.as_ref()) .and_then(|gui_config| gui_config.proxy_url.clone());
.map(|gui_config| gui_config.proxy_url.clone());
let connecting_color = "yellow"; let connecting_color = "yellow";
let connected_color = "oklch(0.55 0.1184 141.35)"; let connected_color = "oklch(0.55 0.1184 141.35)";
@@ -509,7 +508,7 @@ pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element {
} }
#[component] #[component]
pub fn ServerView(config: Resource<Option<ProxyOverides>>) -> Element { pub fn ServerView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle(); let net: Coroutine<Command> = use_coroutine_handle();
let server = STATE.server.read(); let server = STATE.server.read();
let Some(&UserState { let Some(&UserState {
@@ -547,7 +546,7 @@ pub fn ServerView(config: Resource<Option<ProxyOverides>>) -> Element {
} }
#[component] #[component]
pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element { pub fn LoginView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle(); let net: Coroutine<Command> = use_coroutine_handle();
let last_status = use_signal(|| None::<color_eyre::Result<ServerStatus>>); let last_status = use_signal(|| None::<color_eyre::Result<ServerStatus>>);
@@ -565,8 +564,7 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
addr.clone() addr.clone()
} else { } else {
config() config()
.flatten() .and_then(|c| c.proxy_url.clone())
.map(|c| c.proxy_url.clone())
.unwrap_or_default() .unwrap_or_default()
} }
}); });
@@ -577,13 +575,13 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
let do_connect = move |_| { let do_connect = move |_| {
//let _ = set_default_username(&username.read()); //let _ = set_default_username(&username.read());
let _ = imp::set_default_username(&username.read()); let _ = imp::set_default_username(&username.read());
if config.read().as_ref().is_some_and(|opt| opt.is_none()) { if config.read().as_ref().is_some_and(|cfg| cfg.any_server) {
imp::set_default_server(&address.read()); imp::set_default_server(&address.read());
} }
net.send(Connect { net.send(Connect {
address: address.read().clone(), address: address.read().clone(),
username: username.read().clone(), username: username.read().clone(),
config: config.read().clone().flatten().unwrap_or_default(), config: config.read().clone().unwrap_or_default(),
}) })
}; };
let status = &STATE.status; let status = &STATE.status;
@@ -628,7 +626,7 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
None => rsx!(), None => rsx!(),
} }
} }
if config.read().as_ref().is_some_and(|opt| opt.is_none()) { if config.read().as_ref().is_some_and(|cfg| cfg.any_server) {
div { div {
label { label {
for: "address-entry", for: "address-entry",
@@ -727,7 +725,7 @@ pub fn app() -> Element {
let config = use_resource(|| async move { let config = use_resource(|| async move {
match imp::load_proxy_overides().await { match imp::load_proxy_overides().await {
Ok(config) => config, Ok(config) => config,
Err(_) => None, Err(_) => ProxyOverides::default(),
} }
}); });
@@ -736,13 +734,9 @@ pub fn app() -> Element {
document::Link{ rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" } document::Link{ rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" }
document::Link{ rel: "stylesheet", href: STYLE } document::Link{ rel: "stylesheet", href: STYLE }
if config.read().is_none() { match *STATE.status.read() {
div { class: "loading", "Loading..." } Connected => rsx!(ServerView { config }),
} else { _ => rsx!(LoginView { config }),
match *STATE.status.read() {
Connected => rsx!(ServerView { config }),
_ => rsx!(LoginView { config }),
}
} }
) )
} }
+7 -3
View File
@@ -284,7 +284,7 @@ pub async fn network_connect(
address: String, address: String,
username: String, username: String,
event_rx: &mut UnboundedReceiver<Command>, event_rx: &mut UnboundedReceiver<Command>,
gui_config: &ProxyOverides, proxy_overides: &ProxyOverides,
) -> Result<(), Error> { ) -> Result<(), Error> {
info!("connecting"); info!("connecting");
@@ -366,8 +366,12 @@ pub fn load_server_url() -> Option<String> {
config.get("server").cloned() config.get("server").cloned()
} }
pub async fn load_proxy_overides() -> color_eyre::Result<Option<ProxyOverides>> { pub async fn load_proxy_overides() -> color_eyre::Result<ProxyOverides> {
Ok(None) Ok(ProxyOverides {
proxy_url: None,
cert_hash: None,
any_server: true,
})
} }
pub async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> { pub async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
+5 -5
View File
@@ -329,7 +329,7 @@ pub async fn network_connect(
address: String, address: String,
username: String, username: String,
event_rx: &mut UnboundedReceiver<Command>, event_rx: &mut UnboundedReceiver<Command>,
gui_config: &ProxyOverides, proxy_overides: &ProxyOverides,
) -> Result<(), Error> { ) -> Result<(), Error> {
info!("connecting"); info!("connecting");
@@ -342,8 +342,8 @@ pub async fn network_connect(
) )
.ey()?; .ey()?;
if !gui_config.cert_hash.is_empty() { if let Some(server_hash) = &proxy_overides.cert_hash {
let hash = web_sys::js_sys::Uint8Array::from(gui_config.cert_hash.as_slice()); let hash = web_sys::js_sys::Uint8Array::from(server_hash.as_slice());
web_sys::js_sys::Reflect::set(&object, &"value".into(), &hash).ey()?; web_sys::js_sys::Reflect::set(&object, &"value".into(), &hash).ey()?;
} }
@@ -422,7 +422,7 @@ pub fn absolute_url(path: &str) -> Result<Url, Error> {
Ok(Url::parse(&location.href().ey()?)?.join(path)?) Ok(Url::parse(&location.href().ey()?)?.join(path)?)
} }
pub async fn load_proxy_overides() -> color_eyre::Result<Option<ProxyOverides>> { pub async fn load_proxy_overides() -> color_eyre::Result<ProxyOverides> {
let config_url = match option_env!("MUMBLE_WEB2_GUI_CONFIG_URL") { let config_url = match option_env!("MUMBLE_WEB2_GUI_CONFIG_URL") {
Some(url) => Url::parse(url)?, Some(url) => Url::parse(url)?,
None => absolute_url("config")?, None => absolute_url("config")?,
@@ -434,7 +434,7 @@ pub async fn load_proxy_overides() -> color_eyre::Result<Option<ProxyOverides>>
.json::<ProxyOverides>() .json::<ProxyOverides>()
.await?; .await?;
Ok(Some(config)) Ok(config)
} }
pub async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> { pub async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
+13 -13
View File
@@ -77,13 +77,13 @@ async fn main() -> Result<()> {
.install_default() .install_default()
.map_err(|e| anyhow!("could not install crypto provider {e:?}"))?; .map_err(|e| anyhow!("could not install crypto provider {e:?}"))?;
let mut client_config = ProxyOverides { let mut proxy_overides = ProxyOverides {
proxy_url: server_config proxy_url: match &server_config.proxy_url {
.proxy_url Some(url) => Some(url.to_string()),
.as_ref() None => None,
.map(|url| url.to_string()) },
.unwrap_or_default(), cert_hash: None,
cert_hash: Vec::new(), any_server: false,
}; };
let (cert, key) = match (&server_config.cert_path, &server_config.key_path) { let (cert, key) = match (&server_config.cert_path, &server_config.key_path) {
@@ -102,7 +102,7 @@ async fn main() -> Result<()> {
let cert = cert_params.self_signed(&key_pair)?; let cert = cert_params.self_signed(&key_pair)?;
let hash = hmac_sha256::Hash::hash(cert.der().as_ref()); let hash = hmac_sha256::Hash::hash(cert.der().as_ref());
client_config.cert_hash = hash.into(); proxy_overides.cert_hash = Some(hash.into());
(cert.pem().into(), key_pair.serialize_pem().into()) (cert.pem().into(), key_pair.serialize_pem().into())
} }
@@ -123,13 +123,13 @@ async fn main() -> Result<()> {
let rustls_config = RustlsConfig::new(Keycert::new().cert(cert.as_slice()).key(key.as_slice())); let rustls_config = RustlsConfig::new(Keycert::new().cert(cert.as_slice()).key(key.as_slice()));
info!( info!(
"client config:\n{}", "proxy overides:\n{}",
toml::to_string_pretty(&client_config)? toml::to_string_pretty(&proxy_overides)?
); );
let config_craft = ConfigCraft { let config_craft = ConfigCraft {
server_config: server_config.clone(), server_config: server_config.clone(),
client_config, proxy_overides,
}; };
let status_craft = StatusCraft { let status_craft = StatusCraft {
@@ -252,14 +252,14 @@ impl StatusCraft {
#[derive(Clone)] #[derive(Clone)]
pub struct ConfigCraft { pub struct ConfigCraft {
server_config: Arc<Config>, server_config: Arc<Config>,
client_config: ProxyOverides, proxy_overides: ProxyOverides,
} }
#[craft] #[craft]
impl ConfigCraft { impl ConfigCraft {
#[craft(handler)] #[craft(handler)]
async fn get_config(&self) -> Json<ProxyOverides> { async fn get_config(&self) -> Json<ProxyOverides> {
Json(self.client_config.clone()) Json(self.proxy_overides.clone())
} }
#[craft(handler)] #[craft(handler)]