Repository navigation
Replace a server's accepted short IDs at runtime and revoke sessions - #18
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KqE58aYaai3u8CFZe5nXdE
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KqE58aYaai3u8CFZe5nXdE
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified in credential replacement, synchronized revocation, or the targeted tests.
No open issues 🎉
What changed in this PR
Enables runtime updates to accepted client short IDs without restarting the server, supporting helper-invite credential rotation.
Changes:
- Adds atomic credential replacement and a copy-returning accessor.
- Revokes affected sessions and prevents registration from bypassing revocation.
- Adds tests for updates, revocation, defensive copies, and registration timing.
| File | Description |
|---|---|
| shortids_test.go | Tests credential updates, session revocation, and copy isolation. |
| server.go | Adds runtime credential management and synchronized session tracking. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets a running samizdat server change which client short IDs it accepts, without rebinding its listener. Sessions already authenticated with a removed ID are ended.
This is the transport half of Lantern's helper invites direct mode. A volunteer serves specific paired users. Each pairing gets its own short ID, which lantern-cloud rotates every 15 minutes, and the volunteer's app pushes the current set to its running inbound about every 150s. Until now the short-ID set was fixed at
NewServer, so the only way to change credentials was to rebuild the server, which drops the port and resets every client.Changes
(*Server).SetShortIDs([][8]byte) error:atomic.Pointerholding a private copy);NewServeralready does.(*Server).ShortIDs() [][8]bytereturns a copy of the current set.SetShortIDscloses the connections of sessions whose ID was removed. It closes them after releasing its lock, and stream handlers see an ordinary disconnect.SetShortIDs. The configured set is copied atNewServer, so mutating the caller'sServerConfig.ShortIDsslice afterwards no longer silently changes what the server accepts.Tests
shortids_test.go, end to end through a real client and server:SetShortIDs, and is rejected after the ID is removed;ShortIDs()returns a copy.TestTrackSessionRefusesIDRevokedAfterVerifycovers the refuse-at-track-time branch deterministically.go test -race -count=1 ./...passes. The new tests also passed-count=20under-race.Pre-PR review (local Codex gate)
round=1 CODEX GATE: verdict=approve critical=0 important=0 minor=0 reviewed=12golangci-lint's defaulterrcheckreports uncheckedCloseandSetReadDeadlinecalls, 17 in the new test file and one inserver.go. The repo has no lint config, its CI doesn't run golangci-lint, and existing code follows the same style, so I left them.A separate per-task review (spec compliance plus code quality) also ran. It confirmed the swap/scan versus track-time re-check closes the verify-then-revoke race. Its minor findings (the track-time test, the doc wording, a goroutine leak in the test relay) are fixed in 46dbfb0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KqE58aYaai3u8CFZe5nXdE
Summary by CodeRabbit