mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-11 17:47:20 +10:00
Fix duplicate tag detection for empty tags
Closes https://github.com/SagerNet/sing-box/issues/3665
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
F "github.com/sagernet/sing/common/format"
|
||||
"github.com/sagernet/sing/common/json"
|
||||
)
|
||||
|
||||
@@ -60,37 +61,40 @@ func checkOptions(options *Options) error {
|
||||
|
||||
func checkInbounds(inbounds []Inbound) error {
|
||||
seen := make(map[string]bool)
|
||||
for _, inbound := range inbounds {
|
||||
if inbound.Tag == "" {
|
||||
continue
|
||||
for i, inbound := range inbounds {
|
||||
tag := inbound.Tag
|
||||
if tag == "" {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
if seen[inbound.Tag] {
|
||||
return E.New("duplicate inbound tag: ", inbound.Tag)
|
||||
if seen[tag] {
|
||||
return E.New("duplicate inbound tag: ", tag)
|
||||
}
|
||||
seen[inbound.Tag] = true
|
||||
seen[tag] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkOutbounds(outbounds []Outbound, endpoints []Endpoint) error {
|
||||
seen := make(map[string]bool)
|
||||
for _, outbound := range outbounds {
|
||||
if outbound.Tag == "" {
|
||||
continue
|
||||
for i, outbound := range outbounds {
|
||||
tag := outbound.Tag
|
||||
if tag == "" {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
if seen[outbound.Tag] {
|
||||
return E.New("duplicate outbound/endpoint tag: ", outbound.Tag)
|
||||
if seen[tag] {
|
||||
return E.New("duplicate outbound/endpoint tag: ", tag)
|
||||
}
|
||||
seen[outbound.Tag] = true
|
||||
seen[tag] = true
|
||||
}
|
||||
for _, endpoint := range endpoints {
|
||||
if endpoint.Tag == "" {
|
||||
continue
|
||||
for i, endpoint := range endpoints {
|
||||
tag := endpoint.Tag
|
||||
if tag == "" {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
if seen[endpoint.Tag] {
|
||||
return E.New("duplicate outbound/endpoint tag: ", endpoint.Tag)
|
||||
if seen[tag] {
|
||||
return E.New("duplicate outbound/endpoint tag: ", tag)
|
||||
}
|
||||
seen[endpoint.Tag] = true
|
||||
seen[tag] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user