Merge pull request #924 from yujinqiu/dedup-protocol-register

Dedup protocol registration
pull/927/head
DarienRaymond 2018-03-06 10:43:56 +01:00 committed by GitHub
commit 4b5a5810a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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
}