hub v0.51.0: DR-tier-by-default — per-customer dr_tier flag (default ON, legacy backfill from reality), cascade stages, WG-registration auto-provision hook, offsite-requires-DR guard (F-6 policy), host-page capability chips (inactive=neutral)

Claude-Session: https://claude.ai/code/session_01NptTCFtu7dz2Ru89qHRagN
This commit is contained in:
2026-07-12 20:37:00 +02:00
parent 007946faf4
commit 448a68237a
18 changed files with 824 additions and 87 deletions
+13
View File
@@ -2,6 +2,7 @@ package api
import (
"bytes"
"context"
"crypto/subtle"
"database/sql"
"encoding/base64"
@@ -58,6 +59,13 @@ type Handler struct {
// claimEngine is the customer-claim code engine (v0.50.0). nil = claim arc disabled: no codes
// issued, no claim field in ACKs/configs — pre-arc behavior exactly.
claimEngine *claim.Engine
// wgRegisteredHook (v0.51.0, DR-tier-by-default scenario A) fires after a host's FIRST WG
// peer registration — main.go wires it to the web server's PBSDRAutoProvision so a DR-ON
// customer's pbs_dr descriptor lands hands-free (WG registers → provision → the agent's next
// desired-state tick). nil = no cascade hook (pre-v0.51.0 behavior). Runs in a detached
// goroutine; must never delay or fail the registration response.
wgRegisteredHook func(ctx context.Context, customerID string)
}
// SetClaimEngine wires the customer-claim code engine (nil-safe everywhere it is used).
@@ -65,6 +73,11 @@ func (h *Handler) SetClaimEngine(e *claim.Engine) {
h.claimEngine = e
}
// SetWGRegisteredHook wires the post-WG-registration cascade hook (v0.51.0; nil-safe).
func (h *Handler) SetWGRegisteredHook(f func(ctx context.Context, customerID string)) {
h.wgRegisteredHook = f
}
// SetLatestVersionProvider wires the registry version checker so the controller report ACK can
// advertise the latest available version (Phase 2). nil-safe (no latest_version field emitted).
func (h *Handler) SetLatestVersionProvider(p LatestVersionProvider) {
+7
View File
@@ -295,6 +295,13 @@ func (h *Handler) handleRegisterHostWG(w http.ResponseWriter, r *http.Request, p
return
}
syncStatus = h.syncAfterMutation(r.Context())
// v0.51.0 DR-tier cascade (scenario A): a NEW tunnel peer may be the pbs_dr descriptor's
// last unmet precondition — fire the hook so a DR-ON customer provisions hands-free.
// Detached goroutine: registration must never wait on (or fail over) ep0 provisioning;
// the hook itself detaches+bounds its context and logs every outcome.
if h.wgRegisteredHook != nil && host.CustomerID != "" {
go h.wgRegisteredHook(context.WithoutCancel(r.Context()), host.CustomerID)
}
}
h.logger.Printf("[INFO] wg registered: host=%s pubkey=%s ip=%s/32 changed=%v gen=%d sync=%s",
pathHostID, req.Pubkey, ip, changed, gen, syncStatus)