Wait a little bit more between UDP attempts

This commit is contained in:
Frank Denis 2020-03-26 10:37:56 +01:00
parent 1d090eb194
commit 9f65457b1c

View file

@ -197,24 +197,28 @@ func dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress strin
var err error var err error
options := 0 options := 0
for tries := 1; tries >= 0; tries-- { for tries := 2; tries >= 0; tries-- {
if tryFragmentsSupport { if tryFragmentsSupport {
queryCopy := query.Copy()
queryCopy.Id += uint16(options)
go func(query *dns.Msg, delay time.Duration) { go func(query *dns.Msg, delay time.Duration) {
time.Sleep(delay) time.Sleep(delay)
option := _dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr, 1500) option := _dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr, 1500)
option.fragmentsBlocked = false option.fragmentsBlocked = false
option.priority = 0 option.priority = 0
channel <- option channel <- option
}(query.Copy(), time.Duration(10*tries)*time.Millisecond) }(queryCopy, time.Duration(200*tries)*time.Millisecond)
options++ options++
} }
queryCopy := query.Copy()
queryCopy.Id += uint16(options)
go func(query *dns.Msg, delay time.Duration) { go func(query *dns.Msg, delay time.Duration) {
time.Sleep(delay) time.Sleep(delay)
option := _dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr, 480) option := _dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr, 480)
option.fragmentsBlocked = true option.fragmentsBlocked = true
option.priority = 1 option.priority = 1
channel <- option channel <- option
}(query.Copy(), time.Duration(15*tries)*time.Millisecond) }(queryCopy, time.Duration(250*tries)*time.Millisecond)
options++ options++
} }
var bestOption *dnsExchangeResponse var bestOption *dnsExchangeResponse
@ -254,6 +258,7 @@ func dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress strin
func _dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress string, relayUDPAddr *net.UDPAddr, relayTCPAddr *net.TCPAddr, paddedLen int) dnsExchangeResponse { func _dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress string, relayUDPAddr *net.UDPAddr, relayTCPAddr *net.TCPAddr, paddedLen int) dnsExchangeResponse {
var packet []byte var packet []byte
var rtt time.Duration var rtt time.Duration
if proto == "udp" { if proto == "udp" {
qNameLen, padding := len(query.Question[0].Name), 0 qNameLen, padding := len(query.Question[0].Name), 0
if qNameLen < paddedLen { if qNameLen < paddedLen {