fix: stabilize console scrolling and protect administrator login

This commit is contained in:
2026-09-30 00:09:01 +08:00
parent 9a15406f76
commit f56f233704
32 changed files with 1308 additions and 86 deletions

View File

@@ -93,7 +93,29 @@ func run() error {
txStats := mysql.ReadTransactionStats()
metrics.RecordTransactionStats(observability.TransactionStats{Retries: txStats.Retries, Exhausted: txStats.Exhausted})
}
consoleAuth := mysql.NewConsoleAuthStore(db)
consoleAuth := mysql.NewConsoleAuthStore(db, cfg.ConsoleLogin)
// 登录安全记录独立保留,每分钟有界清理,关闭时等待清理器退出。
loginCleanupCtx, stopLoginCleanup := context.WithCancel(root)
loginCleanupDone := make(chan struct{})
go func() {
defer close(loginCleanupDone)
ticker := time.NewTicker(time.Minute)
defer ticker.Stop()
for {
select {
case <-loginCleanupCtx.Done():
return
case <-ticker.C:
call, cancel := context.WithTimeout(loginCleanupCtx, 5*time.Second)
err := consoleAuth.CleanupLoginSecurity(call)
cancel()
if err != nil && loginCleanupCtx.Err() == nil {
slog.Error("console login security cleanup failed")
}
}
}
}()
defer func() { stopLoginCleanup(); <-loginCleanupDone }()
retentionStore := mysql.NewRetentionPolicyStore(db, cfg.RetentionDefaults)
server := httpserver.NewWithConsoleAuth(cfg.HTTPAddr, readiness.Check, consoleAuth, service.New(mysql.NewTaskStore(db)))
httpserver.RegisterApplicationResources(server, resources.New(mysql.NewTaskStore(db)))