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)]
pub struct ProxyOverides {
pub proxy_url: String,
pub cert_hash: Vec<u8>,
pub proxy_url: Option<String>,
pub cert_hash: Option<Vec<u8>>,
pub any_server: bool,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
+12 -18
View File
@@ -309,7 +309,7 @@ pub fn ChatView() -> Element {
}
#[component]
pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element {
pub fn ControlView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle();
let status = &STATE.status;
let server = STATE.server.read();
@@ -331,8 +331,7 @@ pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element {
let proxy_url = config
.read_unchecked()
.as_ref()
.and_then(|opt| opt.as_ref())
.map(|gui_config| gui_config.proxy_url.clone());
.and_then(|gui_config| gui_config.proxy_url.clone());
let connecting_color = "yellow";
let connected_color = "oklch(0.55 0.1184 141.35)";
@@ -509,7 +508,7 @@ pub fn ControlView(config: Resource<Option<ProxyOverides>>) -> Element {
}
#[component]
pub fn ServerView(config: Resource<Option<ProxyOverides>>) -> Element {
pub fn ServerView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle();
let server = STATE.server.read();
let Some(&UserState {
@@ -547,7 +546,7 @@ pub fn ServerView(config: Resource<Option<ProxyOverides>>) -> Element {
}
#[component]
pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
pub fn LoginView(config: Resource<ProxyOverides>) -> Element {
let net: Coroutine<Command> = use_coroutine_handle();
let last_status = use_signal(|| None::<color_eyre::Result<ServerStatus>>);
@@ -565,8 +564,7 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
addr.clone()
} else {
config()
.flatten()
.map(|c| c.proxy_url.clone())
.and_then(|c| c.proxy_url.clone())
.unwrap_or_default()
}
});
@@ -577,13 +575,13 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
let do_connect = move |_| {
//let _ = 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());
}
net.send(Connect {
address: address.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;
@@ -628,7 +626,7 @@ pub fn LoginView(config: Resource<Option<ProxyOverides>>) -> Element {
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 {
label {
for: "address-entry",
@@ -727,7 +725,7 @@ pub fn app() -> Element {
let config = use_resource(|| async move {
match imp::load_proxy_overides().await {
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: STYLE }
if config.read().is_none() {
div { class: "loading", "Loading..." }
} else {
match *STATE.status.read() {
Connected => rsx!(ServerView { config }),
_ => 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,
username: String,
event_rx: &mut UnboundedReceiver<Command>,
gui_config: &ProxyOverides,
proxy_overides: &ProxyOverides,
) -> Result<(), Error> {
info!("connecting");
@@ -366,8 +366,12 @@ pub fn load_server_url() -> Option<String> {
config.get("server").cloned()
}
pub async fn load_proxy_overides() -> color_eyre::Result<Option<ProxyOverides>> {
Ok(None)
pub async fn load_proxy_overides() -> color_eyre::Result<ProxyOverides> {
Ok(ProxyOverides {
proxy_url: None,
cert_hash: None,
any_server: true,
})
}
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,
username: String,
event_rx: &mut UnboundedReceiver<Command>,
gui_config: &ProxyOverides,
proxy_overides: &ProxyOverides,
) -> Result<(), Error> {
info!("connecting");
@@ -342,8 +342,8 @@ pub async fn network_connect(
)
.ey()?;
if !gui_config.cert_hash.is_empty() {
let hash = web_sys::js_sys::Uint8Array::from(gui_config.cert_hash.as_slice());
if let Some(server_hash) = &proxy_overides.cert_hash {
let hash = web_sys::js_sys::Uint8Array::from(server_hash.as_slice());
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)?)
}
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") {
Some(url) => Url::parse(url)?,
None => absolute_url("config")?,
@@ -434,7 +434,7 @@ pub async fn load_proxy_overides() -> color_eyre::Result<Option<ProxyOverides>>
.json::<ProxyOverides>()
.await?;
Ok(Some(config))
Ok(config)
}
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()
.map_err(|e| anyhow!("could not install crypto provider {e:?}"))?;
let mut client_config = ProxyOverides {
proxy_url: server_config
.proxy_url
.as_ref()
.map(|url| url.to_string())
.unwrap_or_default(),
cert_hash: Vec::new(),
let mut proxy_overides = ProxyOverides {
proxy_url: match &server_config.proxy_url {
Some(url) => Some(url.to_string()),
None => None,
},
cert_hash: None,
any_server: false,
};
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 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())
}
@@ -123,13 +123,13 @@ async fn main() -> Result<()> {
let rustls_config = RustlsConfig::new(Keycert::new().cert(cert.as_slice()).key(key.as_slice()));
info!(
"client config:\n{}",
toml::to_string_pretty(&client_config)?
"proxy overides:\n{}",
toml::to_string_pretty(&proxy_overides)?
);
let config_craft = ConfigCraft {
server_config: server_config.clone(),
client_config,
proxy_overides,
};
let status_craft = StatusCraft {
@@ -252,14 +252,14 @@ impl StatusCraft {
#[derive(Clone)]
pub struct ConfigCraft {
server_config: Arc<Config>,
client_config: ProxyOverides,
proxy_overides: ProxyOverides,
}
#[craft]
impl ConfigCraft {
#[craft(handler)]
async fn get_config(&self) -> Json<ProxyOverides> {
Json(self.client_config.clone())
Json(self.proxy_overides.clone())
}
#[craft(handler)]