add caches the msg if it has anything in the questions section.
(msg *dns.Msg)
| 52 | |
| 53 | // add caches the msg if it has anything in the questions section. |
| 54 | func (rd *recursionDetector) add(msg *dns.Msg) { |
| 55 | now := time.Now() |
| 56 | |
| 57 | if len(msg.Question) == 0 { |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | key := msgToSignature(msg) |
| 62 | expire64 := uint64(now.Add(rd.ttl).UnixNano()) |
| 63 | expire := make([]byte, uint64sz) |
| 64 | binary.BigEndian.PutUint64(expire, expire64) |
| 65 | |
| 66 | rd.recentRequests.Set(key, expire) |
| 67 | } |
| 68 | |
| 69 | // clear clears the recent requests cache. |
| 70 | func (rd *recursionDetector) clear() { |