Documentation ¶
Index ¶
- func DispatcherType() interface{}
- func RouterType() interface{}
- type BalancerOverrider
- type BalancerPrincipleTarget
- type Context
- type DefaultRouter
- func (DefaultRouter) AddRule(config *serial.TypedMessage, shouldAppend bool) error
- func (DefaultRouter) AddUserRule(tag string, email []string)
- func (DefaultRouter) Close() error
- func (DefaultRouter) PickRoute(ctx Context) (Route, error)
- func (DefaultRouter) RemoveRule(tag string) error
- func (DefaultRouter) RemoveUserRule(email []string)
- func (DefaultRouter) Start() error
- func (DefaultRouter) Type() interface{}
- type Dispatcher
- type Route
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DispatcherType ¶
func DispatcherType() interface{}
DispatcherType returns the type of Dispatcher interface. Can be used to implement common.HasType.
xray:api:stable
func RouterType ¶
func RouterType() interface{}
RouterType return the type of Router interface. Can be used to implement common.HasType.
xray:api:stable
Types ¶
type BalancerOverrider ¶ added in v1.8.10
type BalancerPrincipleTarget ¶ added in v1.8.10
type Context ¶
type Context interface { // GetInboundTag returns the tag of the inbound the connection was from. GetInboundTag() string // GetSourcesIPs returns the source IPs bound to the connection. GetSourceIPs() []net.IP // GetSourcePort returns the source port of the connection. GetSourcePort() net.Port // GetTargetIPs returns the target IP of the connection or resolved IPs of target domain. GetTargetIPs() []net.IP // GetTargetPort returns the target port of the connection. GetTargetPort() net.Port // GetTargetDomain returns the target domain of the connection, if exists. GetTargetDomain() string // GetNetwork returns the network type of the connection. GetNetwork() net.Network // GetProtocol returns the protocol from the connection content, if sniffed out. GetProtocol() string // GetUser returns the user email from the connection content, if exists. GetUser() string // GetAttributes returns extra attributes from the conneciont content. GetAttributes() map[string]string // GetSkipDNSResolve returns a flag switch for weather skip dns resolve during route pick. GetSkipDNSResolve() bool }
Context is a feature to store connection information for routing.
xray:api:stable
type DefaultRouter ¶
type DefaultRouter struct{}
DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.
func (DefaultRouter) AddRule ¶ added in v1.8.10
func (DefaultRouter) AddRule(config *serial.TypedMessage, shouldAppend bool) error
AddRule implements Router.
func (DefaultRouter) AddUserRule ¶ added in v1.8.24
func (DefaultRouter) AddUserRule(tag string, email []string)
AddUsers implements Router.
func (DefaultRouter) PickRoute ¶
func (DefaultRouter) PickRoute(ctx Context) (Route, error)
PickRoute implements Router.
func (DefaultRouter) RemoveRule ¶ added in v1.8.10
func (DefaultRouter) RemoveRule(tag string) error
RemoveRule implements Router.
func (DefaultRouter) RemoveUserRule ¶ added in v1.8.24
func (DefaultRouter) RemoveUserRule(email []string)
RemoveUsers implements Router.
type Dispatcher ¶
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) DispatchLink(ctx context.Context, dest net.Destination, link *transport.Link) error }
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 Route ¶
type Route interface { // A Route is also a routing context. Context // GetOutboundGroupTags returns the detoured outbound group tags in sequence before a final outbound is chosen. GetOutboundGroupTags() []string // GetOutboundTag returns the tag of the outbound the connection was dispatched to. GetOutboundTag() string }
Route is the routing result of Router feature.
xray:api:stable
type Router ¶
type Router interface { features.Feature // PickRoute returns a route decision based on the given routing context. PickRoute(ctx Context) (Route, error) AddRule(config *serial.TypedMessage, shouldAppend bool) error RemoveRule(tag string) error // Add user routing rule AddUserRule(tag string, email []string) // Remove user routing rule RemoveUserRule(email []string) }
Router is a feature to choose an outbound tag for the given request.
xray:api:stable