Xray-core/features/routing/dispatcher.go

29 lines
844 B
Go
Raw Permalink Normal View History

2020-11-25 14:01:53 +03:00
package routing
import (
"context"
2020-12-04 04:36:16 +03:00
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/features"
"github.com/xtls/xray-core/transport"
2020-11-25 14:01:53 +03:00
)
// Dispatcher is a feature that dispatches inbound requests to outbound handlers based on rules.
// Dispatcher is required to be registered in a Xray instance to make Xray function properly.
//
// xray:api:stable
type Dispatcher interface {
features.Feature
// Dispatch returns a Ray for transporting data for the given request.
Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error)
2021-09-28 04:42:57 +03:00
DispatchLink(ctx context.Context, dest net.Destination, link *transport.Link) error
2020-11-25 14:01:53 +03:00
}
// DispatcherType returns the type of Dispatcher interface. Can be used to implement common.HasType.
//
// xray:api:stable
func DispatcherType() interface{} {
return (*Dispatcher)(nil)
}