Explorar o código

Dedup protocol registration

Jinqiu Yu %!s(int64=7) %!d(string=hai) anos
pai
achega
794dfd5bf3
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      transport/internet/config.go

+ 3 - 1
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
 }