From c5eab36093ad21301ad7a3f1434bf6dc2db907a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 29 Nov 2024 10:38:26 +0800 Subject: [PATCH] Fix cn route --- template/render_dns.go | 6 +++--- template/render_route.go | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/template/render_dns.go b/template/render_dns.go index 555c277..0c74e10 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -171,7 +171,6 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error options.DNS.Rules = append(options.DNS.Rules, t.PreDNSRules...) if len(t.CustomDNSRules) == 0 { if !t.DisableTrafficBypass { - options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{ Type: C.RuleTypeDefault, DefaultOptions: option.DefaultDNSRule{ @@ -210,7 +209,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error Type: C.RuleTypeDefault, DefaultOptions: option.DefaultDNSRule{ RawDefaultDNSRule: option.RawDefaultDNSRule{ - RuleSet: []string{"geosite-geolocation-!cn"}, + RuleSet: []string{"geoip-cn"}, }, }, }, @@ -218,7 +217,8 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error Type: C.RuleTypeDefault, DefaultOptions: option.DefaultDNSRule{ RawDefaultDNSRule: option.RawDefaultDNSRule{ - RuleSet: []string{"geoip-cn"}, + RuleSet: []string{"geosite-geolocation-!cn"}, + Invert: true, }, }, }, diff --git a/template/render_route.go b/template/render_route.go index 6343e5d..692b901 100644 --- a/template/render_route.go +++ b/template/render_route.go @@ -172,7 +172,39 @@ func (t *Template) renderRoute(metadata M.Metadata, options *option.Options) err Type: C.RuleTypeDefault, DefaultOptions: option.DefaultRule{ RawDefaultRule: option.RawDefaultRule{ - RuleSet: []string{"geoip-cn", "geosite-geolocation-cn"}, + RuleSet: []string{"geosite-geolocation-cn"}, + }, + RuleAction: option.RuleAction{ + Action: C.RuleActionTypeRoute, + RouteOptions: option.RouteActionOptions{ + Outbound: directTag, + }, + }, + }, + }, option.Rule{ + Type: C.RuleTypeLogical, + LogicalOptions: option.LogicalRule{ + RawLogicalRule: option.RawLogicalRule{ + Mode: C.LogicalTypeAnd, + Rules: []option.Rule{ + { + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultRule{ + RawDefaultRule: option.RawDefaultRule{ + RuleSet: []string{"geoip-cn"}, + }, + }, + }, + { + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultRule{ + RawDefaultRule: option.RawDefaultRule{ + RuleSet: []string{"geosite-geolocation-!cn"}, + Invert: true, + }, + }, + }, + }, }, RuleAction: option.RuleAction{ Action: C.RuleActionTypeRoute,