simplify connection handler registration

This commit is contained in:
v2ray
2016-01-06 16:23:54 +01:00
parent 350b31cad9
commit 5b1854f842
10 changed files with 59 additions and 52 deletions
+12
View File
@@ -25,6 +25,12 @@ func RegisterInboundConnectionHandlerFactory(name string, creator InboundConnect
return nil
}
func MustRegisterInboundConnectionHandlerCreator(name string, creator InboundConnectionHandlerCreator) {
if err := RegisterInboundConnectionHandlerFactory(name, creator); err != nil {
panic(err)
}
}
func RegisterOutboundConnectionHandlerFactory(name string, creator OutboundConnectionHandlerCreator) error {
if _, found := outboundFactories[name]; found {
return ErrorNameExists
@@ -33,6 +39,12 @@ func RegisterOutboundConnectionHandlerFactory(name string, creator OutboundConne
return nil
}
func MustRegisterOutboundConnectionHandlerCreator(name string, creator OutboundConnectionHandlerCreator) {
if err := RegisterOutboundConnectionHandlerFactory(name, creator); err != nil {
panic(err)
}
}
func CreateInboundConnectionHandler(name string, space app.Space, rawConfig []byte) (proxy.InboundConnectionHandler, error) {
creator, found := inboundFactories[name]
if !found {