瀏覽代碼

Restrict tag to be unique (#258)

Jim Han 4 年之前
父節點
當前提交
9aa49be703
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 3 0
      app/proxyman/inbound/inbound.go
  2. 3 0
      app/proxyman/outbound/outbound.go

+ 3 - 0
app/proxyman/inbound/inbound.go

@@ -42,6 +42,9 @@ func (m *Manager) AddHandler(ctx context.Context, handler inbound.Handler) error
 
 	tag := handler.Tag()
 	if len(tag) > 0 {
+		if _, found := m.taggedHandlers[tag]; found {
+			return newError("existing tag found: " + tag)
+		}
 		m.taggedHandlers[tag] = handler
 	} else {
 		m.untaggedHandler = append(m.untaggedHandler, handler)

+ 3 - 0
app/proxyman/outbound/outbound.go

@@ -109,6 +109,9 @@ func (m *Manager) AddHandler(ctx context.Context, handler outbound.Handler) erro
 
 	tag := handler.Tag()
 	if len(tag) > 0 {
+		if _, found := m.taggedHandler[tag]; found {
+			return newError("existing tag found: " + tag)
+		}
 		m.taggedHandler[tag] = handler
 	} else {
 		m.untaggedHandlers = append(m.untaggedHandlers, handler)