v2ray-core: github.com/v2ray/v2ray-core/features/routing Index | Files | Directories

package routing

import "github.com/v2ray/v2ray-core/features/routing"


Package Files

context.go dispatcher.go router.go

func DispatcherType Uses

func DispatcherType() interface{}

DispatcherType returns the type of Dispatcher interface. Can be used to implement common.HasType.


func RouterType Uses

func RouterType() interface{}

RouterType return the type of Router interface. Can be used to implement common.HasType.


type Context Uses

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

Context is a feature to store connection information for routing.


type DefaultRouter Uses

type DefaultRouter struct{}

DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.

func (DefaultRouter) Close Uses

func (DefaultRouter) Close() error

Close implements common.Closable.

func (DefaultRouter) PickRoute Uses

func (DefaultRouter) PickRoute(ctx Context) (Route, error)

PickRoute implements Router.

func (DefaultRouter) Start Uses

func (DefaultRouter) Start() error

Start implements common.Runnable.

func (DefaultRouter) Type Uses

func (DefaultRouter) Type() interface{}

Type implements common.HasType.

type Dispatcher Uses

type Dispatcher interface {

    // Dispatch returns a Ray for transporting data for the given request.
    Dispatch(ctx context.Context, dest net.Destination) (*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 V2Ray instance to make V2Ray function properly.


type Route Uses

type Route interface {
    // A Route is also a routing 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.


type Router Uses

type Router interface {

    // PickRoute returns a route decision based on the given routing context.
    PickRoute(ctx Context) (Route, error)

Router is a feature to choose an outbound tag for the given request.




Package routing imports 5 packages (graph). Updated 2020-10-15. Refresh now. Tools for package owners.