MCPcopy
hub / github.com/AdguardTeam/dnsproxy / msgToKey

Function msgToKey

proxy/cache.go:537–552  ·  view source on GitHub ↗

msgToKey constructs the cache key from type, class and question's name of m.

(m *dns.Msg)

Source from the content-addressed store, hash-verified

535
536// msgToKey constructs the cache key from type, class and question's name of m.
537func msgToKey(m *dns.Msg) (b []byte) {
538 q := m.Question[0]
539 name := q.Name
540 b = make([]byte, 1+packedMsgLenSz+packedMsgLenSz+len(name))
541
542 // Put the DO flag.
543 opt := m.IsEdns0()
544 b[0] = mathutil.BoolToNumber[byte](opt != nil && opt.Do())
545
546 // Put QTYPE, QCLASS, and QNAME.
547 binary.BigEndian.PutUint16(b[1:], q.Qtype)
548 binary.BigEndian.PutUint16(b[1+packedMsgLenSz:], q.Qclass)
549 copy(b[1+2*packedMsgLenSz:], strings.ToLower(name))
550
551 return b
552}
553
554const (
555 // keyMaskIndex is the index of the byte with mask ones value.

Callers 11

getMethod · 0.85
setMethod · 0.85
queueMethod · 0.85
doneMethod · 0.85
TestCache_expiredFunction · 0.85
TestCacheCNAMEFunction · 0.85
TestCacheExpirationFunction · 0.85
setAndGetCacheFunction · 0.85

Calls

no outgoing calls

Tested by 7

TestCache_expiredFunction · 0.68
TestCacheCNAMEFunction · 0.68
TestCacheExpirationFunction · 0.68
setAndGetCacheFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…