From 108b7f84465dcf595a02062a2f39fc7089a78749 Mon Sep 17 00:00:00 2001 From: Vladimir Bauer Date: Thu, 17 Oct 2019 20:29:08 +0500 Subject: [PATCH] fix panic if dns.RR is not a *dns.TXT --- dnscrypt-proxy/dnscrypt_certs.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dnscrypt-proxy/dnscrypt_certs.go b/dnscrypt-proxy/dnscrypt_certs.go index d3a115dc..dd79a120 100644 --- a/dnscrypt-proxy/dnscrypt_certs.go +++ b/dnscrypt-proxy/dnscrypt_certs.go @@ -43,7 +43,14 @@ func FetchCurrentDNSCryptCert(proxy *Proxy, serverName *string, proto string, pk highestSerial := uint32(0) var certCountStr string for _, answerRr := range in.Answer { - binCert, err := packTxtString(strings.Join(answerRr.(*dns.TXT).Txt, "")) + var txt string + if t, ok := answerRr.(*dns.TXT); !ok { + dlog.Warnf("[%v] Certificate not found", providerName) + continue + } else { + txt = strings.Join(t.Txt, "") + } + binCert, err := packTxtString(txt) if err != nil { dlog.Warnf("[%v] Unable to unpack the certificate", providerName) continue