Skip to content

fix(lan): pairing ignores a key's stored name; sharing restarts on a new key - #260

Merged
mindaugaskasp merged 1 commit into
mainfrom
fix/lan-legacy-key-name
Nov 17, 2026
Merged

mindaugaskasp merged 1 commit into
mainfrom
fix/lan-legacy-key-name

Conversation

@mindaugaskasp

Copy link
Copy Markdown
Owner

Fixes "Connection lost" when adding a PC, found from the logs on both machines:

  • Mac: add f84018a8: closed before the code step
  • Windows: unexpected add-reply at connecting

The connection itself worked. Each side was rejecting the other's key.

1. Long key names (from before #124). The Mac's key dated from before key names were capped at 40 characters, and carried an 80-character name. Pairing sent the stored key as it was, and every receiver ran the import check, which refuses names over 40.

2. A key reset didn't reach network sharing. Sharing captured the identity once, at startup. After a reset it kept announcing and pairing with the old key, which is why resetting both keys changed nothing. It would also have signed Stop sharing notices with a retired key, which may only decrypt.

  • Writing the identity now notifies a listener (identityEvents.js), and sharing restarts when the fingerprint changed.
  • The trust refresh timer no longer piles up across restarts.

Tests, each seen failing first:

  • e2e: a key with an 80-character name adds in both directions.
  • e2e: after a key reset, the other machine sees the new fingerprint without a restart.
  • unit: the pairing key reader and writer.

Another testing gap this exposed: e2e only ever used brand-new keys, so data created under older rules was never exercised. The first test now covers the case that bit here.

Verified:

  • npm run check passes.
  • Full make e2e: 799 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PJaGuL4V5ghYxXSGoyYU8n

…n a new key

Adding a PC failed in both directions with "closed before the code step" on
one side and "unexpected add-reply at connecting" on the other. Two causes,
both reproduced by e2e tests that failed first:

- A key made before names were capped at 40 (#124) still carries its longer
  name. Pairing sent the stored key as it was, and every receiver ran the
  import check, which refuses names over 40. Pairing saves a key under the
  name the user clicked, so its own name is never read: it now sends keys
  without one (parseKeyText still accepts that, so v0.19.3 receivers do too)
  and reads keys while ignoring it. .diffbrokey import keeps the 40 rule.
- Sharing captured the identity at startup. After a key reset it kept
  announcing and pairing with the old key, and would have signed Stop
  sharing notices with a retired key, which may only decrypt. Writing the
  identity now notifies a listener, and sharing restarts when the
  fingerprint changed. The trust refresh timer no longer piles up across
  restarts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJaGuL4V5ghYxXSGoyYU8n
@mindaugaskasp
mindaugaskasp merged commit d912edc into main Nov 17, 2026
17 checks passed
@mindaugaskasp
mindaugaskasp deleted the fix/lan-legacy-key-name branch November 17, 2026 21:03
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.

1 participant