Reencrypt on TCP retries

This commit is contained in:
Frank Denis 2019-10-20 02:04:32 +02:00
parent 661477bf09
commit fbe9f225dd
1 changed files with 6 additions and 1 deletions

View File

@ -412,7 +412,12 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
if serverProto == "udp" {
response, err = proxy.exchangeWithUDPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
if err == nil && len(response) >= MinDNSPacketSize && response[2]&0x02 == 0x02 {
dlog.Debug("Truncated response over UDP, retrying over TCP")
serverProto = "tcp"
sharedKey, encryptedQuery, clientNonce, err := proxy.Encrypt(serverInfo, query, serverProto)
if err != nil {
pluginsState.returnCode = PluginsReturnCodeParseError
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
}
response, err = proxy.exchangeWithTCPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
}
} else {