e72bb6d4c4
The desktop GUI doesn't go through the proxy to reach the Mumble server, so its login screen needs to ping directly. Rather than duplicate the ping logic, move it into the common crate behind an optional `networking` feature (so common stays lightweight when the feature isn't requested). - common: add `ping_server(address, port)` behind `networking` feature - proxy: replace the inline UdpSocket ping + ping.rs codec with a call to common::ping_server; drop the rand dep - client: PlatformInterface::get_status now takes an address; desktop and mobile call common::ping_server directly, web still uses the proxy's /status endpoint - gui: thread the address from the login input through get_status, so it re-pings when the user edits the address Assisted-by: claude-opus-4-7 Reviewed-on: #33 Reviewed-by: restitux <restitux@ohea.xyz> Co-authored-by: Sam Sartor <me@samsartor.com> Co-committed-by: Sam Sartor <me@samsartor.com>
62 lines
1.8 KiB
Rust
62 lines
1.8 KiB
Rust
use crate::app::{Command, SharedState};
|
|
use color_eyre::eyre::Error;
|
|
use futures_channel::mpsc::UnboundedReceiver;
|
|
use mumble_web2_common::{ProxyOverrides, ServerStatus};
|
|
use std::time::Duration;
|
|
|
|
/// Desktop platform implementation using Tokio and native audio.
|
|
pub struct DesktopPlatform;
|
|
|
|
impl super::PlatformInterface for DesktopPlatform {
|
|
type AudioSystem = super::native_audio::NativeAudioSystem;
|
|
type ConfigSystem = super::native_config::NativeConfigSystem;
|
|
|
|
async fn sleep(duration: Duration) {
|
|
tokio::time::sleep(duration).await;
|
|
}
|
|
|
|
async fn load_proxy_overrides() -> color_eyre::Result<ProxyOverrides> {
|
|
Ok(ProxyOverrides {
|
|
proxy_url: None,
|
|
cert_hash: None,
|
|
any_server: true,
|
|
})
|
|
}
|
|
|
|
async fn network_connect(
|
|
address: String,
|
|
username: String,
|
|
event_rx: &mut UnboundedReceiver<Command>,
|
|
overrides: &ProxyOverrides,
|
|
state: SharedState,
|
|
) -> Result<(), Error> {
|
|
super::connect::network_connect(address, username, event_rx, overrides, state).await
|
|
}
|
|
|
|
async fn get_status(
|
|
_client: &reqwest::Client,
|
|
address: &str,
|
|
) -> color_eyre::Result<ServerStatus> {
|
|
mumble_web2_common::ping_server(address, 64738).await
|
|
}
|
|
|
|
fn init_logging() {
|
|
use tracing::level_filters::LevelFilter;
|
|
use tracing_subscriber::filter::EnvFilter;
|
|
|
|
let env_filter = EnvFilter::builder()
|
|
.with_default_directive(LevelFilter::INFO.into())
|
|
.from_env_lossy();
|
|
|
|
tracing_subscriber::fmt()
|
|
.with_target(true)
|
|
.with_level(true)
|
|
.with_env_filter(env_filter)
|
|
.init();
|
|
}
|
|
|
|
fn request_permissions() {
|
|
// No-op on desktop
|
|
}
|
|
}
|