mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Reject duplicate tags in outbound groups
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user