Revert "fix: proxy: Trigger query logging plugins using defer"
This reverts commit fc9509a8c8
.
This commit is contained in:
parent
14862c2fc7
commit
da3f30871f
|
@ -375,7 +375,6 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
return
|
||||
}
|
||||
pluginsState := NewPluginsState(proxy, clientProto, clientAddr, start)
|
||||
defer pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverName := "-"
|
||||
if serverInfo != nil {
|
||||
serverName = serverInfo.Name
|
||||
|
@ -391,11 +390,13 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
response, err = pluginsState.synthResponse.PackBuffer(response)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
return
|
||||
}
|
||||
}
|
||||
if pluginsState.action == PluginsActionDrop {
|
||||
pluginsState.returnCode = PluginsReturnCodeDrop
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -407,6 +408,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
sharedKey, encryptedQuery, clientNonce, err := proxy.Encrypt(serverInfo, query, serverProto)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
return
|
||||
}
|
||||
serverInfo.noticeBegin(proxy)
|
||||
|
@ -417,6 +419,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
sharedKey, encryptedQuery, clientNonce, err = proxy.Encrypt(serverInfo, query, serverProto)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
return
|
||||
}
|
||||
response, err = proxy.exchangeWithTCPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
|
||||
|
@ -430,6 +433,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
} else {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
}
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
}
|
||||
|
@ -441,12 +445,14 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
SetTransactionID(query, tid)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
}
|
||||
response, err = ioutil.ReadAll(io.LimitReader(resp.Body, int64(MaxDNSPacketSize)))
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
}
|
||||
|
@ -458,12 +464,14 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
}
|
||||
if len(response) < MinDNSPacketSize || len(response) > MaxDNSPacketSize {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
}
|
||||
response, err = pluginsState.ApplyResponsePlugins(&proxy.pluginsGlobals, response, ttl)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
serverInfo.noticeFailure(proxy)
|
||||
return
|
||||
}
|
||||
|
@ -476,6 +484,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
}
|
||||
if len(response) < MinDNSPacketSize || len(response) > MaxDNSPacketSize {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
if serverInfo != nil {
|
||||
serverInfo.noticeFailure(proxy)
|
||||
}
|
||||
|
@ -486,6 +495,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
response, err = TruncatedResponse(response)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -499,6 +509,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
response, err = PrefixWithSize(response)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
if serverInfo != nil {
|
||||
serverInfo.noticeFailure(proxy)
|
||||
}
|
||||
|
@ -506,6 +517,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
}
|
||||
clientPc.Write(response)
|
||||
}
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
}
|
||||
|
||||
func NewProxy() *Proxy {
|
||||
|
|
Loading…
Reference in New Issue