Skip to content

fix: handle macOS hostname drift in isSelf() (v0.26.6)#320

Merged
jpelaez-23blocks merged 1 commit intomainfrom
fix/hostname-drift-318
Apr 6, 2026
Merged

fix: handle macOS hostname drift in isSelf() (v0.26.6)#320
jpelaez-23blocks merged 1 commit intomainfrom
fix/hostname-drift-318

Conversation

@jpelaez-23blocks
Copy link
Copy Markdown
Contributor

Summary

  • Fixes MacOS hostname drift issue #318 — macOS hostname drift causes machine to lose mesh identity
  • Adds cached alias lookup to isSelf() so old hostnames are still recognized after OS hostname changes
  • Two-pass lookup in loadStoredSelfAliases(): hostname match first, then IP alias match with exactly-one-match guard to prevent DHCP false positives
  • Single file change (lib/hosts-config.ts), no changes to migrateHost(), validateHosts(), registerPeer(), or any other resolution logic

Test plan

  • Verify isSelf("old-hostname") returns true when hosts.json has entry with old hostname and matching IP in aliases
  • Verify remote hosts with coincidentally matching IPs are NOT claimed as self (ambiguous match = skip)
  • Verify normal operation unchanged when hostname has not drifted (pass 1 matches immediately)
  • Verify cache refreshes when clearHostsCache() is called after saving hosts

🤖 Generated with Claude Code

When macOS silently changes hostname (DHCP, Bonjour collision, docking),
isSelf() failed to recognize the old self host entry in hosts.json.
This caused the machine to lose its identity in the mesh network.

Fix: cache the self host's aliases at startup by matching against
hosts.json entries. Uses two-pass lookup — first by hostname (safe),
then by IP alias with exactly-one-match guard (prevents DHCP false
positives on remote hosts).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jpelaez-23blocks jpelaez-23blocks merged commit 79f60b8 into main Apr 6, 2026
3 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.

MacOS hostname drift issue

1 participant