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