mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-07 11:39:11 -04:00
common.Must
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package blackhole
|
||||
|
||||
import (
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/serial"
|
||||
"v2ray.com/core/proxy"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Must listed after config.pb.go
|
||||
proxy.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory))
|
||||
common.Must(proxy.RegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)))
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/app/dispatcher"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/errors"
|
||||
"v2ray.com/core/common/log"
|
||||
@@ -211,5 +212,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Inb
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory))
|
||||
common.Must(proxy.RegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)))
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/app/dns"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/dice"
|
||||
"v2ray.com/core/common/errors"
|
||||
@@ -141,5 +142,5 @@ func (v *Factory) Create(space app.Space, config interface{}, meta *proxy.Outbou
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory))
|
||||
common.Must(proxy.RegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)))
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ func RegisterInboundHandlerCreator(name string, creator InboundHandlerFactory) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func MustRegisterInboundHandlerCreator(name string, creator InboundHandlerFactory) {
|
||||
if err := RegisterInboundHandlerCreator(name, creator); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterOutboundHandlerCreator(name string, creator OutboundHandlerFactory) error {
|
||||
if _, found := outboundFactories[name]; found {
|
||||
return common.ErrDuplicatedName
|
||||
@@ -34,12 +28,6 @@ func RegisterOutboundHandlerCreator(name string, creator OutboundHandlerFactory)
|
||||
return nil
|
||||
}
|
||||
|
||||
func MustRegisterOutboundHandlerCreator(name string, creator OutboundHandlerFactory) {
|
||||
if err := RegisterOutboundHandlerCreator(name, creator); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func CreateInboundHandler(name string, space app.Space, config interface{}, meta *InboundHandlerMeta) (InboundHandler, error) {
|
||||
creator, found := inboundFactories[name]
|
||||
if !found {
|
||||
|
||||
@@ -297,5 +297,5 @@ func (v *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *pro
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory))
|
||||
common.Must(proxy.RegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package shadowsocks
|
||||
|
||||
import (
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/serial"
|
||||
"v2ray.com/core/proxy"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Must happen after config is initialized
|
||||
proxy.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(ClientConfig)), new(ClientFactory))
|
||||
proxy.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory))
|
||||
common.Must(proxy.RegisterOutboundHandlerCreator(serial.GetMessageType(new(ClientConfig)), new(ClientFactory)))
|
||||
common.Must(proxy.RegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)))
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/app/dispatcher"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/bufio"
|
||||
"v2ray.com/core/common/crypto"
|
||||
@@ -333,5 +334,5 @@ func (v *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *pro
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory))
|
||||
common.Must(proxy.RegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)))
|
||||
}
|
||||
|
||||
@@ -271,5 +271,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Inb
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory))
|
||||
common.Must(proxy.RegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/bufio"
|
||||
"v2ray.com/core/common/log"
|
||||
@@ -178,5 +179,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Out
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory))
|
||||
common.Must(proxy.RegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user