bastion 0.60.0
ci / personal-data (push) Successful in 4s
ci / test (push) Successful in 3m36s
ci / fuzz (push) Successful in 3m35s

This commit is contained in:
Privatae
2026-11-02 00:10:58 +00:00
parent 4a5c310482
commit 4f8285ef18
100 changed files with 11537 additions and 840 deletions
+17
View File
@@ -205,6 +205,23 @@ func (s *uiTokenStore) valid(tok string) bool {
return ok && !uiNow().After(exp)
}
// mintCapped is mint, refused once max tokens are live, counted and minted
// under one lock so callers at the same instant cannot pass max together.
func (s *uiTokenStore) mintCapped(max int) (string, bool, error) {
tok, err := genSecret(32)
if err != nil {
return "", false, err
}
s.mu.Lock()
defer s.mu.Unlock()
s.sweepLocked()
if len(s.m) >= max {
return "", false, nil
}
s.m[tok] = uiNow().Add(s.ttl)
return tok, true, nil
}
func (s *uiTokenStore) drop(tok string) {
s.mu.Lock()
defer s.mu.Unlock()