Hub v0.158.0 code (built, NOT deployed): agent-only vouch, R-895 snapshot alarms, the hub's own 90-day access log (R-1140 A); installer --rotate-recovery-only (R-1141); 02/03/05/09 + break-glass
gates / gates (push) Successful in 6m45s
gates / gates (push) Successful in 6m45s
Hub: the R-120 golden guard judges only a CHANGED golden selection; offsite_snapshots_vanished / _unexplained (operator-only, hub-origin) on the 07:10 listing; internal/accesslog writes path-only lines to /data/access-log, 90 days. Installer: --rotate-recovery-only runs step 4b alone (rides the next installer tag). 03: the orphan check runs after a failed backup (agent 6545ccc). 02: the allow-list is empty, appdata_folders (controller v0.329.0). All red-proofed.
This commit is contained in:
1 parent
5a5486104a
commit
7d64038f02
27 files changed
+1813
-77
No files matched your search
+9
-1
@@ -14,6 +14,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/accesslog"
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/api"
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/assets"
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/claim"
|
||||
@@ -678,10 +679,16 @@ func main() {
|
||||
}
|
||||
mux.Handle("/", webServer.Handler())
|
||||
|
||||
// R-1140 (operator decision A, 2026-10-17): the hub's OWN access log — one line per request, a file per UTC day under
|
||||
// <data_dir>/access-log on the hub's volume, kept 90 days. Path only (no query), no credential value; a logging
|
||||
// failure never fails or delays a request (internal/accesslog). Pinned by TestServerHandlerIsAccessLogged.
|
||||
accessLog := accesslog.New(accesslog.Options{Dir: filepath.Join(cfg.Server.DataDir, "access-log"), Logf: logger.Printf})
|
||||
logger.Printf("[INFO] access log: %s, one file per UTC day, kept %d days", filepath.Join(cfg.Server.DataDir, "access-log"), int(accesslog.DefaultKeep.Hours()/24))
|
||||
|
||||
// Start HTTP server
|
||||
server := &http.Server{
|
||||
Addr: cfg.Server.Listen,
|
||||
Handler: mux,
|
||||
Handler: accessLog.Middleware(mux),
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 60 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
@@ -979,6 +986,7 @@ func main() {
|
||||
logger.Fatalf("[FATAL] HTTP server error: %v", err)
|
||||
}
|
||||
|
||||
accessLog.Close() // drains the buffered lines of the last requests
|
||||
logger.Println("[INFO] felhom-hub stopped")
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestServerHandlerIsAccessLogged (R-1140, hub v0.158.0): the http.Server's Handler is the access log's Middleware
|
||||
// around the mux — so EVERY route (API, operator UI, /bind/, /healthz) passes it. A log package nobody mounts is the
|
||||
// seam-built-never-wired class (REUSE.md trap). RED-PROOF: `Handler: mux,` → FAIL.
|
||||
func TestServerHandlerIsAccessLogged(t *testing.T) {
|
||||
f, err := parser.ParseFile(token.NewFileSet(), "main.go", nil, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var wrapped, servers int
|
||||
ast.Inspect(f, func(n ast.Node) bool {
|
||||
cl, ok := n.(*ast.CompositeLit)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
sel, ok := cl.Type.(*ast.SelectorExpr)
|
||||
if !ok || sel.Sel.Name != "Server" {
|
||||
return true
|
||||
}
|
||||
if x, ok := sel.X.(*ast.Ident); !ok || x.Name != "http" {
|
||||
return true
|
||||
}
|
||||
servers++
|
||||
for _, el := range cl.Elts {
|
||||
kv, ok := el.(*ast.KeyValueExpr)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if k, ok := kv.Key.(*ast.Ident); !ok || k.Name != "Handler" {
|
||||
continue
|
||||
}
|
||||
if call, ok := kv.Value.(*ast.CallExpr); ok {
|
||||
if s, ok := call.Fun.(*ast.SelectorExpr); ok && s.Sel.Name == "Middleware" && len(call.Args) == 1 {
|
||||
if a, ok := call.Args[0].(*ast.Ident); ok && a.Name == "mux" {
|
||||
wrapped++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
if servers != 1 || wrapped != 1 {
|
||||
t.Fatalf("http.Server literals: %d, with Handler: accessLog.Middleware(mux): %d — want 1 and 1", servers, wrapped)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user