Limit the number of answers we provide to users.
This commit is contained in:
1 parent
0cb6a6269d
commit
cfcc08a914
6 files changed
+70
-11
No files matched your search
+9
-1
@@ -89,7 +89,6 @@ func getMaxReplyLen(r *dns.Msg, proto dnsProtocol) int {
|
||||
return maxLen
|
||||
}
|
||||
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
@@ -105,3 +104,12 @@ func shuffleAnswers(answers []dns.RR) []dns.RR {
|
||||
|
||||
return answers
|
||||
}
|
||||
|
||||
// only take the first `num` answers
|
||||
func pruneAnswers(answers []dns.RR, num int) []dns.RR {
|
||||
if num > 0 && len(answers) > num {
|
||||
// TODO: we should have some prefer locally-introduced answers, etc...
|
||||
return answers[:num]
|
||||
}
|
||||
return answers
|
||||
}
|
||||
Reference in new issue
Block a user