From 9aa49be703367a9229f425633b0993722fb0ccc1 Mon Sep 17 00:00:00 2001 From: Jim Han <50871214+JimhHan@users.noreply.github.com> Date: Thu, 18 Feb 2021 17:53:10 +0800 Subject: [PATCH] Restrict tag to be unique (#258) --- app/proxyman/inbound/inbound.go | 3 +++ app/proxyman/outbound/outbound.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index 0846b856..3c9fb467 100644 --- a/app/proxyman/inbound/inbound.go +++ b/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) diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 40f98ba9..8ebcde17 100644 --- a/app/proxyman/outbound/outbound.go +++ b/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)