Repository navigation
Add ShortIDFromContext so handlers can attribute a stream to its short ID - #20
Conversation
Add ShortIDFromContext alongside SessionConnFromContext so a Handler can tell which of the server's accepted short IDs its session authenticated with. handleAuthenticated already has it from VerifySessionID; serveH2 now carries it into the per-connection context every stream inherits. Additive only: no behavior change, and the ID is never logged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KqE58aYaai3u8CFZe5nXdE
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Expose short ID to handlers server.go, integration_test.go |
serveH2 receives the authenticated short ID and adds it to HTTP/2 request contexts. ShortIDFromContext reports whether the ID is present. Integration tests check IDs across clients and streams, plus missing-context cases. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Feature
Possibly related PRs
- getlantern/samizdat#17: Adds the session connection to the handler context, which PR
#20retains while adding the short ID. - getlantern/samizdat#18: Passes the verified short ID through authentication, which PR
#20uses when creating the handler context.
Merge Risk: 
Minimal · up to ee596
-
No merge-blocking issue is apparent from the supplied review evidence.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change adding session short-ID attribution to handler contexts.
No open issues 🎉
What changed in this PR
Adds ShortIDFromContext so handlers can attribute each stream to its session’s authenticated short ID, supporting per-pairing connection reporting.
Changes:
- Passes the verified short ID into the HTTP/2 session context alongside the session connection.
- Exposes an additive accessor returning the short ID and whether it is present.
- Adds tests for attribution across two clients with two streams each, plus missing-value behavior.
| File | Description |
|---|---|
server.go |
Propagates the authenticated short ID to handler contexts and adds its public accessor. |
integration_test.go |
Tests per-session short ID attribution and contexts without a short ID. |
Review effort: Balanced
Adds
ShortIDFromContext(ctx) ([8]byte, bool), so a handler can tell which short ID its session authenticated with.Why
Lantern's personal proxies give each helper-invite pairing its own samizdat short ID on the volunteer's peer proxy. To show "Adam connected right now" on the volunteer's device, lantern-box's samizdat inbound has to attribute each stream to a pairing. The server already verifies and tracks the short ID per session, but handlers could only reach the session's connection (
SessionConnFromContext).Changes
handleAuthenticatedpasses the short ID it verified toserveH2, which stores it in theServeConncontext next tosessionConnKey. Every stream's handler context inherits it.ShortIDFromContextsits next toSessionConnFromContext. The repo's short ID type is[shortIDLen]bytewithshortIDLen = 8, which the public API already spells[8]byte.Testing
TestIntegrationShortIDInContext: two clients, one per allowed short ID, two streams each. Each handler sees its own session's ID.TestShortIDFromContextMissing: a context without the ID returns the zero value and false.go build ./...,go vet ./...andgo test -race -count=1 ./...pass.golangci-lint run --new-from-rev=origin/mainreports 0 issues.Risk
Very low. The ID is fixed for a session's lifetime, which is fine because revoking an ID with
SetShortIDsalready closes the session.How to revert
Revert the merge commit.
Rollout
lantern-box will bump samizdat and add the short ID to
peerconn.Event(the next step).Pre-PR review (local Codex gate)
CODEX GATE: verdict=approve critical=0 important=0 minor=0 preexisting=0 reviewed=6ee59657approvegofmt -llistsconnpool.go,fragmenter.go,integration_test.go,samizdat.goandserver.goon main.AGENTS.mdadditions: none🤖 Generated with Claude Code
https://claude.ai/code/session_01KqE58aYaai3u8CFZe5nXdE
Summary by CodeRabbit