Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bb6648654 | |||
| eab8f1d6a7 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
||||
pub struct ClientConfig {
|
||||
pub struct ProxyOverides {
|
||||
pub proxy_url: Option<String>,
|
||||
pub cert_hash: Option<Vec<u8>>,
|
||||
pub any_server: bool,
|
||||
|
||||
+7
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use mime_guess::Mime;
|
||||
use mumble_web2_common::{ClientConfig, ServerStatus};
|
||||
use mumble_web2_common::{ProxyOverides, ServerStatus};
|
||||
use ordermap::OrderSet;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -23,7 +23,7 @@ pub enum Command {
|
||||
Connect {
|
||||
address: String,
|
||||
username: String,
|
||||
config: ClientConfig,
|
||||
config: ProxyOverides,
|
||||
},
|
||||
SendChat {
|
||||
markdown: String,
|
||||
@@ -309,7 +309,7 @@ pub fn ChatView() -> Element {
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ControlView(config: Resource<ClientConfig>) -> Element {
|
||||
pub fn ControlView(config: Resource<ProxyOverides>) -> Element {
|
||||
let net: Coroutine<Command> = use_coroutine_handle();
|
||||
let status = &STATE.status;
|
||||
let server = STATE.server.read();
|
||||
@@ -508,7 +508,7 @@ pub fn ControlView(config: Resource<ClientConfig>) -> Element {
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ServerView(config: Resource<ClientConfig>) -> Element {
|
||||
pub fn ServerView(config: Resource<ProxyOverides>) -> Element {
|
||||
let net: Coroutine<Command> = use_coroutine_handle();
|
||||
let server = STATE.server.read();
|
||||
let Some(&UserState {
|
||||
@@ -546,7 +546,7 @@ pub fn ServerView(config: Resource<ClientConfig>) -> Element {
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn LoginView(config: Resource<ClientConfig>) -> 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>>);
|
||||
@@ -723,9 +723,9 @@ pub fn app() -> Element {
|
||||
|
||||
use_coroutine(|rx: UnboundedReceiver<Command>| super::network_entrypoint(rx));
|
||||
let config = use_resource(|| async move {
|
||||
match imp::load_config().await {
|
||||
match imp::load_proxy_overides().await {
|
||||
Ok(config) => config,
|
||||
Err(_) => ClientConfig::default(),
|
||||
Err(_) => ProxyOverides::default(),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use dioxus::hooks::UnboundedReceiver;
|
||||
use etcetera::{choose_app_strategy, AppStrategy, AppStrategyArgs};
|
||||
use futures::io::{AsyncRead, AsyncWrite};
|
||||
use mumble_protocol::control::ClientControlCodec;
|
||||
use mumble_web2_common::{ClientConfig, ServerStatus};
|
||||
use mumble_web2_common::{ProxyOverides, ServerStatus};
|
||||
use std::collections::HashMap;
|
||||
use std::mem::replace;
|
||||
use std::net::ToSocketAddrs;
|
||||
@@ -284,7 +284,7 @@ pub async fn network_connect(
|
||||
address: String,
|
||||
username: String,
|
||||
event_rx: &mut UnboundedReceiver<Command>,
|
||||
gui_config: &ClientConfig,
|
||||
proxy_overides: &ProxyOverides,
|
||||
) -> Result<(), Error> {
|
||||
info!("connecting");
|
||||
|
||||
@@ -366,8 +366,8 @@ pub fn load_server_url() -> Option<String> {
|
||||
config.get("server").cloned()
|
||||
}
|
||||
|
||||
pub async fn load_config() -> color_eyre::Result<ClientConfig> {
|
||||
Ok(ClientConfig {
|
||||
pub async fn load_proxy_overides() -> color_eyre::Result<ProxyOverides> {
|
||||
Ok(ProxyOverides {
|
||||
proxy_url: None,
|
||||
cert_hash: None,
|
||||
any_server: true,
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@ use futures::{AsyncRead, AsyncWrite};
|
||||
use gloo_timers::future::TimeoutFuture;
|
||||
use js_sys::Float32Array;
|
||||
use mumble_protocol::control::ClientControlCodec;
|
||||
use mumble_web2_common::{ClientConfig, ServerStatus};
|
||||
use mumble_web2_common::{ProxyOverides, ServerStatus};
|
||||
use reqwest::Url;
|
||||
use std::future::Future;
|
||||
use std::time::Duration;
|
||||
@@ -329,7 +329,7 @@ pub async fn network_connect(
|
||||
address: String,
|
||||
username: String,
|
||||
event_rx: &mut UnboundedReceiver<Command>,
|
||||
gui_config: &ClientConfig,
|
||||
proxy_overides: &ProxyOverides,
|
||||
) -> Result<(), Error> {
|
||||
info!("connecting");
|
||||
|
||||
@@ -342,7 +342,7 @@ pub async fn network_connect(
|
||||
)
|
||||
.ey()?;
|
||||
|
||||
if let Some(server_hash) = &gui_config.cert_hash {
|
||||
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_config() -> color_eyre::Result<ClientConfig> {
|
||||
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")?,
|
||||
@@ -431,7 +431,7 @@ pub async fn load_config() -> color_eyre::Result<ClientConfig> {
|
||||
|
||||
let config = reqwest::get(config_url)
|
||||
.await?
|
||||
.json::<ClientConfig>()
|
||||
.json::<ProxyOverides>()
|
||||
.await?;
|
||||
|
||||
Ok(config)
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ use mumble_protocol::voice::VoicePacket;
|
||||
use mumble_protocol::voice::VoicePacketPayload;
|
||||
use mumble_protocol::Clientbound;
|
||||
use mumble_protocol::Serverbound;
|
||||
use mumble_web2_common::ClientConfig;
|
||||
use mumble_web2_common::ProxyOverides;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
|
||||
+9
-9
@@ -1,5 +1,5 @@
|
||||
use color_eyre::eyre::{anyhow, bail, Context, Result};
|
||||
use mumble_web2_common::{ClientConfig, ServerStatus};
|
||||
use mumble_web2_common::{ProxyOverides, ServerStatus};
|
||||
use rand::Rng;
|
||||
use salvo::conn::rustls::{Keycert, RustlsConfig};
|
||||
use salvo::cors::{AllowOrigin, Cors};
|
||||
@@ -77,7 +77,7 @@ async fn main() -> Result<()> {
|
||||
.install_default()
|
||||
.map_err(|e| anyhow!("could not install crypto provider {e:?}"))?;
|
||||
|
||||
let mut client_config = ClientConfig {
|
||||
let mut proxy_overides = ProxyOverides {
|
||||
proxy_url: match &server_config.proxy_url {
|
||||
Some(url) => Some(url.to_string()),
|
||||
None => None,
|
||||
@@ -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 = Some(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: ClientConfig,
|
||||
proxy_overides: ProxyOverides,
|
||||
}
|
||||
|
||||
#[craft]
|
||||
impl ConfigCraft {
|
||||
#[craft(handler)]
|
||||
async fn get_config(&self) -> Json<ClientConfig> {
|
||||
Json(self.client_config.clone())
|
||||
async fn get_config(&self) -> Json<ProxyOverides> {
|
||||
Json(self.proxy_overides.clone())
|
||||
}
|
||||
|
||||
#[craft(handler)]
|
||||
|
||||
Reference in New Issue
Block a user