From 7b7fa3723292b53ec209576e872d0c89938dd1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 18 Nov 2024 14:20:42 +0800 Subject: [PATCH] fix --- template/render_outbounds.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/template/render_outbounds.go b/template/render_outbounds.go index 32d33a2..09ad426 100644 --- a/template/render_outbounds.go +++ b/template/render_outbounds.go @@ -161,9 +161,6 @@ func (t *Template) renderOutbounds(metadata M.Metadata, options *boxOption.Optio } return true }) - if len(subscriptionTags) == 0 { - continue - } var tagPerSubscription string if len(outboundTags) == 0 && len(subscriptions) == 1 { tagPerSubscription = extraGroup.Tag @@ -186,11 +183,17 @@ func (t *Template) renderOutbounds(metadata M.Metadata, options *boxOption.Optio case C.TypeSelector: selectorOptions := common.PtrValueOrDefault(extraGroup.CustomSelector) groupOutboundPerSubscription.Options = &selectorOptions - selectorOptions.Outbounds = append(selectorOptions.Outbounds, subscriptionTags...) + selectorOptions.Outbounds = common.Uniq(append(selectorOptions.Outbounds, subscriptionTags...)) + if len(selectorOptions.Outbounds) == 0 { + continue + } case C.TypeURLTest: urltestOptions := common.PtrValueOrDefault(extraGroup.CustomURLTest) groupOutboundPerSubscription.Options = &urltestOptions - urltestOptions.Outbounds = append(urltestOptions.Outbounds, subscriptionTags...) + urltestOptions.Outbounds = common.Uniq(append(urltestOptions.Outbounds, subscriptionTags...)) + if len(urltestOptions.Outbounds) == 0 { + continue + } } subscriptionGroups[it.Name] = append(subscriptionGroups[it.Name], groupOutboundPerSubscription) } @@ -225,10 +228,6 @@ func (t *Template) renderOutbounds(metadata M.Metadata, options *boxOption.Optio return true })...) } - extraTags = common.Uniq(extraTags) - if len(extraTags) == 0 { - continue - } groupOutbound := boxOption.Outbound{ Tag: extraGroup.Tag, Type: extraGroup.Type, @@ -237,11 +236,17 @@ func (t *Template) renderOutbounds(metadata M.Metadata, options *boxOption.Optio case C.TypeSelector: selectorOptions := common.PtrValueOrDefault(extraGroup.CustomSelector) groupOutbound.Options = &selectorOptions - selectorOptions.Outbounds = append(selectorOptions.Outbounds, extraTags...) + selectorOptions.Outbounds = common.Uniq(append(selectorOptions.Outbounds, extraTags...)) + if len(selectorOptions.Outbounds) == 0 { + continue + } case C.TypeURLTest: urltestOptions := common.PtrValueOrDefault(extraGroup.CustomURLTest) groupOutbound.Options = &urltestOptions - urltestOptions.Outbounds = append(urltestOptions.Outbounds, extraTags...) + urltestOptions.Outbounds = common.Uniq(append(urltestOptions.Outbounds, extraTags...)) + if len(urltestOptions.Outbounds) == 0 { + continue + } } if extraGroup.Target == option.ExtraGroupTargetDefault { defaultGroups = append(defaultGroups, groupOutbound)