@@ -86,6 +86,7 @@ func BuildConfig(opt HiddifyOptions, input option.Options) (*option.Options, err
8686 setNTP (& options )
8787 setRoutingOptions (& options , & opt )
8888 err := setOutbounds (& options , & input , & opt )
89+
8990 if err != nil {
9091 return nil , err
9192 }
@@ -154,7 +155,7 @@ func setOutbounds(options *option.Options, input *option.Options, opt *HiddifyOp
154155 if contains (PredefinedOutboundTags , out .Tag ) {
155156 continue
156157 }
157- outbound , err := patchOutbound (out , * opt , options .DNS . StaticIPs )
158+ outbound , err := patchOutbound (out , * opt , options .DNS )
158159 if err != nil {
159160 return err
160161 }
@@ -434,37 +435,19 @@ func setDns(options *option.Options, opt *HiddifyOptions) {
434435 },
435436 },
436437 }
437- domains := map [string ][]string {
438- "time.apple.com" : {"time.g.aaplimg.com" , "time.apple.com" },
439- "ipinfo.io" : {"ipinfo.io" },
440- "dns.cloudflare.com" : {"www.speedtest.net" , "cloudflare.com" },
441- "ipwho.is" : {"ipwho.is" },
442- "api.my-ip.io" : {"api.my-ip.io" },
443- "myip.expert" : {"myip.expert" },
444- "ip-api.com" : {"ip-api.com" },
445- }
446- var wg sync.WaitGroup
447- var mu sync.Mutex
448- for key , domainList := range domains {
449- wg .Add (1 )
450- go func (k string , dList []string ) {
451- defer wg .Done ()
452- ips := getIPs (dList ... )
453- if len (ips ) > 0 {
454- mu .Lock ()
455- options .DNS .StaticIPs [k ] = ips
456- mu .Unlock ()
457- }
458- }(key , domainList )
459- }
460438
461- wg .Wait ()
462- if dnsstr := options .DNS .StaticIPs ["dns.cloudflare.com" ]; dnsstr != nil {
463- options .DNS .StaticIPs ["api.ip.sb" ] = dnsstr
464- options .DNS .StaticIPs ["ipapi.co" ] = dnsstr
465- options .DNS .StaticIPs ["reallyfreegeoip.org" ] = dnsstr
466- options .DNS .StaticIPs ["freeipapi.com" ] = dnsstr
467- }
439+ options .DNS .StaticIPs ["time.apple.com" ] = []string {"time.g.aaplimg.com" , "time.apple.com" }
440+ options .DNS .StaticIPs ["ipinfo.io" ] = []string {"ipinfo.io" }
441+ options .DNS .StaticIPs ["dns.cloudflare.com" ] = []string {"www.speedtest.net" , "cloudflare.com" }
442+ options .DNS .StaticIPs ["ipwho.is" ] = []string {"ipwho.is" }
443+ options .DNS .StaticIPs ["api.my-ip.io" ] = []string {"api.my-ip.io" }
444+ options .DNS .StaticIPs ["myip.expert" ] = []string {"myip.expert" }
445+ options .DNS .StaticIPs ["ip-api.com" ] = []string {"ip-api.com" }
446+ options .DNS .StaticIPs ["freeipapi.com" ] = []string {"www.speedtest.net" , "cloudflare.com" }
447+ options .DNS .StaticIPs ["reallyfreegeoip.org" ] = []string {"www.speedtest.net" , "cloudflare.com" }
448+ options .DNS .StaticIPs ["ipapi.co" ] = []string {"www.speedtest.net" , "cloudflare.com" }
449+ options .DNS .StaticIPs ["api.ip.sb" ] = []string {"www.speedtest.net" , "cloudflare.com" }
450+
468451}
469452
470453func addForceDirect (options * option.Options , opt * HiddifyOptions ) {
@@ -491,43 +474,47 @@ func addForceDirect(options *option.Options, opt *HiddifyOptions) {
491474 }
492475 }
493476 }
477+
494478 if len (dnsMap ) > 0 {
495479 unique_dns_detours := make (map [string ]bool )
496480 for _ , detour := range dnsMap {
497481 unique_dns_detours [detour ] = true
498482 }
499483
500484 for detour := range unique_dns_detours {
501- if detour == OutboundDirectTag {
502- detour = "direct"
503- } else {
485+ dns_detour := "dns-direct"
486+ if detour != OutboundDirectTag {
487+ dns_detour = "dns-" + detour
504488 options .DNS .Servers = append (options .DNS .Servers , option.DNSServerOptions {
505- Tag : "dns-" + detour ,
489+ Tag : dns_detour ,
506490 Address : opt .RemoteDnsAddress ,
507491 AddressResolver : DNSDirectTag ,
508492 Strategy : opt .RemoteDnsDomainStrategy ,
509493 Detour : detour ,
510494 })
511495 }
496+
512497 domains := []string {}
513498 for domain , d := range dnsMap {
514499 if d == detour {
515500 domains = append (domains , domain )
516501 }
517502 }
503+
518504 if len (domains ) == 0 {
519505 continue
520506 }
521507 options .DNS .Rules = append (options .DNS .Rules , option.DNSRule {
522508 Type : C .RuleTypeDefault ,
523509 DefaultOptions : option.DefaultDNSRule {
524- Server : "dns-" + detour ,
510+ Server : dns_detour ,
525511 Domain : domains ,
526512 },
527513 })
528514 }
529515
530516 }
517+
531518}
532519
533520func setFakeDns (options * option.Options , opt * HiddifyOptions ) {
@@ -836,6 +823,16 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) {
836823 },
837824 })
838825 }
826+ if opt .RouteOptions .BlockQuic {
827+ routeRules = append (routeRules , option.Rule {
828+ Type : C .RuleTypeDefault ,
829+ DefaultOptions : option.DefaultRule {
830+ Port : []uint16 {443 },
831+ Network : []string {"udp" },
832+ Outbound : OutboundBlockTag ,
833+ },
834+ })
835+ }
839836 options .Route = & option.RouteOptions {
840837 Rules : routeRules ,
841838 Final : OutboundMainProxyTag ,
@@ -862,14 +859,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) {
862859 }
863860 }
864861 }
865- routeRules = append (routeRules , option.Rule {
866- Type : C .RuleTypeDefault ,
867- DefaultOptions : option.DefaultRule {
868- Port : []uint16 {443 },
869- Network : []string {"udp" },
870- Outbound : OutboundBlockTag ,
871- },
872- })
862+
873863}
874864
875865func patchHiddifyWarpFromConfig (out option.Outbound , opt HiddifyOptions ) option.Outbound {
0 commit comments