| 24 | } |
| 25 | |
| 26 | func periodicClean(c *cache.Cache[[]dns.RR], stop <-chan struct{}) { |
| 27 | tick := time.NewTicker(8 * time.Hour) |
| 28 | defer tick.Stop() |
| 29 | for { |
| 30 | select { |
| 31 | case <-tick.C: |
| 32 | // we sign for 8 days, check if a signature in the cache reached 75% of that (i.e. 6), if found delete |
| 33 | // the signature |
| 34 | is75 := time.Now().UTC().Add(twoDays) |
| 35 | c.Walk(func(items map[uint64][]dns.RR, key uint64) bool { |
| 36 | for _, rr := range items[key] { |
| 37 | if !rr.(*dns.RRSIG).ValidityPeriod(is75) { |
| 38 | delete(items, key) |
| 39 | } |
| 40 | } |
| 41 | return true |
| 42 | }) |
| 43 | |
| 44 | case <-stop: |
| 45 | return |
| 46 | } |
| 47 | } |
| 48 | } |