Przeglądaj źródła

Dedup protocol registration

Jinqiu Yu 7 lat temu
rodzic
commit
794dfd5bf3
1 zmienionych plików z 3 dodań i 1 usunięć
  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
 }