mirror of https://github.com/v2ray/v2ray-core
correct initialization in socks server
parent
85d6e1ad13
commit
84a7a2ad61
|
@ -38,12 +38,20 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a new Server object.
|
// NewServer creates a new Server object.
|
||||||
func NewServer(config *Config, packetDispatcher dispatcher.PacketDispatcher, meta *proxy.InboundHandlerMeta) *Server {
|
func NewServer(config *Config, space app.Space, meta *proxy.InboundHandlerMeta) *Server {
|
||||||
return &Server{
|
s := &Server{
|
||||||
config: config,
|
config: config,
|
||||||
packetDispatcher: packetDispatcher,
|
|
||||||
meta: meta,
|
meta: meta,
|
||||||
}
|
}
|
||||||
|
space.InitializeApplication(func() error {
|
||||||
|
if !space.HasApp(dispatcher.APP_ID) {
|
||||||
|
log.Error("Socks|Server: Dispatcher is not found in the space.")
|
||||||
|
return app.ErrMissingApplication
|
||||||
|
}
|
||||||
|
s.packetDispatcher = space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Port implements InboundHandler.Port().
|
// Port implements InboundHandler.Port().
|
||||||
|
@ -310,13 +318,7 @@ func (this *ServerFactory) StreamCapability() internet.StreamConnectionType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
|
||||||
if !space.HasApp(dispatcher.APP_ID) {
|
return NewServer(rawConfig.(*Config), space, meta), nil
|
||||||
return nil, internal.ErrBadConfiguration
|
|
||||||
}
|
|
||||||
return NewServer(
|
|
||||||
rawConfig.(*Config),
|
|
||||||
space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher),
|
|
||||||
meta), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue