2016-01-31 16:01:28 +00:00
|
|
|
package dispatcher
|
|
|
|
|
|
|
|
import (
|
2017-01-26 19:46:44 +00:00
|
|
|
"context"
|
|
|
|
|
2016-08-20 18:55:45 +00:00
|
|
|
"v2ray.com/core/app"
|
2017-02-03 21:35:09 +00:00
|
|
|
"v2ray.com/core/common/net"
|
2016-08-20 18:55:45 +00:00
|
|
|
"v2ray.com/core/transport/ray"
|
2016-01-31 16:01:28 +00:00
|
|
|
)
|
|
|
|
|
2017-01-13 12:53:44 +00:00
|
|
|
// Interface dispatch a packet and possibly further network payload to its destination.
|
|
|
|
type Interface interface {
|
2017-02-03 21:35:09 +00:00
|
|
|
Dispatch(ctx context.Context, dest net.Destination) (ray.InboundRay, error)
|
2016-01-31 16:01:28 +00:00
|
|
|
}
|
2017-01-06 14:32:36 +00:00
|
|
|
|
2017-01-13 12:53:44 +00:00
|
|
|
func FromSpace(space app.Space) Interface {
|
|
|
|
if app := space.GetApplication((*Interface)(nil)); app != nil {
|
|
|
|
return app.(Interface)
|
2017-01-06 14:32:36 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|