1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-27 01:45:23 +00:00

correct initialization in socks server

This commit is contained in:
v2ray 2016-07-23 11:09:49 +02:00
parent 85d6e1ad13
commit 84a7a2ad61
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -38,12 +38,20 @@ type Server struct {
}
// NewServer creates a new Server object.
func NewServer(config *Config, packetDispatcher dispatcher.PacketDispatcher, meta *proxy.InboundHandlerMeta) *Server {
return &Server{
config: config,
packetDispatcher: packetDispatcher,
meta: meta,
func NewServer(config *Config, space app.Space, meta *proxy.InboundHandlerMeta) *Server {
s := &Server{
config: config,
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().
@ -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) {
if !space.HasApp(dispatcher.APP_ID) {
return nil, internal.ErrBadConfiguration
}
return NewServer(
rawConfig.(*Config),
space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher),
meta), nil
return NewServer(rawConfig.(*Config), space, meta), nil
}
func init() {