Limit the number of required retries for local queries
This commit is contained in:
parent
20f48edc25
commit
d627a4bc58
|
@ -29,12 +29,13 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
CertMagic = [4]byte{0x44, 0x4e, 0x53, 0x43}
|
||||
ServerMagic = [8]byte{0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38}
|
||||
MinDNSPacketSize = 12 + 5
|
||||
MaxDNSPacketSize = 4096
|
||||
MaxDNSUDPPacketSize = 1252
|
||||
InitialMinQuestionSize = 512
|
||||
CertMagic = [4]byte{0x44, 0x4e, 0x53, 0x43}
|
||||
ServerMagic = [8]byte{0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38}
|
||||
MinDNSPacketSize = 12 + 5
|
||||
MaxDNSPacketSize = 4096
|
||||
MaxDNSUDPPacketSize = 4096
|
||||
MaxDNSUDPSafePacketSize = 1252
|
||||
InitialMinQuestionSize = 512
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -29,7 +29,8 @@ func (plugin *PluginGetSetPayloadSize) Eval(pluginsState *PluginsState, msg *dns
|
|||
edns0 := msg.IsEdns0()
|
||||
dnssec := false
|
||||
if edns0 != nil {
|
||||
pluginsState.originalMaxPayloadSize = Min(int(edns0.UDPSize())-ResponseOverhead, pluginsState.originalMaxPayloadSize)
|
||||
pluginsState.maxUnencryptedUDPSafePayloadSize = int(edns0.UDPSize())
|
||||
pluginsState.originalMaxPayloadSize = Max(pluginsState.maxUnencryptedUDPSafePayloadSize-ResponseOverhead, pluginsState.originalMaxPayloadSize)
|
||||
dnssec = edns0.Do()
|
||||
}
|
||||
var options *[]dns.EDNS0
|
||||
|
|
|
@ -60,25 +60,26 @@ var PluginsReturnCodeToString = map[PluginsReturnCode]string{
|
|||
}
|
||||
|
||||
type PluginsState struct {
|
||||
sessionData map[string]interface{}
|
||||
action PluginsAction
|
||||
originalMaxPayloadSize int
|
||||
maxPayloadSize int
|
||||
clientProto string
|
||||
clientAddr *net.Addr
|
||||
synthResponse *dns.Msg
|
||||
dnssec bool
|
||||
cacheSize int
|
||||
cacheNegMinTTL uint32
|
||||
cacheNegMaxTTL uint32
|
||||
cacheMinTTL uint32
|
||||
cacheMaxTTL uint32
|
||||
questionMsg *dns.Msg
|
||||
requestStart time.Time
|
||||
requestEnd time.Time
|
||||
cacheHit bool
|
||||
returnCode PluginsReturnCode
|
||||
serverName string
|
||||
sessionData map[string]interface{}
|
||||
action PluginsAction
|
||||
maxUnencryptedUDPSafePayloadSize int
|
||||
originalMaxPayloadSize int
|
||||
maxPayloadSize int
|
||||
clientProto string
|
||||
clientAddr *net.Addr
|
||||
synthResponse *dns.Msg
|
||||
dnssec bool
|
||||
cacheSize int
|
||||
cacheNegMinTTL uint32
|
||||
cacheNegMaxTTL uint32
|
||||
cacheMinTTL uint32
|
||||
cacheMaxTTL uint32
|
||||
questionMsg *dns.Msg
|
||||
requestStart time.Time
|
||||
requestEnd time.Time
|
||||
cacheHit bool
|
||||
returnCode PluginsReturnCode
|
||||
serverName string
|
||||
}
|
||||
|
||||
func InitPluginsGlobals(pluginsGlobals *PluginsGlobals, proxy *Proxy) error {
|
||||
|
@ -209,17 +210,18 @@ type Plugin interface {
|
|||
|
||||
func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, start time.Time) PluginsState {
|
||||
return PluginsState{
|
||||
action: PluginsActionForward,
|
||||
maxPayloadSize: MaxDNSUDPPacketSize - ResponseOverhead,
|
||||
clientProto: clientProto,
|
||||
clientAddr: clientAddr,
|
||||
cacheSize: proxy.cacheSize,
|
||||
cacheNegMinTTL: proxy.cacheNegMinTTL,
|
||||
cacheNegMaxTTL: proxy.cacheNegMaxTTL,
|
||||
cacheMinTTL: proxy.cacheMinTTL,
|
||||
cacheMaxTTL: proxy.cacheMaxTTL,
|
||||
questionMsg: nil,
|
||||
requestStart: start,
|
||||
action: PluginsActionForward,
|
||||
maxPayloadSize: MaxDNSUDPPacketSize - ResponseOverhead,
|
||||
clientProto: clientProto,
|
||||
clientAddr: clientAddr,
|
||||
cacheSize: proxy.cacheSize,
|
||||
cacheNegMinTTL: proxy.cacheNegMinTTL,
|
||||
cacheNegMaxTTL: proxy.cacheNegMaxTTL,
|
||||
cacheMinTTL: proxy.cacheMinTTL,
|
||||
cacheMaxTTL: proxy.cacheMaxTTL,
|
||||
questionMsg: nil,
|
||||
requestStart: start,
|
||||
maxUnencryptedUDPSafePayloadSize: MaxDNSUDPSafePacketSize,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
return
|
||||
}
|
||||
if clientProto == "udp" {
|
||||
if len(response) > MaxDNSUDPPacketSize {
|
||||
if len(response) > pluginsState.maxUnencryptedUDPSafePayloadSize {
|
||||
response, err = TruncatedResponse(response)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeParseError
|
||||
|
|
Loading…
Reference in New Issue