@@ -83,24 +83,33 @@ func (t *Template) renderDNS(ctx context.Context, metadata M.Metadata, options *
8383 )
8484 if t .DisableTrafficBypass {
8585 localDNSOptions = option.DNSServerOptions {
86- Tag : DNSLocalTag ,
86+ Tag : DNSLocalTag ,
87+ Type : C .DNSTypeLegacy ,
8788 Options : & option.LegacyDNSServerOptions {
8889 Address : "local" ,
8990 Strategy : domainStrategyLocal ,
9091 },
9192 }
9293 } else {
9394 localDNSOptions = option.DNSServerOptions {
94- Tag : DNSLocalTag ,
95+ Tag : DNSLocalTag ,
96+ Type : C .DNSTypeLegacy ,
9597 Options : & option.LegacyDNSServerOptions {
9698 Address : dnsLocal ,
9799 Detour : directTag ,
98100 Strategy : domainStrategyLocal ,
99101 },
100102 }
101- if dnsLocalUrl , err := url .Parse (dnsLocal ); err == nil && BM .IsDomainName (dnsLocalUrl .Hostname ()) {
102- defaultDNSOptions .Options .(* option.LegacyDNSServerOptions ).AddressResolver = DNSLocalSetupTag
103+ if BM .IsDomainName (dnsLocal ) {
103104 localDNSIsDomain = true
105+ } else if dnsLocalUrl , err := url .Parse (dnsLocal ); err == nil {
106+ switch dnsLocalUrl .Scheme {
107+ case "tcp" , "udp" , "tls" , "https" , "quic" , "h3" :
108+ localDNSIsDomain = true
109+ }
110+ }
111+ if localDNSIsDomain {
112+ defaultDNSOptions .Options .(* option.LegacyDNSServerOptions ).AddressResolver = DNSLocalSetupTag
104113 }
105114 }
106115 if newDNSServers {
@@ -111,12 +120,14 @@ func (t *Template) renderDNS(ctx context.Context, metadata M.Metadata, options *
111120 if localDNSIsDomain {
112121 if newDNSServers {
113122 options .DNS .Servers = append (options .DNS .Servers , option.DNSServerOptions {
123+ Type : C .DNSTypeLocal ,
114124 Tag : DNSLocalSetupTag ,
115125 Options : & option.LocalDNSServerOptions {},
116126 })
117127 } else {
118128 options .DNS .Servers = append (options .DNS .Servers , option.DNSServerOptions {
119- Tag : DNSLocalSetupTag ,
129+ Type : C .DNSTypeLegacy ,
130+ Tag : DNSLocalSetupTag ,
120131 Options : & option.LegacyDNSServerOptions {
121132 Address : "local" ,
122133 Strategy : domainStrategyLocal ,
0 commit comments