msgToKey constructs the cache key from type, class and question's name of m.
(m *dns.Msg)
| 535 | |
| 536 | // msgToKey constructs the cache key from type, class and question's name of m. |
| 537 | func 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 | |
| 554 | const ( |
| 555 | // keyMaskIndex is the index of the byte with mask ones value. |
no outgoing calls
searching dependent graphs…