mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-15 06:06:07 -06:00
[PR #422] fix: hostname resolution via OS resolver + multi-homed DTLS listener #414
Labels
No labels
Xorg
documentation
enhancement
macos
pull-request
question
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/lan-mouse#414
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/feschber/lan-mouse/pull/422
Author: @jondkinney
Created: 5/6/2026
Status: 🔄 Open
Base:
main← Head:split/03-network📝 Commits (3)
dd6ccadfix(dns): resolve hostnames via the OS resolver instead of pure DNScd43ed4fix(listen): bind one DTLS listener per local IPv4 address70a6e2cfix(listen): periodic reconciliation drops stale per-IP listeners📊 Changes
5 files changed (+626 additions, -284 deletions)
View changed files
📝
Cargo.lock(+268 -204)📝
Cargo.toml(+2 -1)📝
src/dns.rs(+21 -11)📝
src/listen.rs(+335 -65)📝
src/service.rs(+0 -3)📄 Description
Summary
Two unrelated-but-bundled fixes for "lan-mouse should Just Work on real LANs" — one for hostname resolution, one for multi-homed hosts. Together they remove the most common need for the manual
ips=[…]workaround.Hostname resolution via the OS resolver (
9ce3847)hickory_resolver::TokioResolveronly consults/etc/resolv.confand queries upstream DNS servers — which means it can't see/etc/hosts, mDNS/Avahi/Bonjour, NetBIOS, or anything else in the system's full name-resolution stack. On a typical home LAN there's no DNS server that knows about peer machine names, so users had to fall back to typing IP addresses, which broke the moment they moved their setup to a different network.Swap to
tokio::net::lookup_host, which callsgetaddrinfo. That walks/etc/nsswitch.confon Linux (picking up Avahi-resolved.localnames,/etc/hosts, and DNS), uses Bonjour for.localon macOS, and the full Windows resolver on Windows. A Bonjour hostname likeJKMBP-M4-Max.localnow resolves on every modern network without explicit configuration; the user can carry their two machines between LANs and the connection still finds them. Drop thehickory-resolverdependency entirely; lookup failures surface asio::Error, already covered byServiceError::Io.Multi-homed DTLS listener (
2c7ce2e/4c80ed0)When a host has two interfaces on the same subnet (macOS Wi-Fi
en0+ USB-C docken7both on192.168.1.0/24), a single0.0.0.0:portDTLS listener silently breaks for peers that dial the non-routed IP: the kernel sources its reply from the routing table's preferred interface, so the reply's src-IP doesn't match the 4-tuple the peer expects, andwebrtc-dtlsdrops the packet.Replace the single
0.0.0.0bind with oneListenerper local IPv4 address (loopback + link-local skipped), each socket bound to a specific IP so the kernel uses that IP as source — symmetric replies guaranteed regardless of the routing table. Anif-watchsupervisor task adds/drops listener slots dynamically on interface up/down; plugging a dock or toggling Wi-Fi no longer requires a lan-mouse restart.The supervisor also runs a 30-second reconciliation tick that diffs the live
getifaddrsset against the listeners HashMap.if-watchon macOS uses Network.framework, which doesn't reliably fireIfEvent::Downwhen an interface is administratively disabled (e.g. user toggles Wi-Fi off in System Settings); the polling backup catches whatever the event stream misses, both adds and drops.Falls back to a single
0.0.0.0bind only if interface enumeration or every per-IP bind fails — preserves single-NIC behavior and ensures we never silently fail to listen.Removes the previous user-facing workaround of forcing
ips = ["192.168.1.88"]on the peer.Test plan
JKMBP-M4-Max.localresolves on a fresh network without any DNS-server configif-watch0.0.0.0bind (no behavior change)Split out from #418, the umbrella PR collecting ~10 independent feature areas. This PR contains the hostname-resolution and multi-homed-listener subsets. See #418 for the full picture.
Stack overview
These PRs are split out from #418 and stack in this order:
Each PR's branch builds on the previous one, so until earlier PRs are merged the cumulative diff against
mainincludes all preceding work. Reviewing in order is easiest.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.