Stop rotation goroutine on config unload

This commit is contained in:
Matthew Holt 2025-11-24 15:54:05 -07:00
parent 57d6671ac6
commit 04e70bbaa0
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -423,13 +423,18 @@ func (t *TLS) Start() error {
// keep ECH keys rotated
go func() {
for range time.Tick(1 * time.Hour) {
// ensure old keys are rotated out
t.EncryptedClientHello.configsMu.Lock()
err = t.EncryptedClientHello.rotateECHKeys(t.ctx, echLogger, false)
t.EncryptedClientHello.configsMu.Unlock()
if err != nil {
echLogger.Error("rotating ECH configs failed", zap.Error(err))
for {
select {
case <-time.After(1 * time.Hour):
// ensure old keys are rotated out
t.EncryptedClientHello.configsMu.Lock()
err = t.EncryptedClientHello.rotateECHKeys(t.ctx, echLogger, false)
t.EncryptedClientHello.configsMu.Unlock()
if err != nil {
echLogger.Error("rotating ECH configs failed", zap.Error(err))
}
case <-t.ctx.Done():
return
}
}
}()