From c90ccd75354487527a69e5b1a7bc7e8a24fd9909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 22 Oct 2026 23:31:46 +0800 Subject: [PATCH] Reject duplicate tags in outbound groups --- protocol/group/selector.go | 6 ++++++ protocol/group/urltest.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/protocol/group/selector.go b/protocol/group/selector.go index c3aaec5a..2b04d00f 100644 --- a/protocol/group/selector.go +++ b/protocol/group/selector.go @@ -3,6 +3,7 @@ package group import ( "context" "net" + "slices" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/adapter/outbound" @@ -62,6 +63,11 @@ func NewSelector(ctx context.Context, router adapter.Router, logger log.ContextL if len(outbound.tags) == 0 { return nil, E.New("missing tags") } + for i, tag := range outbound.tags { + if slices.Contains(outbound.tags[:i], tag) { + return nil, E.New("duplicate tag: ", tag) + } + } return outbound, nil } diff --git a/protocol/group/urltest.go b/protocol/group/urltest.go index bc50ab70..207f1515 100644 --- a/protocol/group/urltest.go +++ b/protocol/group/urltest.go @@ -4,6 +4,7 @@ import ( "context" "maps" "net" + "slices" "sync" "sync/atomic" "time" @@ -68,6 +69,11 @@ func NewURLTest(ctx context.Context, router adapter.Router, logger log.ContextLo if len(outbound.tags) == 0 { return nil, E.New("missing tags") } + for i, tag := range outbound.tags { + if slices.Contains(outbound.tags[:i], tag) { + return nil, E.New("duplicate tag: ", tag) + } + } return outbound, nil }