optimize(dns): use different ID for another lookup in ipversion prefer mode

This commit is contained in:
mzz2017 2023-04-07 23:13:10 +08:00
parent 38cc66d1d3
commit 066e856163
2 changed files with 4 additions and 0 deletions

View File

@ -17,10 +17,12 @@ import (
"github.com/daeuniverse/dae/component/outbound/dialer" "github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mohae/deepcopy" "github.com/mohae/deepcopy"
"github.com/mzz2017/softwind/netproxy" "github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/mzz2017/softwind/pool" "github.com/mzz2017/softwind/pool"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/net/dns/dnsmessage" "golang.org/x/net/dns/dnsmessage"
"io" "io"
"math"
"net" "net"
"net/netip" "net/netip"
"strings" "strings"
@ -369,6 +371,7 @@ func (c *DnsController) Handle_(dnsMessage *dnsmessage.Message, req *udpRequest)
// Try to make both A and AAAA lookups. // Try to make both A and AAAA lookups.
dnsMessage2 := deepcopy.Copy(dnsMessage).(*dnsmessage.Message) dnsMessage2 := deepcopy.Copy(dnsMessage).(*dnsmessage.Message)
dnsMessage2.ID = uint16(fastrand.Intn(math.MaxUint16))
var qtype2 dnsmessage.Type var qtype2 dnsmessage.Type
switch qtype { switch qtype {
case dnsmessage.TypeA: case dnsmessage.TypeA:

View File

@ -81,6 +81,7 @@ node {
dns { dns {
# For example, if ipversion_prefer is 4 and the domain name has both type A and type AAAA records, the dae will only respond to type A queries and response empty answer to type AAAA queries. # For example, if ipversion_prefer is 4 and the domain name has both type A and type AAAA records, the dae will only respond to type A queries and response empty answer to type AAAA queries.
#ipversion_prefer: 4 #ipversion_prefer: 4
upstream { upstream {
# Value can be scheme://host:port, where the scheme can be tcp/udp/tcp+udp. # Value can be scheme://host:port, where the scheme can be tcp/udp/tcp+udp.
# If host is a domain and has both IPv4 and IPv6 record, dae will automatically choose # If host is a domain and has both IPv4 and IPv6 record, dae will automatically choose