check checks if the passed req was already sent by the server.
(msg *dns.Msg)
| 35 | |
| 36 | // check checks if the passed req was already sent by the server. |
| 37 | func (rd *recursionDetector) check(msg *dns.Msg) (ok bool) { |
| 38 | if len(msg.Question) == 0 { |
| 39 | return false |
| 40 | } |
| 41 | |
| 42 | key := msgToSignature(msg) |
| 43 | expireData := rd.recentRequests.Get(key) |
| 44 | if expireData == nil { |
| 45 | return false |
| 46 | } |
| 47 | |
| 48 | expire := time.Unix(0, int64(binary.BigEndian.Uint64(expireData))) |
| 49 | |
| 50 | return time.Now().Before(expire) |
| 51 | } |
| 52 | |
| 53 | // add caches the msg if it has anything in the questions section. |
| 54 | func (rd *recursionDetector) add(msg *dns.Msg) { |