Fix issue with too large DNS messages

This is an import of the fix for issue 10135 in the rancher fork of this
project ( rancher/rancher#10135 ).
This commit is contained in:
Douglas Mayle 2020-05-20 16:09:37 +02:00
parent 4a45706209
commit 785adeb6c1

View File

@ -33,6 +33,11 @@ import (
"sigs.k8s.io/external-dns/provider"
)
const (
// maximum size of a UDP transport message in DNS protocol
udpMaxMsgSize = 512
)
// rfc2136 provider type
type rfc2136Provider struct {
nameserver string
@ -309,6 +314,10 @@ func (r rfc2136Provider) SendMessage(msg *dns.Msg) error {
msg.SetTsig(r.tsigKeyName, r.tsigSecretAlg, 300, time.Now().Unix())
}
if msg.Len() > udpMaxMsgSize {
c.Net = "tcp"
}
resp, _, err := c.Exchange(msg, r.nameserver)
if err != nil {
log.Infof("error in dns.Client.Exchange: %s", err)