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

Function msgToSignature

proxy/recursiondetector.go:86–97  ·  view source on GitHub ↗

msgToSignature converts msg into it's signature represented in bytes.

(msg *dns.Msg)

Source from the content-addressed store, hash-verified

84
85// msgToSignature converts msg into it's signature represented in bytes.
86func msgToSignature(msg *dns.Msg) (sig []byte) {
87 sig = make([]byte, uint16sz*2+netutil.MaxDomainNameLen)
88 // The binary.BigEndian byte order is used everywhere except when the real
89 // machine's endianness is needed.
90 byteOrder := binary.BigEndian
91 byteOrder.PutUint16(sig[0:], msg.Id)
92 q := msg.Question[0]
93 byteOrder.PutUint16(sig[uint16sz:], q.Qtype)
94 copy(sig[2*uint16sz:], []byte(q.Name))
95
96 return sig
97}

Callers 4

checkMethod · 0.85
addMethod · 0.85
BenchmarkMsgToSignatureFunction · 0.85

Calls

no outgoing calls

Tested by 2

BenchmarkMsgToSignatureFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…