Move mumble UDP ping into common crate (#33)
Build Mumble Web 2 / macos_build (push) Failing after 2s
Build Mumble Web 2 / linux_build (push) Failing after 0s
Build Mumble Web 2 / android_build (push) Failing after 3s
Build Mumble Web 2 / windows_build (push) Failing after 10s

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>
This commit was merged in pull request #33.
This commit is contained in:
2026-05-05 04:37:19 +00:00
committed by Sam Sartor
parent 63ce666fa7
commit e72bb6d4c4
14 changed files with 112 additions and 231 deletions
+2
View File
@@ -133,6 +133,7 @@ desktop = [
"cpal",
"dasp_ring_buffer",
"etcetera",
"mumble-web2-common/networking",
]
mobile = [
"tokio",
@@ -141,4 +142,5 @@ mobile = [
"opus",
"cpal",
"dasp_ring_buffer",
"mumble-web2-common/networking",
]
+2 -6
View File
@@ -1,5 +1,5 @@
use crate::app::{Command, SharedState};
use color_eyre::eyre::{bail, Error};
use color_eyre::eyre::Error;
use futures_channel::mpsc::UnboundedReceiver;
use mumble_protocol::control::ClientControlCodec;
use std::net::ToSocketAddrs;
@@ -14,7 +14,7 @@ use tokio_rustls::TlsConnector;
use tokio_util::compat::{TokioAsyncReadCompatExt as _, TokioAsyncWriteCompatExt as _};
use tracing::{info, instrument};
use mumble_web2_common::{ProxyOverrides, ServerStatus};
use mumble_web2_common::ProxyOverrides;
#[derive(Debug)]
struct NoCertificateVerification;
@@ -108,10 +108,6 @@ pub async fn network_connect(
crate::network_loop(username, state, event_rx, outgoing_send, reader).await
}
pub async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
bail!("status not supported on desktop yet")
}
#[allow(unused)]
pub use tokio::spawn;
#[allow(unused)]
+5 -2
View File
@@ -33,8 +33,11 @@ impl super::PlatformInterface for DesktopPlatform {
super::connect::network_connect(address, username, event_rx, overrides, state).await
}
async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
super::connect::get_status(client).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() {
+5 -2
View File
@@ -29,8 +29,11 @@ impl super::PlatformInterface for MobilePlatform {
super::connect::network_connect(address, username, event_rx, overrides, state).await
}
async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
super::connect::get_status(client).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() {
+6 -1
View File
@@ -86,9 +86,14 @@ pub trait PlatformInterface {
state: SharedState,
) -> impl Future<Output = Result<(), Error>>;
/// Get server status (user count, version, etc.).
/// Get server status (user count, version, etc.) for the given address.
///
/// On web, this goes through the proxy's /status endpoint and ignores `address`
/// (the proxy is bound to a specific server). On desktop/mobile, this pings the
/// given address directly via UDP.
fn get_status(
client: &reqwest::Client,
address: &str,
) -> impl Future<Output = color_eyre::Result<ServerStatus>>;
/// Load the proxy overrides (proxy URL, cert hash, etc.).
+1
View File
@@ -32,6 +32,7 @@ impl super::PlatformInterface for StubPlatform {
fn get_status(
_client: &reqwest::Client,
_address: &str,
) -> impl Future<Output = color_eyre::Result<ServerStatus>> {
async { panic!("stubbed platform") }
}
+4 -1
View File
@@ -117,7 +117,10 @@ impl super::PlatformInterface for WebPlatform {
network_connect(address, username, event_rx, overrides, state).await
}
async fn get_status(client: &reqwest::Client) -> color_eyre::Result<ServerStatus> {
async fn get_status(
client: &reqwest::Client,
_address: &str,
) -> color_eyre::Result<ServerStatus> {
Ok(client
.get(absolute_url("status")?)
.send()