@@ -682,6 +682,12 @@ func (t *dnsgateway) fromInternalCache(tid, uid string, q *dns.Msg, typ iptype)
682682func (t * dnsgateway ) qp (t1 Transport , uid , network string , q * dns.Msg , innersummary * x.DNSSummary ) (ans * dns.Msg , err error ) {
683683 // For A/AAAA queries, check if xips has an answer for the qname.
684684 if ans , err := t .fromInternalCache (idstr (t1 ), uid , q , typreal ); err == nil {
685+ innersummary .ID = idstr (t1 )
686+ innersummary .Server = getaddrstr (t1 )
687+ innersummary .RData = xdns .GetInterestingRData (ans )
688+ innersummary .RCode = xdns .Rcode (ans )
689+ innersummary .RTtl = xdns .RTtl (ans )
690+ innersummary .Status = Complete
685691 innersummary .Cached = true
686692 return ans , nil
687693 }
@@ -745,6 +751,14 @@ func (t *dnsgateway) querySecondary(t2 Transport, uid, network string, msg *dns.
745751 if r , err = t .fromInternalCache (idstr (t2 ), uid , msg , typsecondary ); err != nil {
746752 // else: query secondary to get answer for q
747753 r , err = Req (t2 , network , msg , result .smm )
754+ } else {
755+ result .smm .ID = idstr (t2 )
756+ result .smm .Server = getaddrstr (t2 )
757+ result .smm .RData = xdns .GetInterestingRData (r )
758+ result .smm .RCode = xdns .Rcode (r )
759+ result .smm .RTtl = xdns .RTtl (r )
760+ result .smm .Status = Complete
761+ result .smm .Cached = true
748762 }
749763 }
750764
@@ -1945,6 +1959,13 @@ func idstr(t Transport) string {
19451959 return t .ID ().V ()
19461960}
19471961
1962+ func getaddrstr (t Transport ) string {
1963+ if t == nil {
1964+ return notransport
1965+ }
1966+ return t .GetAddr ().V ()
1967+ }
1968+
19481969func ipok (ip netip.Addr ) bool {
19491970 return ! ip .IsUnspecified () && ip .IsValid ()
19501971}
0 commit comments