From 4dd4cec38a599aec30f0b0e16777101f3802d974 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 | 1 - template/render_route.go | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/template/render_dns.go b/template/render_dns.go index 555c277..41f5e5b 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{ 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,