msgToKeyWithSubnet constructs the cache key from DO bit, type, class, subnet mask, client's IP address and question's name of m. ecsIP is expected to be masked already.
(m *dns.Msg, ecsIP net.IP, mask int)
| 563 | // mask, client's IP address and question's name of m. ecsIP is expected to be |
| 564 | // masked already. |
| 565 | func msgToKeyWithSubnet(m *dns.Msg, ecsIP net.IP, mask int) (key []byte) { |
| 566 | q := m.Question[0] |
| 567 | keyLen := keyIPIndex + len(q.Name) |
| 568 | masked := mask != 0 |
| 569 | if masked { |
| 570 | keyLen += len(ecsIP) |
| 571 | } |
| 572 | |
| 573 | // Initialize the slice. |
| 574 | key = make([]byte, keyLen) |
| 575 | |
| 576 | // Put DO. |
| 577 | opt := m.IsEdns0() |
| 578 | key[0] = mathutil.BoolToNumber[byte](opt != nil && opt.Do()) |
| 579 | |
| 580 | // Put Qtype. |
| 581 | binary.BigEndian.PutUint16(key[1:], q.Qtype) |
| 582 | |
| 583 | // Put Qclass. |
| 584 | binary.BigEndian.PutUint16(key[1+packedMsgLenSz:], q.Qclass) |
| 585 | |
| 586 | // Add mask. |
| 587 | key[keyMaskIndex] = uint8(mask) |
| 588 | k := keyIPIndex |
| 589 | if masked { |
| 590 | k += copy(key[keyIPIndex:], ecsIP) |
| 591 | } |
| 592 | |
| 593 | copy(key[k:], strings.ToLower(q.Name)) |
| 594 | |
| 595 | return key |
| 596 | } |
| 597 | |
| 598 | // isDNSSEC returns true if r is a DNSSEC RR. NSEC, NSEC3, DS, DNSKEY and |
| 599 | // RRSIG/SIG are DNSSEC records. |
no outgoing calls
searching dependent graphs…