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