Skip to content

feat(proxy): support LAN mode with mDNS#430

Merged
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat-proxy-mdns
May 8, 2026
Merged

feat(proxy): support LAN mode with mDNS#430
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat-proxy-mdns

Conversation

@gaojunran

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds LAN mode to the pitchfork reverse proxy, allowing other devices on the local network to reach registered daemons via <slug>.local hostnames using mDNS. A new SyncMdns IPC message keeps mDNS records in sync when slugs are added or removed at runtime.

  • New mdns.rs and lan_ip.rs: MdnsPublisher wraps mdns-sd to register/unregister virtual _pitchfork._tcp service records per slug; detect_lan_ip probes the default route via a UDP connect and falls back to nix::ifaddrs enumeration on Unix to find the outbound LAN IP.
  • Supervisor integration: start_mdns is called after the proxy binds successfully and launches a 5-second polling task that republishes all records when the LAN IP changes; close() aborts the monitor and sends mDNS goodbye packets before the proxy task is torn down.
  • Settings / IPC / CLI: Two new settings (proxy.lan, proxy.lan_ip), a new SyncMdns round-trip, and CLI proxy add/remove hooks round out the feature.

Confidence Score: 5/5

Safe to merge; the new LAN / mDNS path is additive and disabled by default, so existing behaviour is unchanged for users who do not set proxy.lan or proxy.lan_ip.

The feature is opt-in and the shutdown sequence correctly aborts the monitor task and sends mDNS goodbye packets before the proxy task exits. The two inline suggestions are minor observability and ordering improvements, not correctness blockers.

src/supervisor/mod.rs (shutdown ordering of monitor task vs. publisher lock) and src/proxy/server.rs (silent LAN bind override).

Important Files Changed

Filename Overview
src/proxy/mdns.rs New MdnsPublisher wrapping mdns-sd; handles publish/unpublish/republish_all correctly with proper shutdown sequencing and mutex-serialized access.
src/proxy/lan_ip.rs New UDP-probe + nix::ifaddrs LAN IP detection; cfg(unix/not(unix)) stubs ensure cross-platform compilation, though the virtual-interface name checks have some discussed edge cases.
src/supervisor/mod.rs Adds start_mdns/sync_mdns and the LAN monitor task; the abort-without-await before publisher shutdown is a minor ordering concern flagged inline.
src/proxy/server.rs LAN mode conditionally overrides bind address to 0.0.0.0; the override is silent in logs, unlike the adjacent invalid-IP warning path.
src/proxy/mod.rs Adds pub mod lan_ip and pub mod mdns without cfg(unix) guards; lan_ip.rs provides non-unix stubs internally so it compiles, but the declaration-level guards are conventional.
src/ipc/client.rs Adds sync_mdns() method with correct graceful degradation for old supervisors that return Error for unknown IPC variants.
src/supervisor/lifecycle.rs Conditionally omits HOST=127.0.0.1 in LAN mode (correct), updates VITE host allowlisting for .local TLD, and adds PITCHFORK_LAN env var.
src/ipc/mod.rs Adds SyncMdns request and MdnsSynced response to the IPC enum; clean, minimal change.
src/supervisor/ipc_handlers.rs Wires SyncMdns IPC request to supervisor.sync_mdns(); always returns MdnsSynced regardless of LAN mode state.
src/proxy/hosts.rs sync_hosts_from_settings updated for LAN mode; falls back to proxy.host when lan_ip is not pinned since async-detected IP is unavailable synchronously.
Cargo.toml Adds mdns-sd as a universal dependency (cross-platform crate) and extends nix with net and ioctl features for ifaddrs.

Reviews (3): Last reviewed commit: "feat(proxy): support mdns" | Re-trigger Greptile

Comment thread src/supervisor/mod.rs
Comment thread src/proxy/mdns.rs Outdated
Comment thread src/proxy/lan_ip.rs
Comment thread src/proxy/mod.rs
@gaojunran gaojunran changed the title feat(proxy): support LAN mode and mDNS feat(proxy): support LAN mode with mDNS May 7, 2026
@gaojunran gaojunran marked this pull request as ready for review May 8, 2026 11:35
@jdx jdx merged commit e70c934 into jdx:main May 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants