differentiate between timeout and other error for dnscrypt servers
This commit is contained in:
parent
0058bc063e
commit
ac6fd3db39
|
@ -44,6 +44,7 @@ const (
|
|||
PluginsReturnCodeResponseError
|
||||
PluginsReturnCodeServerError
|
||||
PluginsReturnCodeCloak
|
||||
PluginsReturnCodeServerTimeout
|
||||
)
|
||||
|
||||
var PluginsReturnCodeToString = map[PluginsReturnCode]string{
|
||||
|
@ -57,6 +58,7 @@ var PluginsReturnCodeToString = map[PluginsReturnCode]string{
|
|||
PluginsReturnCodeResponseError: "RESPONSE_ERROR",
|
||||
PluginsReturnCodeServerError: "SERVER_ERROR",
|
||||
PluginsReturnCodeCloak: "CLOAK",
|
||||
PluginsReturnCodeServerTimeout: "SERVER_TIMEOUT",
|
||||
}
|
||||
|
||||
type PluginsState struct {
|
||||
|
|
|
@ -419,7 +419,11 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
response, err = proxy.exchangeWithTCPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
|
||||
}
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerTimeout
|
||||
} else {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
}
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue