From 925ffb1f3a3cd82e7e77bea499cd050e12067cd0 Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:52:46 +0700 Subject: [PATCH] fix(link): advertise the desktop over IPv4 only mDNS answers on Wi-Fi carried every link-local IPv6 address of the machine, including the loopback's fe80::1, which on most networks is the router. Android before 14 keeps a single resolved address and could pick it, leaving the phone with an unresolvable .local name, so finding the computer failed and pairing needed a typed address. Loopback is not advertised either; nobody on the network can use it. --- rust_backend/crates/link/src/mdns.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rust_backend/crates/link/src/mdns.rs b/rust_backend/crates/link/src/mdns.rs index c5969f158..9cdf5f0ae 100644 --- a/rust_backend/crates/link/src/mdns.rs +++ b/rust_backend/crates/link/src/mdns.rs @@ -1,9 +1,9 @@ //! Discovery (contract section 2): advertises `_mornye._tcp.local.` with the //! server name as the instance name and TXT `v=1`, `id=`, -//! `fp=` on every interface. Advertising is best effort; the -//! server works without it when the phone knows the address. +//! `fp=` on every IPv4 interface. Advertising is best effort; +//! the server works without it when the phone knows the address. -use mdns_sd::{ServiceDaemon, ServiceInfo}; +use mdns_sd::{IfKind, ServiceDaemon, ServiceInfo}; use std::time::Duration; const SERVICE_TYPE: &str = "_mornye._tcp.local."; @@ -22,6 +22,14 @@ pub(crate) fn advertise( ) -> Result { let fail = |error: mdns_sd::Error| format!("mDNS advertising failed: {error}"); let daemon = ServiceDaemon::new().map_err(fail)?; + // IPv6 answers matched every link-local address to every interface, so + // Wi-Fi carried the loopback's fe80::1 (often the router's address). + // Android before 14 keeps one resolved address and could pick that + // one; the phone prefers IPv4 anyway. Loopback reaches nobody. + if let Err(error) = daemon.disable_interface(vec![IfKind::IPv6, IfKind::LoopbackV4]) { + let _ = daemon.shutdown(); + return Err(fail(error)); + } let short_id: String = server_id .chars() .filter(char::is_ascii_alphanumeric)