Skip to content

Commit c5b7627

Browse files
committed
Missing bits from #2986 for DNSCrypt
1 parent 99220ae commit c5b7627

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

dnscrypt-proxy/query_processing.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,20 @@ func processDNSCryptQuery(
8686

8787
// Check for stale response if there was an error
8888
if err != nil {
89+
serverInfo.noticeFailure(proxy)
8990
if stale, ok := pluginsState.sessionData["stale"]; ok {
9091
dlog.Debug("Serving stale response")
91-
serverInfo.noticeFailure(proxy)
92-
if staleResponse, err := (stale.(*dns.Msg)).Pack(); err == nil {
92+
if staleResponse, packErr := (stale.(*dns.Msg)).Pack(); packErr == nil {
9393
return staleResponse, nil
9494
}
9595
}
96-
}
97-
98-
// Handle error cases
99-
if err != nil {
96+
// If no stale response was served, return the original error
10097
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
10198
pluginsState.returnCode = PluginsReturnCodeServerTimeout
10299
} else {
103100
pluginsState.returnCode = PluginsReturnCodeNetworkError
104101
}
105102
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
106-
serverInfo.noticeFailure(proxy)
107103
return nil, err
108104
}
109105

0 commit comments

Comments
 (0)