1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-01 00:06:11 -04:00
v2fly/app/proxyman/inbound/mux.go
2017-02-03 22:50:01 +01:00

34 lines
664 B
Go

package inbound
import (
"context"
"errors"
"v2ray.com/core/app"
"v2ray.com/core/app/dispatcher"
"v2ray.com/core/common/net"
"v2ray.com/core/transport/ray"
)
type mux struct {
dispatcher dispatcher.Interface
}
func newMux(ctx context.Context) *mux {
m := &mux{}
space := app.SpaceFromContext(ctx)
space.OnInitialize(func() error {
d := dispatcher.FromSpace(space)
if d == nil {
return errors.New("Proxyman|DefaultInboundHandler: No dispatcher in space.")
}
m.dispatcher = d
return nil
})
return m
}
func (m *mux) Dispatch(ctx context.Context, dest net.Destination) (ray.InboundRay, error) {
return m.dispatcher.Dispatch(ctx, dest)
}