From 794dfd5bf31c0c44d7cb4613eded74ed01cae1c8 Mon Sep 17 00:00:00 2001 From: Jinqiu Yu Date: Tue, 6 Mar 2018 15:24:52 +0800 Subject: [PATCH] Dedup protocol registration --- transport/internet/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transport/internet/config.go b/transport/internet/config.go index 72d20f8e..b97246fc 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -10,7 +10,9 @@ var ( ) func RegisterProtocolConfigCreator(protocol TransportProtocol, creator ConfigCreator) error { - // TODO: check duplicate + if _, found := globalTransportConfigCreatorCache[protocol]; found { + return newError("protocol: " + TransportProtocol_name[int32(protocol)]+ " is already registered").AtError() + } globalTransportConfigCreatorCache[protocol] = creator return nil }