mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-30 13:48:36 +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 {
|
if rec == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if rec.A != nil && rec.A.Expire.Before(now) {
|
a, aaaa := rec.A, rec.AAAA
|
||||||
rec.A = nil
|
if a != nil && a.Expire.Before(now) {
|
||||||
|
a = nil
|
||||||
}
|
}
|
||||||
if rec.AAAA != nil && rec.AAAA.Expire.Before(now) {
|
if aaaa != nil && aaaa.Expire.Before(now) {
|
||||||
rec.AAAA = nil
|
aaaa = nil
|
||||||
}
|
}
|
||||||
if rec.A == nil && rec.AAAA == nil {
|
if a == nil && aaaa == nil {
|
||||||
delete(c.ips, domain)
|
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