mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-04 21:57:44 +03:00
Forwarding plugin: retry over TCP if a truncated response is received
dns.Exchange() doesn't do it automatically. Fixes #1178
This commit is contained in:
parent
170c690996
commit
63d28fc9b2
1 changed files with 9 additions and 1 deletions
|
@ -89,10 +89,18 @@ func (plugin *PluginForward) Eval(pluginsState *PluginsState, msg *dns.Msg) erro
|
|||
}
|
||||
server := servers[rand.Intn(len(servers))]
|
||||
pluginsState.serverName = server
|
||||
respMsg, err := dns.Exchange(msg, server)
|
||||
client := dns.Client{Net: "udp"}
|
||||
respMsg, _, err := client.Exchange(msg, server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if respMsg.Truncated {
|
||||
client.Net = "tcp"
|
||||
respMsg, _, err = client.Exchange(msg, server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if edns0 := respMsg.IsEdns0(); edns0 == nil || !edns0.Do() {
|
||||
respMsg.AuthenticatedData = false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue