router

package
v0.0.0-...-125528f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BalancingRule_BalancingStrategy_name = map[int32]string{
	0: "Random",
	1: "Latency",
}
View Source
var BalancingRule_BalancingStrategy_value = map[string]int32{
	"Random":  0,
	"Latency": 1,
}
View Source
var Config_DomainStrategy_name = map[int32]string{
	0: "AsIs",
	1: "UseIp",
	2: "IpIfNonMatch",
	3: "IpOnDemand",
}
View Source
var Config_DomainStrategy_value = map[string]int32{
	"AsIs":         0,
	"UseIp":        1,
	"IpIfNonMatch": 2,
	"IpOnDemand":   3,
}
View Source
var Domain_Type_name = map[int32]string{
	0: "Plain",
	1: "Regex",
	2: "Domain",
	3: "Full",
}
View Source
var Domain_Type_value = map[string]int32{
	"Plain":  0,
	"Regex":  1,
	"Domain": 2,
	"Full":   3,
}
View Source
var ShouldPerformLatencyTest = true

Functions

func StringToRuneSlice

func StringToRuneSlice(s string) []rune

func WildcardPatternMatch

func WildcardPatternMatch(str, pattern string) bool

Function that matches input str with given wildcard pattern

Types

type ApplicationMatcher

type ApplicationMatcher struct {
	// contains filtered or unexported fields
}

func NewApplicationMatcher

func NewApplicationMatcher(apps []string) *ApplicationMatcher

func (*ApplicationMatcher) Apply

func (m *ApplicationMatcher) Apply(ctx *Context) bool

type AttributeMatcher

type AttributeMatcher struct {
	// contains filtered or unexported fields
}

func NewAttributeMatcher

func NewAttributeMatcher(code string) (*AttributeMatcher, error)

func (*AttributeMatcher) Apply

func (m *AttributeMatcher) Apply(ctx *Context) bool

func (*AttributeMatcher) Match

func (m *AttributeMatcher) Match(attrs map[string]interface{}) bool

type Balancer

type Balancer struct {
	// contains filtered or unexported fields
}

func (*Balancer) PickOutbound

func (b *Balancer) PickOutbound() (string, error)

type BalancingRule

type BalancingRule struct {
	Tag               string                          `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
	OutboundSelector  []string                        `protobuf:"bytes,2,rep,name=outbound_selector,json=outboundSelector,proto3" json:"outbound_selector,omitempty"`
	BalancingStrategy BalancingRule_BalancingStrategy `` /* 172-byte string literal not displayed */
	// FIXME Better define in its own setting struct.
	TotalMeasures        uint32   `protobuf:"varint,100,opt,name=total_measures,json=totalMeasures,proto3" json:"total_measures,omitempty"`
	Interval             uint32   `protobuf:"varint,101,opt,name=interval,proto3" json:"interval,omitempty"`
	Delay                uint32   `protobuf:"varint,102,opt,name=delay,proto3" json:"delay,omitempty"`
	Timeout              uint32   `protobuf:"varint,103,opt,name=timeout,proto3" json:"timeout,omitempty"`
	Tolerance            uint32   `protobuf:"varint,104,opt,name=tolerance,proto3" json:"tolerance,omitempty"`
	ProbeTarget          string   `protobuf:"bytes,105,opt,name=probe_target,json=probeTarget,proto3" json:"probe_target,omitempty"`
	ProbeContent         string   `protobuf:"bytes,106,opt,name=probe_content,json=probeContent,proto3" json:"probe_content,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*BalancingRule) Build

func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error)

func (*BalancingRule) Descriptor

func (*BalancingRule) Descriptor() ([]byte, []int)

func (*BalancingRule) GetBalancingStrategy

func (m *BalancingRule) GetBalancingStrategy() BalancingRule_BalancingStrategy

func (*BalancingRule) GetDelay

func (m *BalancingRule) GetDelay() uint32

func (*BalancingRule) GetInterval

func (m *BalancingRule) GetInterval() uint32

func (*BalancingRule) GetOutboundSelector

func (m *BalancingRule) GetOutboundSelector() []string

func (*BalancingRule) GetProbeContent

func (m *BalancingRule) GetProbeContent() string

func (*BalancingRule) GetProbeTarget

func (m *BalancingRule) GetProbeTarget() string

func (*BalancingRule) GetTag

func (m *BalancingRule) GetTag() string

func (*BalancingRule) GetTimeout

func (m *BalancingRule) GetTimeout() uint32

func (*BalancingRule) GetTolerance

func (m *BalancingRule) GetTolerance() uint32

func (*BalancingRule) GetTotalMeasures

func (m *BalancingRule) GetTotalMeasures() uint32

func (*BalancingRule) ProtoMessage

func (*BalancingRule) ProtoMessage()

func (*BalancingRule) Reset

func (m *BalancingRule) Reset()

func (*BalancingRule) String

func (m *BalancingRule) String() string

func (*BalancingRule) XXX_DiscardUnknown

func (m *BalancingRule) XXX_DiscardUnknown()

func (*BalancingRule) XXX_Marshal

func (m *BalancingRule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BalancingRule) XXX_Merge

func (m *BalancingRule) XXX_Merge(src proto.Message)

func (*BalancingRule) XXX_Size

func (m *BalancingRule) XXX_Size() int

func (*BalancingRule) XXX_Unmarshal

func (m *BalancingRule) XXX_Unmarshal(b []byte) error

type BalancingRule_BalancingStrategy

type BalancingRule_BalancingStrategy int32
const (
	BalancingRule_Random  BalancingRule_BalancingStrategy = 0
	BalancingRule_Latency BalancingRule_BalancingStrategy = 1
)

func (BalancingRule_BalancingStrategy) EnumDescriptor

func (BalancingRule_BalancingStrategy) EnumDescriptor() ([]byte, []int)

func (BalancingRule_BalancingStrategy) String

type BalancingStrategy

type BalancingStrategy interface {
	PickOutbound([]string) string
}

func NewLatencyStrategy

func NewLatencyStrategy(ohm outbound.Manager, selectors []string, totalMeasures int, interval, delay, timeout, tolerance time.Duration, target, content string) BalancingStrategy

type By

type By func(p1, p2 *Server) bool

func (By) Sort

func (by By) Sort(servers []Server)

type CIDR

type CIDR struct {
	// IP address, should be either 4 or 16 bytes.
	Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
	// Number of leading ones in the network mask.
	Prefix               uint32   `protobuf:"varint,2,opt,name=prefix,proto3" json:"prefix,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

IP for routing decision, in CIDR form.

func (*CIDR) Descriptor

func (*CIDR) Descriptor() ([]byte, []int)

func (*CIDR) GetIp

func (m *CIDR) GetIp() []byte

func (*CIDR) GetPrefix

func (m *CIDR) GetPrefix() uint32

func (*CIDR) ProtoMessage

func (*CIDR) ProtoMessage()

func (*CIDR) Reset

func (m *CIDR) Reset()

func (*CIDR) String

func (m *CIDR) String() string

func (*CIDR) XXX_DiscardUnknown

func (m *CIDR) XXX_DiscardUnknown()

func (*CIDR) XXX_Marshal

func (m *CIDR) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CIDR) XXX_Merge

func (m *CIDR) XXX_Merge(src proto.Message)

func (*CIDR) XXX_Size

func (m *CIDR) XXX_Size() int

func (*CIDR) XXX_Unmarshal

func (m *CIDR) XXX_Unmarshal(b []byte) error

type CIDRList

type CIDRList []*CIDR

CIDRList is an alias of []*CIDR to provide sort.Interface.

func (*CIDRList) Len

func (l *CIDRList) Len() int

Len implements sort.Interface.

func (*CIDRList) Less

func (l *CIDRList) Less(i int, j int) bool

Less implements sort.Interface.

func (*CIDRList) Swap

func (l *CIDRList) Swap(i int, j int)

Swap implements sort.Interface.

type Condition

type Condition interface {
	Apply(ctx *Context) bool
}

type ConditionChan

type ConditionChan []Condition

func NewConditionChan

func NewConditionChan() *ConditionChan

func (*ConditionChan) Add

func (v *ConditionChan) Add(cond Condition) *ConditionChan

func (*ConditionChan) Apply

func (v *ConditionChan) Apply(ctx *Context) bool

func (*ConditionChan) Len

func (v *ConditionChan) Len() int

type Config

type Config struct {
	DomainStrategy       Config_DomainStrategy `` /* 153-byte string literal not displayed */
	Rule                 []*RoutingRule        `protobuf:"bytes,2,rep,name=rule,proto3" json:"rule,omitempty"`
	BalancingRule        []*BalancingRule      `protobuf:"bytes,3,rep,name=balancing_rule,json=balancingRule,proto3" json:"balancing_rule,omitempty"`
	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
	XXX_unrecognized     []byte                `json:"-"`
	XXX_sizecache        int32                 `json:"-"`
}

func (*Config) Descriptor

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetBalancingRule

func (m *Config) GetBalancingRule() []*BalancingRule

func (*Config) GetDomainStrategy

func (m *Config) GetDomainStrategy() Config_DomainStrategy

func (*Config) GetRule

func (m *Config) GetRule() []*RoutingRule

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (m *Config) Reset()

func (*Config) String

func (m *Config) String() string

func (*Config) XXX_DiscardUnknown

func (m *Config) XXX_DiscardUnknown()

func (*Config) XXX_Marshal

func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config) XXX_Merge

func (m *Config) XXX_Merge(src proto.Message)

func (*Config) XXX_Size

func (m *Config) XXX_Size() int

func (*Config) XXX_Unmarshal

func (m *Config) XXX_Unmarshal(b []byte) error

type Config_DomainStrategy

type Config_DomainStrategy int32
const (
	// Use domain as is.
	Config_AsIs Config_DomainStrategy = 0
	// Always resolve IP for domains.
	Config_UseIp Config_DomainStrategy = 1
	// Resolve to IP if the domain doesn't match any rules.
	Config_IpIfNonMatch Config_DomainStrategy = 2
	// Resolve to IP if any rule requires IP matching.
	Config_IpOnDemand Config_DomainStrategy = 3
)

func (Config_DomainStrategy) EnumDescriptor

func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int)

func (Config_DomainStrategy) String

func (x Config_DomainStrategy) String() string

type Context

type Context struct {
	Inbound  *session.Inbound
	Outbound *session.Outbound
	Content  *session.Content
	// contains filtered or unexported fields
}

func (*Context) GetTargetIPs

func (c *Context) GetTargetIPs() []net.IP

type CustomGeoIPMatcher

type CustomGeoIPMatcher struct {
	// contains filtered or unexported fields
}

func NewCustomGeoIPMatcher

func NewCustomGeoIPMatcher(geoipCodes []string, onSource bool) *CustomGeoIPMatcher

func (*CustomGeoIPMatcher) Apply

func (m *CustomGeoIPMatcher) Apply(ctx *Context) bool

type Domain

type Domain struct {
	// Domain matching type.
	Type Domain_Type `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.router.Domain_Type" json:"type,omitempty"`
	// Domain value.
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// Attributes of this domain. May be used for filtering.
	Attribute            []*Domain_Attribute `protobuf:"bytes,3,rep,name=attribute,proto3" json:"attribute,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

Domain for routing decision.

func (*Domain) Descriptor

func (*Domain) Descriptor() ([]byte, []int)

func (*Domain) GetAttribute

func (m *Domain) GetAttribute() []*Domain_Attribute

func (*Domain) GetType

func (m *Domain) GetType() Domain_Type

func (*Domain) GetValue

func (m *Domain) GetValue() string

func (*Domain) ProtoMessage

func (*Domain) ProtoMessage()

func (*Domain) Reset

func (m *Domain) Reset()

func (*Domain) String

func (m *Domain) String() string

func (*Domain) XXX_DiscardUnknown

func (m *Domain) XXX_DiscardUnknown()

func (*Domain) XXX_Marshal

func (m *Domain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Domain) XXX_Merge

func (m *Domain) XXX_Merge(src proto.Message)

func (*Domain) XXX_Size

func (m *Domain) XXX_Size() int

func (*Domain) XXX_Unmarshal

func (m *Domain) XXX_Unmarshal(b []byte) error

type DomainMatcher

type DomainMatcher struct {
	// contains filtered or unexported fields
}

func NewDomainMatcher

func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error)

func (*DomainMatcher) Apply

func (m *DomainMatcher) Apply(ctx *Context) bool

func (*DomainMatcher) ApplyDomain

func (m *DomainMatcher) ApplyDomain(domain string) bool

type Domain_Attribute

type Domain_Attribute struct {
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// Types that are valid to be assigned to TypedValue:
	//	*Domain_Attribute_BoolValue
	//	*Domain_Attribute_IntValue
	TypedValue           isDomain_Attribute_TypedValue `protobuf_oneof:"typed_value"`
	XXX_NoUnkeyedLiteral struct{}                      `json:"-"`
	XXX_unrecognized     []byte                        `json:"-"`
	XXX_sizecache        int32                         `json:"-"`
}

func (*Domain_Attribute) Descriptor

func (*Domain_Attribute) Descriptor() ([]byte, []int)

func (*Domain_Attribute) GetBoolValue

func (m *Domain_Attribute) GetBoolValue() bool

func (*Domain_Attribute) GetIntValue

func (m *Domain_Attribute) GetIntValue() int64

func (*Domain_Attribute) GetKey

func (m *Domain_Attribute) GetKey() string

func (*Domain_Attribute) GetTypedValue

func (m *Domain_Attribute) GetTypedValue() isDomain_Attribute_TypedValue

func (*Domain_Attribute) ProtoMessage

func (*Domain_Attribute) ProtoMessage()

func (*Domain_Attribute) Reset

func (m *Domain_Attribute) Reset()

func (*Domain_Attribute) String

func (m *Domain_Attribute) String() string

func (*Domain_Attribute) XXX_DiscardUnknown

func (m *Domain_Attribute) XXX_DiscardUnknown()

func (*Domain_Attribute) XXX_Marshal

func (m *Domain_Attribute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Domain_Attribute) XXX_Merge

func (m *Domain_Attribute) XXX_Merge(src proto.Message)

func (*Domain_Attribute) XXX_OneofWrappers

func (*Domain_Attribute) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*Domain_Attribute) XXX_Size

func (m *Domain_Attribute) XXX_Size() int

func (*Domain_Attribute) XXX_Unmarshal

func (m *Domain_Attribute) XXX_Unmarshal(b []byte) error

type Domain_Attribute_BoolValue

type Domain_Attribute_BoolValue struct {
	BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"`
}

type Domain_Attribute_IntValue

type Domain_Attribute_IntValue struct {
	IntValue int64 `protobuf:"varint,3,opt,name=int_value,json=intValue,proto3,oneof"`
}

type Domain_Type

type Domain_Type int32

Type of domain value.

const (
	// The value is used as is.
	Domain_Plain Domain_Type = 0
	// The value is used as a regular expression.
	Domain_Regex Domain_Type = 1
	// The value is a root domain.
	Domain_Domain Domain_Type = 2
	// The value is a domain.
	Domain_Full Domain_Type = 3
)

func (Domain_Type) EnumDescriptor

func (Domain_Type) EnumDescriptor() ([]byte, []int)

func (Domain_Type) String

func (x Domain_Type) String() string

type GeoIP

type GeoIP struct {
	CountryCode          string   `protobuf:"bytes,1,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"`
	Cidr                 []*CIDR  `protobuf:"bytes,2,rep,name=cidr,proto3" json:"cidr,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*GeoIP) Descriptor

func (*GeoIP) Descriptor() ([]byte, []int)

func (*GeoIP) GetCidr

func (m *GeoIP) GetCidr() []*CIDR

func (*GeoIP) GetCountryCode

func (m *GeoIP) GetCountryCode() string

func (*GeoIP) ProtoMessage

func (*GeoIP) ProtoMessage()

func (*GeoIP) Reset

func (m *GeoIP) Reset()

func (*GeoIP) String

func (m *GeoIP) String() string

func (*GeoIP) XXX_DiscardUnknown

func (m *GeoIP) XXX_DiscardUnknown()

func (*GeoIP) XXX_Marshal

func (m *GeoIP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GeoIP) XXX_Merge

func (m *GeoIP) XXX_Merge(src proto.Message)

func (*GeoIP) XXX_Size

func (m *GeoIP) XXX_Size() int

func (*GeoIP) XXX_Unmarshal

func (m *GeoIP) XXX_Unmarshal(b []byte) error

type GeoIPList

type GeoIPList struct {
	Entry                []*GeoIP `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*GeoIPList) Descriptor

func (*GeoIPList) Descriptor() ([]byte, []int)

func (*GeoIPList) GetEntry

func (m *GeoIPList) GetEntry() []*GeoIP

func (*GeoIPList) ProtoMessage

func (*GeoIPList) ProtoMessage()

func (*GeoIPList) Reset

func (m *GeoIPList) Reset()

func (*GeoIPList) String

func (m *GeoIPList) String() string

func (*GeoIPList) XXX_DiscardUnknown

func (m *GeoIPList) XXX_DiscardUnknown()

func (*GeoIPList) XXX_Marshal

func (m *GeoIPList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GeoIPList) XXX_Merge

func (m *GeoIPList) XXX_Merge(src proto.Message)

func (*GeoIPList) XXX_Size

func (m *GeoIPList) XXX_Size() int

func (*GeoIPList) XXX_Unmarshal

func (m *GeoIPList) XXX_Unmarshal(b []byte) error

type GeoIPMatcher

type GeoIPMatcher struct {
	// contains filtered or unexported fields
}

func (*GeoIPMatcher) Init

func (m *GeoIPMatcher) Init(cidrs []*CIDR) error

func (*GeoIPMatcher) Match

func (m *GeoIPMatcher) Match(ip net.IP) bool

Match returns true if the given ip is included by the GeoIP.

type GeoIPMatcherContainer

type GeoIPMatcherContainer struct {
	// contains filtered or unexported fields
}

GeoIPMatcherContainer is a container for GeoIPMatchers. It keeps unique copies of GeoIPMatcher by country code.

func (*GeoIPMatcherContainer) Add

func (c *GeoIPMatcherContainer) Add(geoip *GeoIP) (*GeoIPMatcher, error)

Add adds a new GeoIP set into the container. If the country code of GeoIP is not empty, GeoIPMatcherContainer will try to find an existing one, instead of adding a new one.

type GeoSite

type GeoSite struct {
	CountryCode          string    `protobuf:"bytes,1,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"`
	Domain               []*Domain `protobuf:"bytes,2,rep,name=domain,proto3" json:"domain,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*GeoSite) Descriptor

func (*GeoSite) Descriptor() ([]byte, []int)

func (*GeoSite) GetCountryCode

func (m *GeoSite) GetCountryCode() string

func (*GeoSite) GetDomain

func (m *GeoSite) GetDomain() []*Domain

func (*GeoSite) ProtoMessage

func (*GeoSite) ProtoMessage()

func (*GeoSite) Reset

func (m *GeoSite) Reset()

func (*GeoSite) String

func (m *GeoSite) String() string

func (*GeoSite) XXX_DiscardUnknown

func (m *GeoSite) XXX_DiscardUnknown()

func (*GeoSite) XXX_Marshal

func (m *GeoSite) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GeoSite) XXX_Merge

func (m *GeoSite) XXX_Merge(src proto.Message)

func (*GeoSite) XXX_Size

func (m *GeoSite) XXX_Size() int

func (*GeoSite) XXX_Unmarshal

func (m *GeoSite) XXX_Unmarshal(b []byte) error

type GeoSiteList

type GeoSiteList struct {
	Entry                []*GeoSite `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*GeoSiteList) Descriptor

func (*GeoSiteList) Descriptor() ([]byte, []int)

func (*GeoSiteList) GetEntry

func (m *GeoSiteList) GetEntry() []*GeoSite

func (*GeoSiteList) ProtoMessage

func (*GeoSiteList) ProtoMessage()

func (*GeoSiteList) Reset

func (m *GeoSiteList) Reset()

func (*GeoSiteList) String

func (m *GeoSiteList) String() string

func (*GeoSiteList) XXX_DiscardUnknown

func (m *GeoSiteList) XXX_DiscardUnknown()

func (*GeoSiteList) XXX_Marshal

func (m *GeoSiteList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GeoSiteList) XXX_Merge

func (m *GeoSiteList) XXX_Merge(src proto.Message)

func (*GeoSiteList) XXX_Size

func (m *GeoSiteList) XXX_Size() int

func (*GeoSiteList) XXX_Unmarshal

func (m *GeoSiteList) XXX_Unmarshal(b []byte) error

type InboundTagMatcher

type InboundTagMatcher struct {
	// contains filtered or unexported fields
}

func NewInboundTagMatcher

func NewInboundTagMatcher(tags []string) *InboundTagMatcher

func (*InboundTagMatcher) Apply

func (v *InboundTagMatcher) Apply(ctx *Context) bool

type LatencyStrategy

type LatencyStrategy struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*LatencyStrategy) PickOutbound

func (s *LatencyStrategy) PickOutbound(tags []string) string

type MultiGeoIPMatcher

type MultiGeoIPMatcher struct {
	// contains filtered or unexported fields
}

func NewMultiGeoIPMatcher

func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error)

func (*MultiGeoIPMatcher) Apply

func (m *MultiGeoIPMatcher) Apply(ctx *Context) bool

type NetworkMatcher

type NetworkMatcher struct {
	// contains filtered or unexported fields
}

func NewNetworkMatcher

func NewNetworkMatcher(network []net.Network) NetworkMatcher

func (NetworkMatcher) Apply

func (v NetworkMatcher) Apply(ctx *Context) bool

type PortMatcher

type PortMatcher struct {
	// contains filtered or unexported fields
}

func NewPortMatcher

func NewPortMatcher(list *net.PortList) *PortMatcher

func (*PortMatcher) Apply

func (v *PortMatcher) Apply(ctx *Context) bool

type ProtocolMatcher

type ProtocolMatcher struct {
	// contains filtered or unexported fields
}

func NewProtocolMatcher

func NewProtocolMatcher(protocols []string) *ProtocolMatcher

func (*ProtocolMatcher) Apply

func (m *ProtocolMatcher) Apply(ctx *Context) bool

type RandomStrategy

type RandomStrategy struct {
}

func (*RandomStrategy) PickOutbound

func (s *RandomStrategy) PickOutbound(tags []string) string

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is an implementation of routing.Router.

func (*Router) Close

func (*Router) Close() error

Close implements common.Closable.

func (*Router) Init

func (r *Router) Init(config *Config, d dns.Client, ohm outbound.Manager) error

Init initializes the Router.

func (*Router) PickRoute

func (r *Router) PickRoute(ctx context.Context) (string, error)

func (*Router) Start

func (*Router) Start() error

Start implements common.Runnable.

func (*Router) Type

func (*Router) Type() interface{}

Type implement common.HasType.

type RoutingRule

type RoutingRule struct {
	// Types that are valid to be assigned to TargetTag:
	//	*RoutingRule_Tag
	//	*RoutingRule_BalancingTag
	TargetTag isRoutingRule_TargetTag `protobuf_oneof:"target_tag"`
	// List of domains for target domain matching.
	Domain []*Domain `protobuf:"bytes,2,rep,name=domain,proto3" json:"domain,omitempty"`
	// List of CIDRs for target IP address matching.
	// Deprecated. Use geoip below.
	Cidr []*CIDR `protobuf:"bytes,3,rep,name=cidr,proto3" json:"cidr,omitempty"` // Deprecated: Do not use.
	// List of GeoIPs for target IP address matching. If this entry exists, the cidr above will have no effect.
	// GeoIP fields with the same country code are supposed to contain exactly same content. They will be merged during runtime.
	// For customized GeoIPs, please leave country code empty.
	Geoip []*GeoIP `protobuf:"bytes,10,rep,name=geoip,proto3" json:"geoip,omitempty"`
	// A range of port [from, to]. If the destination port is in this range, this rule takes effect.
	// Deprecated. Use port_list.
	PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"` // Deprecated: Do not use.
	// List of ports.
	PortList *net.PortList `protobuf:"bytes,14,opt,name=port_list,json=portList,proto3" json:"port_list,omitempty"`
	// List of networks. Deprecated. Use networks.
	NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // Deprecated: Do not use.
	// List of networks for matching.
	Networks []net.Network `protobuf:"varint,13,rep,packed,name=networks,proto3,enum=v2ray.core.common.net.Network" json:"networks,omitempty"`
	// List of CIDRs for source IP address matching.
	SourceCidr []*CIDR `protobuf:"bytes,6,rep,name=source_cidr,json=sourceCidr,proto3" json:"source_cidr,omitempty"` // Deprecated: Do not use.
	// List of GeoIPs for source IP address matching. If this entry exists, the source_cidr above will have no effect.
	SourceGeoip          []*GeoIP `protobuf:"bytes,11,rep,name=source_geoip,json=sourceGeoip,proto3" json:"source_geoip,omitempty"`
	CustomGeoip          []string `protobuf:"bytes,50,rep,name=custom_geoip,json=customGeoip,proto3" json:"custom_geoip,omitempty"`
	UserEmail            []string `protobuf:"bytes,7,rep,name=user_email,json=userEmail,proto3" json:"user_email,omitempty"`
	InboundTag           []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"`
	Protocol             []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"`
	Application          []string `protobuf:"bytes,51,rep,name=application,proto3" json:"application,omitempty"`
	Attributes           string   `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RoutingRule) BuildCondition

func (rr *RoutingRule) BuildCondition() (Condition, error)

func (*RoutingRule) Descriptor

func (*RoutingRule) Descriptor() ([]byte, []int)

func (*RoutingRule) GetApplication

func (m *RoutingRule) GetApplication() []string

func (*RoutingRule) GetAttributes

func (m *RoutingRule) GetAttributes() string

func (*RoutingRule) GetBalancingTag

func (m *RoutingRule) GetBalancingTag() string

func (*RoutingRule) GetCidr deprecated

func (m *RoutingRule) GetCidr() []*CIDR

Deprecated: Do not use.

func (*RoutingRule) GetCustomGeoip

func (m *RoutingRule) GetCustomGeoip() []string

func (*RoutingRule) GetDomain

func (m *RoutingRule) GetDomain() []*Domain

func (*RoutingRule) GetGeoip

func (m *RoutingRule) GetGeoip() []*GeoIP

func (*RoutingRule) GetInboundTag

func (m *RoutingRule) GetInboundTag() []string

func (*RoutingRule) GetNetworkList deprecated

func (m *RoutingRule) GetNetworkList() *net.NetworkList

Deprecated: Do not use.

func (*RoutingRule) GetNetworks

func (m *RoutingRule) GetNetworks() []net.Network

func (*RoutingRule) GetPortList

func (m *RoutingRule) GetPortList() *net.PortList

func (*RoutingRule) GetPortRange deprecated

func (m *RoutingRule) GetPortRange() *net.PortRange

Deprecated: Do not use.

func (*RoutingRule) GetProtocol

func (m *RoutingRule) GetProtocol() []string

func (*RoutingRule) GetSourceCidr deprecated

func (m *RoutingRule) GetSourceCidr() []*CIDR

Deprecated: Do not use.

func (*RoutingRule) GetSourceGeoip

func (m *RoutingRule) GetSourceGeoip() []*GeoIP

func (*RoutingRule) GetTag

func (m *RoutingRule) GetTag() string

func (*RoutingRule) GetTargetTag

func (m *RoutingRule) GetTargetTag() isRoutingRule_TargetTag

func (*RoutingRule) GetUserEmail

func (m *RoutingRule) GetUserEmail() []string

func (*RoutingRule) ProtoMessage

func (*RoutingRule) ProtoMessage()

func (*RoutingRule) Reset

func (m *RoutingRule) Reset()

func (*RoutingRule) String

func (m *RoutingRule) String() string

func (*RoutingRule) XXX_DiscardUnknown

func (m *RoutingRule) XXX_DiscardUnknown()

func (*RoutingRule) XXX_Marshal

func (m *RoutingRule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RoutingRule) XXX_Merge

func (m *RoutingRule) XXX_Merge(src proto.Message)

func (*RoutingRule) XXX_OneofWrappers

func (*RoutingRule) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*RoutingRule) XXX_Size

func (m *RoutingRule) XXX_Size() int

func (*RoutingRule) XXX_Unmarshal

func (m *RoutingRule) XXX_Unmarshal(b []byte) error

type RoutingRule_BalancingTag

type RoutingRule_BalancingTag struct {
	BalancingTag string `protobuf:"bytes,12,opt,name=balancing_tag,json=balancingTag,proto3,oneof"`
}

type RoutingRule_Tag

type RoutingRule_Tag struct {
	Tag string `protobuf:"bytes,1,opt,name=tag,proto3,oneof"`
}

type Rule

type Rule struct {
	Tag       string
	Balancer  *Balancer
	Condition Condition
}

func (*Rule) Apply

func (r *Rule) Apply(ctx *Context) bool

func (*Rule) GetTag

func (r *Rule) GetTag() (string, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

type UserMatcher

type UserMatcher struct {
	// contains filtered or unexported fields
}

func NewUserMatcher

func NewUserMatcher(users []string) *UserMatcher

func (*UserMatcher) Apply

func (v *UserMatcher) Apply(ctx *Context) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL