fix(registry): a heartbeat without a lease passes until LEASE_REQUIRED, live control always needs one #5

Merged
kblack0610 merged 1 commit from fix/registry-lease-optional-until-required into main 2026-10-24 19:43:14 +00:00
Owner

Fixes a regression from #1 (registry-v1.4.0): register hands every server a lease, and heartbeat then refused a call without one whatever LEASE_REQUIRED said. No shipped build sends X-Server-Lease, so since the roll every new listing was reaped every 90 s and came back under a new join code (seen on an Edgegap rc10 server: 7YCE3X -> NJCTPK -> TE2Q4Z).

  • A missing lease now follows LEASE_REQUIRED (off: token alone, on: 403). A wrong lease is still 403 either way.
  • Live control (admin/next, admin/replies, from #4) always demands the lease. Without the new always flag this change would have opened it to any token holder; TestLiveRefusesWhoShouldNot now checks a lease-less poll.
  • README Leases table rewritten per call, not per row.

Tests (golang:1.22-alpine, cgo): go vet clean, go test ./... ok. Negative controls: the old servers.go fails TestLeaseGuardsHeartbeatAndDeregister and TestLegacyRowsWithoutALease, and live.go with always=false fails TestLiveRefusesWhoShouldNot (204 for a lease-less poll).

https://claude.ai/code/session_01LBCNK5JGDhbjiup5PuTutT

Fixes a regression from #1 (registry-v1.4.0): register hands every server a lease, and heartbeat then refused a call without one whatever `LEASE_REQUIRED` said. No shipped build sends `X-Server-Lease`, so since the roll every new listing was reaped every 90 s and came back under a new join code (seen on an Edgegap rc10 server: 7YCE3X -> NJCTPK -> TE2Q4Z). - A missing lease now follows `LEASE_REQUIRED` (off: token alone, on: 403). A wrong lease is still 403 either way. - Live control (`admin/next`, `admin/replies`, from #4) always demands the lease. Without the new `always` flag this change would have opened it to any token holder; `TestLiveRefusesWhoShouldNot` now checks a lease-less poll. - README Leases table rewritten per call, not per row. Tests (golang:1.22-alpine, cgo): `go vet` clean, `go test ./...` ok. Negative controls: the old `servers.go` fails `TestLeaseGuardsHeartbeatAndDeregister` and `TestLegacyRowsWithoutALease`, and `live.go` with `always=false` fails `TestLiveRefusesWhoShouldNot` (204 for a lease-less poll). https://claude.ai/code/session_01LBCNK5JGDhbjiup5PuTutT
v1.4.0 gave every registering server a lease and then refused its heartbeat without
it, so every shipped build (none sends the header) lost its listing each reap and came
back under a new join code. A missing lease now follows LEASE_REQUIRED; a wrong one is
still refused, and admin/next and admin/replies demand it whatever the flag.

Claude-Session: https://claude.ai/code/session_01LBCNK5JGDhbjiup5PuTutT
kblack0610 deleted branch fix/registry-lease-optional-until-required 2026-10-24 19:43:14 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kblack0610/bnb-game-servers!5
No description provided.