dns: added new config dnsnoaaaa to filter AAAA response, default to false

This commit is contained in:
nadoo committed 2022-01-20 21:59:40 +08:00
1 parent 27de61a59d
commit 2754fdeb60
4 files changed
+9 -3

No files matched your search

+5
View File
@@ -27,6 +27,7 @@ type Config struct {
AlwaysTCP bool
CacheSize int
CacheLog bool
NoAAAA bool
}
// Client is a dns client struct.
@@ -65,6 +66,10 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string, preferTCP bool) ([
return nil, err
}
if c.config.NoAAAA && req.Question.QTYPE == QTypeAAAA {
return nil, errors.New("AAAA query is disabled, qname: " + req.Question.QNAME)
}
if req.Question.QTYPE == QTypeA || req.Question.QTYPE == QTypeAAAA {
if v, expired := c.cache.Get(qKey(req.Question)); len(v) > 2 {
v = valCopy(v)