From 17101f7d11d7ca95dafb77d7fbdd0b10080d9081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 23 Jan 2024 11:05:37 +0800 Subject: [PATCH] Fix geosite usage --- template/render_dns.go | 46 ++++++------------------------- template/render_geo_resources.go | 13 ++------- template/render_route.go | 47 ++++++-------------------------- 3 files changed, 18 insertions(+), 88 deletions(-) diff --git a/template/render_dns.go b/template/render_dns.go index c4b8f0c..8f36564 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -114,48 +114,18 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error if !t.DisableTrafficBypass { if t.DisableRuleSet || (metadata.Version != nil && metadata.Version.LessThan(semver.ParseVersion("1.8.0-alpha.10"))) { options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{ - Type: C.RuleTypeLogical, - LogicalOptions: option.LogicalDNSRule{ - Mode: C.LogicalTypeAnd, - Rules: []option.DNSRule{ - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultDNSRule{ - Geosite: []string{"geolocation-!cn"}, - Invert: true, - }, - }, - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultDNSRule{ - Geosite: []string{"cn"}, - }, - }, - }, - Server: DNSLocalTag, + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultDNSRule{ + Geosite: []string{"geolocation-cn"}, + Server: DNSLocalTag, }, }) } else { options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{ - Type: C.RuleTypeLogical, - LogicalOptions: option.LogicalDNSRule{ - Mode: C.LogicalTypeAnd, - Rules: []option.DNSRule{ - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultDNSRule{ - RuleSet: []string{"geosite-geolocation-!cn"}, - Invert: true, - }, - }, - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultDNSRule{ - RuleSet: []string{"geosite-cn"}, - }, - }, - }, - Server: DNSLocalTag, + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultDNSRule{ + RuleSet: []string{"geosite-geolocation-cn"}, + Server: DNSLocalTag, }, }) } diff --git a/template/render_geo_resources.go b/template/render_geo_resources.go index 432bb28..9bb3226 100644 --- a/template/render_geo_resources.go +++ b/template/render_geo_resources.go @@ -68,19 +68,10 @@ func (t *Template) renderGeoResources(metadata M.Metadata, options *option.Optio }, { Type: C.RuleSetTypeRemote, - Tag: "geosite-cn", + Tag: "geosite-geolocation-cn", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-cn.srs", - DownloadDetour: downloadDetour, - }, - }, - { - Type: C.RuleSetTypeRemote, - Tag: "geosite-geolocation-!cn", - Format: C.RuleSetFormatBinary, - RemoteOptions: option.RemoteRuleSet{ - URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-!cn.srs", + URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-cn.srs", DownloadDetour: downloadDetour, }, }, diff --git a/template/render_route.go b/template/render_route.go index a38ef7b..ff4e1a1 100644 --- a/template/render_route.go +++ b/template/render_route.go @@ -121,50 +121,19 @@ func (t *Template) renderRoute(metadata M.Metadata, options *option.Options) err if !t.DisableTrafficBypass { if t.DisableRuleSet || disable18Features { options.Route.Rules = append(options.Route.Rules, option.Rule{ - Type: C.RuleTypeLogical, - LogicalOptions: option.LogicalRule{ - Mode: C.LogicalTypeAnd, - Rules: []option.Rule{ - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultRule{ - Geosite: []string{"geolocation-!cn"}, - Invert: true, - }, - }, - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultRule{ - GeoIP: []string{"cn"}, - Geosite: []string{"cn"}, - Domain: []string{"download.jetbrains.com"}, - }, - }, - }, + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultRule{ + GeoIP: []string{"cn"}, + Geosite: []string{"geolocation-cn"}, Outbound: directTag, }, }) } else { options.Route.Rules = append(options.Route.Rules, option.Rule{ - Type: C.RuleTypeLogical, - LogicalOptions: option.LogicalRule{ - Mode: C.LogicalTypeAnd, - Rules: []option.Rule{ - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultRule{ - RuleSet: []string{"geosite-geolocation-!cn"}, - Invert: true, - }, - }, - { - Type: C.RuleTypeDefault, - DefaultOptions: option.DefaultRule{ - RuleSet: []string{"geoip-cn", "geosite-cn"}, - }, - }, - }, - Outbound: "direct", + Type: C.RuleTypeDefault, + DefaultOptions: option.DefaultRule{ + RuleSet: []string{"geoip-cn", "geosite-geolocation-cn"}, + Outbound: directTag, }, }) }