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