Support for larger UDP DNS responses #30

As [RFC6891](https://tools.ietf.org/html/rfc6891) define, Extension Mechanisms for DNS(EDNS(0)) can make UDP DNS response packets reach max 65535 bytes and breakthrough the early [RFC1035](‘https://tools.ietf.org/html/rfc1035’) 512 limitation.
This commit is contained in:
kenshinx 2017-02-15 01:08:08 +08:00
parent 7d1f6af220
commit 4d3d475c27
3 changed files with 7 additions and 0 deletions

View File

@ -18,6 +18,8 @@ timeout = 5 # 5 seconds
# Match the PR15, https://github.com/kenshinx/godns/pull/15 # Match the PR15, https://github.com/kenshinx/godns/pull/15
interval = 200 # 200 milliseconds interval = 200 # 200 milliseconds
setedns0 = false #Support for larger UDP DNS responses
[redis] [redis]
host = "127.0.0.1" host = "127.0.0.1"
port = 6379 port = 6379

View File

@ -34,6 +34,10 @@ func (r *Resolver) Lookup(net string, req *dns.Msg) (message *dns.Msg, err error
WriteTimeout: r.Timeout(), WriteTimeout: r.Timeout(),
} }
if net == "udp" && settings.ResolvConfig.SetEDNS0 {
req = req.SetEdns0(65535, true)
}
qname := req.Question[0].Name qname := req.Question[0].Name
res := make(chan *dns.Msg, 1) res := make(chan *dns.Msg, 1)

View File

@ -37,6 +37,7 @@ type ResolvSettings struct {
ResolvFile string `toml:"resolv-file"` ResolvFile string `toml:"resolv-file"`
Timeout int Timeout int
Interval int Interval int
SetEDNS0 bool
} }
type DNSServerSettings struct { type DNSServerSettings struct {