Check EDNS0 bufsize in Exchange()

In client.Exchange we *did* check for this size, to the same in the
function Exchange(). This bug surfaced in issue #184, this sort of
fixes it.

Closes #184.
This commit is contained in:
Miek Gieben 2015-02-24 18:16:58 +00:00
parent 841e5ac162
commit 6427527bba
1 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,13 @@ func Exchange(m *Msg, a string) (r *Msg, err error) {
defer co.Close()
co.SetReadDeadline(time.Now().Add(dnsTimeout))
co.SetWriteDeadline(time.Now().Add(dnsTimeout))
opt := m.IsEdns0()
// If EDNS0 is used use that for size.
if opt != nil && opt.UDPSize() >= MinMsgSize {
co.UDPSize = opt.UDPSize()
}
if err = co.WriteMsg(m); err != nil {
return nil, err
}