1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-06 17:25:27 -05:00

generalized event handler

This commit is contained in:
Darien Raymond
2017-11-28 23:41:20 +01:00
parent 973ce07db9
commit fd8db49dc9
16 changed files with 80 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
address: config.GetPredefinedAddress(),
port: net.Port(config.Port),
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy not found in space.")

View File

@@ -40,7 +40,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
timeout: config.Timeout,
destOverride: config.DestinationOverride,
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
if config.DomainStrategy == Config_USE_IP {
f.dns = dns.FromSpace(space)
if f.dns == nil {

View File

@@ -37,7 +37,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
s := &Server{
config: config,
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy not found in space.")

View File

@@ -39,7 +39,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
if space == nil {
return nil, newError("Space not found.")
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy not found in space.")

View File

@@ -47,7 +47,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
account: account,
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy not found in space.")

View File

@@ -34,7 +34,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
s := &Server{
config: config,
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy not found in space.")

View File

@@ -103,7 +103,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
sessionHistory: encoding.NewSessionHistory(ctx),
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
handler.inboundHandlerManager = proxyman.InboundHandlerManagerFromSpace(space)
if handler.inboundHandlerManager == nil {
return newError("InboundHandlerManager is not found is space.")

View File

@@ -44,7 +44,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
serverPicker: protocol.NewRoundRobinServerPicker(serverList),
}
space.OnInitialize(func() error {
space.On(app.SpaceInitializing, func(interface{}) error {
pm := policy.FromSpace(space)
if pm == nil {
return newError("Policy is not found in space.")