MCPcopy
hub / github.com/caddyserver/caddy / rotationNeeded

Method rotationNeeded

modules/caddytls/ech.go:285–296  ·  view source on GitHub ↗

rotationNeeded returns true if any ECH key needs to be replaced, or deleted. It must be called inside a read or write lock of ech.configsMu (probably a write lock, so that the rotation can occur correctly in the same lock).)

(rotationInterval, deleteAfter time.Duration)

Source from the content-addressed store, hash-verified

283// It must be called inside a read or write lock of ech.configsMu (probably a
284// write lock, so that the rotation can occur correctly in the same lock).)
285func (ech *ECH) rotationNeeded(rotationInterval, deleteAfter time.Duration) bool {
286 for publicName := range ech.configs {
287 for i := 0; i < len(ech.configs[publicName]); i++ {
288 cfg := ech.configs[publicName][i]
289 if (time.Since(cfg.meta.Created) >= rotationInterval && cfg.meta.Replaced.IsZero()) ||
290 (time.Since(cfg.meta.Created) >= deleteAfter && !cfg.meta.Replaced.IsZero()) {
291 return true
292 }
293 }
294 }
295 return false
296}
297
298// updateKeyList updates the list of ECH keys the std lib uses to serve ECH.
299// It must be called inside a write lock on ech.configsMu.

Callers 1

rotateECHKeysMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected