From 066e856163413f92191106574f70f37cca56e8a3 Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Fri, 7 Apr 2023 23:13:10 +0800 Subject: [PATCH] optimize(dns): use different ID for another lookup in ipversion prefer mode --- control/dns_control.go | 3 +++ example.dae | 1 + 2 files changed, 4 insertions(+) diff --git a/control/dns_control.go b/control/dns_control.go index d4f7b71..92bd1b4 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -17,10 +17,12 @@ import ( "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/mohae/deepcopy" "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/pkg/fastrand" "github.com/mzz2017/softwind/pool" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" "io" + "math" "net" "net/netip" "strings" @@ -369,6 +371,7 @@ func (c *DnsController) Handle_(dnsMessage *dnsmessage.Message, req *udpRequest) // Try to make both A and AAAA lookups. dnsMessage2 := deepcopy.Copy(dnsMessage).(*dnsmessage.Message) + dnsMessage2.ID = uint16(fastrand.Intn(math.MaxUint16)) var qtype2 dnsmessage.Type switch qtype { case dnsmessage.TypeA: diff --git a/example.dae b/example.dae index 0929a1a..df1baa2 100644 --- a/example.dae +++ b/example.dae @@ -81,6 +81,7 @@ node { 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. #ipversion_prefer: 4 + upstream { # 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