Skip to content

Commit 6740250

Browse files
committed
dnsx/cacher: preserve TIDs as set by client in summary
1 parent 2bcfa1d commit 6740250

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

intra/dnsx/cacher.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ func (t *ctransport) fetch(network string, q *dns.Msg, summary *x.DNSSummary, cb
459459
fillSummary(cachedsummary, summary)
460460
summary.Latency = 0 // don't use cached latency
461461
summary.Cached = true
462-
summary.ID = t.ID().V()
463462
return r, nil
464463
} // else: fallthrough to sendRequest
465464
} else {
@@ -548,44 +547,44 @@ func fillSummary(s *x.DNSSummary, out *x.DNSSummary) {
548547
if out == nil || s == out {
549548
return
550549
}
551-
if len(s.Type) != 0 {
550+
551+
// pefer out
552+
553+
if len(out.Type) != 0 {
552554
out.Type = s.Type
553555
}
554-
if len(s.ID) != 0 {
556+
if len(out.ID) <= 0 {
555557
out.ID = s.ID
558+
out.Server = s.Server
559+
out.PID = s.PID
560+
out.RPID = s.RPID
556561
}
557-
558-
if s.Latency != 0 {
562+
if out.Latency <= 0 {
559563
out.Latency = s.Latency
560564
}
561-
562565
if len(out.UID) <= 0 {
563566
out.UID = s.UID
564567
}
565-
566-
// query portions are only filled in if they are empty
567568
if len(out.QName) == 0 {
569+
// query portions are only filled in if they are empty
568570
out.QName = s.QName
569571
}
570-
// dns.TypeNone = 0
571-
if out.QType == 0 {
572+
if out.QType == 0 { // dns.TypeNone = 0
572573
out.QType = s.QType
573574
}
574-
// fill in region if empty
575-
if len(out.Region) == 0 {
575+
if len(out.Region) == 0 { // fill in region if empty
576576
out.Region = s.Region
577577
}
578578

579+
// prefer s
580+
579581
if len(s.RData) != 0 {
580582
out.RData = s.RData
581583
}
582584

583585
out.Cached = s.Cached
584586
out.RCode = s.RCode
585587
out.RTtl = s.RTtl
586-
out.Server = s.Server
587-
out.PID = s.PID
588-
out.RPID = s.RPID
589588
out.Status = s.Status
590589
out.Blocklists = s.Blocklists
591590
out.Msg = s.Msg

0 commit comments

Comments
 (0)