Skip to content

feat: add mDNS registration for mind-map.local - #18

Merged
aniongithub merged 7 commits into
mainfrom
feature/mdns
May 10, 2026
Merged

feat: add mDNS registration for mind-map.local#18
aniongithub merged 7 commits into
mainfrom
feature/mdns

Conversation

@aniongithub

Copy link
Copy Markdown
Owner

Summary

Registers the mind-map HTTP server via mDNS so it is discoverable as mind-map.local on the local network, per #10.

Changes

  • New internal/mdns package — wraps hashicorp/mdns with Register(port) / Shutdown() helpers
  • mDNS registration on startup — advertises _http._tcp service named mind-map with hostname mind-map.local
  • Default port changed to 80 — so http://mind-map.local works without a port suffix (applies to serve, service install/start/stop/uninstall/status, and install scripts)
  • --no-mdns flag — added to serve command (and propagated through the system service path) to disable mDNS registration
  • Install scripts updatedinstall.sh and install.ps1 default port updated from 51849 → 80

Notes

  • Port 80 requires root/elevated privileges; the server hard-fails if bind fails (user can override with --addr :51849 or any other port)
  • mDNS works out of the box on macOS (Bonjour), Linux (avahi-compatible), and Windows (Bonjour)
  • Clean mDNS shutdown on server stop

Closes #10

Register the HTTP server via mDNS (hashicorp/mdns) so it is
discoverable as mind-map.local on the local network.

- Add internal/mdns package with Register/Shutdown helpers
- Register _http._tcp service named 'mind-map' on serve startup
- Change default listen port from 51849 to 80 so http://mind-map.local
  works without specifying a port
- Add --no-mdns flag to serve command to disable registration
- Propagate --no-mdns through system service path

Closes #10
Both install.sh and install.ps1 now prompt during service setup:
- mDNS on/off (default: on), passes --no-mdns when disabled
- Port selection (default: 80) with availability check — loops
  until the user picks a free port
- Shows mDNS URL in post-install summary when enabled
Instead of running a second mDNS responder on port 5353 (which
conflicts with avahi-daemon on Linux and mDNSResponder on macOS),
register through the system daemon:

- Linux: avahi-publish-address + avahi-publish-service
- macOS/Windows: dns-sd -R (Bonjour)
- Fallback: hashicorp/mdns when no system daemon is available

Platform-specific files:
- mdns_linux.go: avahi path with virtual-interface filtering
- mdns_bonjour.go: dns-sd path (darwin + windows build tags)
- mdns_other.go: fallback stub for other platforms

Also update devcontainer for mDNS testing:
- Add avahi-daemon, avahi-utils, dbus to Dockerfile
- Add postStartCommand to start dbus + avahi
- Add --network=host for multicast access
VS Code's port forwarding binds the port on the host, which
conflicts when the server tries to bind the same port on the
shared host network. With --network=host all ports are already
accessible — forwardPorts is unnecessary.
The service record (avahi-publish-service) is the critical piece
and now registers under the machine's real hostname instead of
forcing --host=mind-map.local. The address record
(avahi-publish-address mind-map.local) is attempted best-effort
and logged as a warning if it fails (e.g. name collision).
Both installers now offer 'enter nothing to auto-pick a free port'
when the default port (80) is unavailable. Scans 8080-8180 for a
free port and selects the first available one.
mind-map is a personal wiki — it should not be accessible from
other machines on the network. Change default listen address from
:80 (all interfaces) to 127.0.0.1:80 (loopback only).

mDNS now advertises 127.0.0.1 so mind-map.local resolves to
loopback. Users type a friendly URL in their browser but the
wiki stays private to the machine.
@aniongithub
aniongithub merged commit ab466d2 into main May 10, 2026
1 check passed
@aniongithub
aniongithub deleted the feature/mdns branch May 10, 2026 06:22
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.

Add mDNS registration for friendly local name

1 participant