From 383aede2076f71e7deee3ee3ca0904d5469c8e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 12 Sep 2024 07:38:29 +0800 Subject: [PATCH] Minor fixes --- ...ll_group_reference.go => filter_null_references.go} | 10 ++++++++++ template/manager.go | 2 +- template/render_dns.go | 2 +- template/render_experimental.go | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) rename template/filter/{filter_null_group_reference.go => filter_null_references.go} (75%) diff --git a/template/filter/filter_null_group_reference.go b/template/filter/filter_null_references.go similarity index 75% rename from template/filter/filter_null_group_reference.go rename to template/filter/filter_null_references.go index 72092ed..a34e2fc 100644 --- a/template/filter/filter_null_group_reference.go +++ b/template/filter/filter_null_references.go @@ -30,5 +30,15 @@ func filterNullGroupReference(metadata M.Metadata, options *option.Options) erro } options.Outbounds[i] = outbound } + options.Route.Rules = common.Filter(options.Route.Rules, func(it option.Rule) bool { + switch it.Type { + case C.RuleTypeDefault: + return common.Contains(outboundTags, it.DefaultOptions.Outbound) + case C.RuleTypeLogical: + return common.Contains(outboundTags, it.LogicalOptions.Outbound) + default: + panic("no") + } + }) return nil } diff --git a/template/manager.go b/template/manager.go index 83508cc..def403b 100644 --- a/template/manager.go +++ b/template/manager.go @@ -41,7 +41,7 @@ func extendTemplate(rawTemplates []option.Template, root, current option.Templat } next = newNext } - newRawTemplate, err := badjson.MergeJSON(next.RawMessage, current.RawMessage, true) + newRawTemplate, err := badjson.MergeJSON(next.RawMessage, current.RawMessage, false) if err != nil { return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: merge extended template: ", current.Extend) } diff --git a/template/render_dns.go b/template/render_dns.go index cf6d9aa..b0009be 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -162,7 +162,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error }, }) } - if !t.DisableDNSLeak && (metadata.Version != nil && metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.1"))) { + if !t.DisableDNSLeak && (metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.1"))) { options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{ Type: C.RuleTypeDefault, DefaultOptions: option.DefaultDNSRule{ diff --git a/template/render_experimental.go b/template/render_experimental.go index 3b48644..75f0663 100644 --- a/template/render_experimental.go +++ b/template/render_experimental.go @@ -30,7 +30,7 @@ func (t *Template) renderExperimental(metadata M.Metadata, options *option.Optio CacheID: profileName, StoreFakeIP: t.EnableFakeIP, } - if !t.DisableDNSLeak && (metadata.Version != nil && metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.8"))) { + if !t.DisableDNSLeak && (metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.1"))) { options.Experimental.CacheFile.StoreRDRC = true } } @@ -51,7 +51,7 @@ func (t *Template) renderExperimental(metadata M.Metadata, options *option.Optio } if !t.DisableClashMode { - if !t.DisableDNSLeak && (metadata.Version != nil && metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.1"))) { + if !t.DisableDNSLeak && (metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.9.0-alpha.1"))) { clashModeLeak := t.ClashModeLeak if clashModeLeak == "" { clashModeLeak = "Leak"