mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-20 16:49:12 +00:00
DNS: Avoid mutating cache records during cleanup (#7442)
https://github.com/XTLS/Xray-core/pull/7442#pullrequestreview-5958707394 --------- Co-authored-by: Meow <197331664+Meo597@users.noreply.github.com>
This commit is contained in:
@@ -124,14 +124,17 @@ func (c *CacheController) writeAndShrink(expiredKeys []string) {
|
||||
if rec == nil {
|
||||
continue
|
||||
}
|
||||
if rec.A != nil && rec.A.Expire.Before(now) {
|
||||
rec.A = nil
|
||||
a, aaaa := rec.A, rec.AAAA
|
||||
if a != nil && a.Expire.Before(now) {
|
||||
a = nil
|
||||
}
|
||||
if rec.AAAA != nil && rec.AAAA.Expire.Before(now) {
|
||||
rec.AAAA = nil
|
||||
if aaaa != nil && aaaa.Expire.Before(now) {
|
||||
aaaa = nil
|
||||
}
|
||||
if rec.A == nil && rec.AAAA == nil {
|
||||
if a == nil && aaaa == nil {
|
||||
delete(c.ips, domain)
|
||||
} else if a != rec.A || aaaa != rec.AAAA {
|
||||
c.ips[domain] = &record{A: a, AAAA: aaaa}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user