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)
| 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).) |
| 285 | func (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. |