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 }