Reject duplicate tags in outbound groups

This commit is contained in:
世界
2026-10-23 19:57:06 +08:00
parent ae4826a387
commit c90ccd7535
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -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
}
+6
View File
@@ -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
}