import "github.com/v2ray/v2ray-core/app/router"
balancing.go condition.go condition_geoip.go config.go config.pb.go errors.generated.go router.go
var ( Domain_Type_name = map[int32]string{ 0: "Plain", 1: "Regex", 2: "Domain", 3: "Full", } Domain_Type_value = map[string]int32{ "Plain": 0, "Regex": 1, "Domain": 2, "Full": 3, } )
Enum value maps for Domain_Type.
var ( Config_DomainStrategy_name = map[int32]string{ 0: "AsIs", 1: "UseIp", 2: "IpIfNonMatch", 3: "IpOnDemand", } Config_DomainStrategy_value = map[string]int32{ "AsIs": 0, "UseIp": 1, "IpIfNonMatch": 2, "IpOnDemand": 3, } )
Enum value maps for Config_DomainStrategy.
var File_app_router_config_proto protoreflect.FileDescriptor
type AttributeMatcher struct {
// contains filtered or unexported fields
}
func NewAttributeMatcher(code string) (*AttributeMatcher, error)
func (m *AttributeMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
func (m *AttributeMatcher) Match(attrs map[string]string) bool
Match implements attributes matching.
type Balancer struct {
// contains filtered or unexported fields
}
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"` // contains filtered or unexported fields }
func (*BalancingRule) Descriptor() ([]byte, []int)
Deprecated: Use BalancingRule.ProtoReflect.Descriptor instead.
func (x *BalancingRule) GetOutboundSelector() []string
func (x *BalancingRule) GetTag() string
func (*BalancingRule) ProtoMessage()
func (x *BalancingRule) ProtoReflect() protoreflect.Message
func (x *BalancingRule) Reset()
func (x *BalancingRule) String() string
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"` // contains filtered or unexported fields }
IP for routing decision, in CIDR form.
Deprecated: Use CIDR.ProtoReflect.Descriptor instead.
func (x *CIDR) ProtoReflect() protoreflect.Message
CIDRList is an alias of []*CIDR to provide sort.Interface.
Len implements sort.Interface.
Less implements sort.Interface.
Swap implements sort.Interface.
func NewConditionChan() *ConditionChan
func (v *ConditionChan) Add(cond Condition) *ConditionChan
func (v *ConditionChan) Apply(ctx routing.Context) bool
Apply applies all conditions registered in this chan.
func (v *ConditionChan) Len() int
type Config struct { DomainStrategy Config_DomainStrategy `protobuf:"varint,1,opt,name=domain_strategy,json=domainStrategy,proto3,enum=v2ray.core.app.router.Config_DomainStrategy" json:"domain_strategy,omitempty"` 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"` // contains filtered or unexported fields }
Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (x *Config) GetBalancingRule() []*BalancingRule
func (x *Config) GetDomainStrategy() Config_DomainStrategy
func (x *Config) GetRule() []*RoutingRule
func (x *Config) ProtoReflect() protoreflect.Message
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) Descriptor() protoreflect.EnumDescriptor
func (x Config_DomainStrategy) Enum() *Config_DomainStrategy
func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int)
Deprecated: Use Config_DomainStrategy.Descriptor instead.
func (x Config_DomainStrategy) Number() protoreflect.EnumNumber
func (x Config_DomainStrategy) String() string
func (Config_DomainStrategy) Type() protoreflect.EnumType
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"` // contains filtered or unexported fields }
Domain for routing decision.
Deprecated: Use Domain.ProtoReflect.Descriptor instead.
func (x *Domain) GetAttribute() []*Domain_Attribute
func (x *Domain) GetType() Domain_Type
func (x *Domain) ProtoReflect() protoreflect.Message
type DomainMatcher struct {
// contains filtered or unexported fields
}
func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error)
func (m *DomainMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
func (m *DomainMatcher) ApplyDomain(domain string) bool
type Domain_Attribute struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // Types that are assignable to TypedValue: // *Domain_Attribute_BoolValue // *Domain_Attribute_IntValue TypedValue isDomain_Attribute_TypedValue `protobuf_oneof:"typed_value"` // contains filtered or unexported fields }
func (*Domain_Attribute) Descriptor() ([]byte, []int)
Deprecated: Use Domain_Attribute.ProtoReflect.Descriptor instead.
func (x *Domain_Attribute) GetBoolValue() bool
func (x *Domain_Attribute) GetIntValue() int64
func (x *Domain_Attribute) GetKey() string
func (m *Domain_Attribute) GetTypedValue() isDomain_Attribute_TypedValue
func (*Domain_Attribute) ProtoMessage()
func (x *Domain_Attribute) ProtoReflect() protoreflect.Message
func (x *Domain_Attribute) Reset()
func (x *Domain_Attribute) String() string
type Domain_Attribute_BoolValue struct { BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"` }
type Domain_Attribute_IntValue struct { IntValue int64 `protobuf:"varint,3,opt,name=int_value,json=intValue,proto3,oneof"` }
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) Descriptor() protoreflect.EnumDescriptor
func (x Domain_Type) Enum() *Domain_Type
func (Domain_Type) EnumDescriptor() ([]byte, []int)
Deprecated: Use Domain_Type.Descriptor instead.
func (x Domain_Type) Number() protoreflect.EnumNumber
func (x Domain_Type) String() string
func (Domain_Type) Type() protoreflect.EnumType
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"` // contains filtered or unexported fields }
Deprecated: Use GeoIP.ProtoReflect.Descriptor instead.
func (x *GeoIP) ProtoReflect() protoreflect.Message
type GeoIPList struct { Entry []*GeoIP `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"` // contains filtered or unexported fields }
Deprecated: Use GeoIPList.ProtoReflect.Descriptor instead.
func (x *GeoIPList) ProtoReflect() protoreflect.Message
type GeoIPMatcher struct {
// contains filtered or unexported fields
}
func (m *GeoIPMatcher) Init(cidrs []*CIDR) error
func (m *GeoIPMatcher) Match(ip net.IP) bool
Match returns true if the given ip is included by the GeoIP.
type GeoIPMatcherContainer struct {
// contains filtered or unexported fields
}
GeoIPMatcherContainer is a container for GeoIPMatchers. It keeps unique copies of GeoIPMatcher by country code.
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 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"` // contains filtered or unexported fields }
Deprecated: Use GeoSite.ProtoReflect.Descriptor instead.
func (x *GeoSite) ProtoReflect() protoreflect.Message
type GeoSiteList struct { Entry []*GeoSite `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"` // contains filtered or unexported fields }
func (*GeoSiteList) Descriptor() ([]byte, []int)
Deprecated: Use GeoSiteList.ProtoReflect.Descriptor instead.
func (x *GeoSiteList) GetEntry() []*GeoSite
func (*GeoSiteList) ProtoMessage()
func (x *GeoSiteList) ProtoReflect() protoreflect.Message
func (x *GeoSiteList) Reset()
func (x *GeoSiteList) String() string
type InboundTagMatcher struct {
// contains filtered or unexported fields
}
func NewInboundTagMatcher(tags []string) *InboundTagMatcher
func (v *InboundTagMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
type MultiGeoIPMatcher struct {
// contains filtered or unexported fields
}
func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error)
func (m *MultiGeoIPMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
type NetworkMatcher struct {
// contains filtered or unexported fields
}
func NewNetworkMatcher(network []net.Network) NetworkMatcher
func (v NetworkMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
type PortMatcher struct {
// contains filtered or unexported fields
}
func NewPortMatcher(list *net.PortList, onSource bool) *PortMatcher
NewPortMatcher create a new port matcher that can match source or destination port
func (v *PortMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
type ProtocolMatcher struct {
// contains filtered or unexported fields
}
func NewProtocolMatcher(protocols []string) *ProtocolMatcher
func (m *ProtocolMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
type RandomStrategy struct { }
func (s *RandomStrategy) PickOutbound(tags []string) string
Route is an implementation of routing.Route.
GetOutboundGroupTags implements routing.Route.
GetOutboundTag implements routing.Route.
type Router struct {
// contains filtered or unexported fields
}
Router is an implementation of routing.Router.
Close implements common.Closable.
Init initializes the Router.
PickRoute implements routing.Router.
Start implements common.Runnable.
Type implement common.HasType.
type RoutingRule struct { // Types that are assignable 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. // // Deprecated: Do not use. Cidr []*CIDR `protobuf:"bytes,3,rep,name=cidr,proto3" json:"cidr,omitempty"` // 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. // // Deprecated: Do not use. PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"` // 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. // // Deprecated: Do not use. NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // 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. // // Deprecated: Do not use. SourceCidr []*CIDR `protobuf:"bytes,6,rep,name=source_cidr,json=sourceCidr,proto3" json:"source_cidr,omitempty"` // 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"` // List of ports for source port matching. SourcePortList *net.PortList `protobuf:"bytes,16,opt,name=source_port_list,json=sourcePortList,proto3" json:"source_port_list,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"` Attributes string `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"` // contains filtered or unexported fields }
func (rr *RoutingRule) BuildCondition() (Condition, error)
func (*RoutingRule) Descriptor() ([]byte, []int)
Deprecated: Use RoutingRule.ProtoReflect.Descriptor instead.
func (x *RoutingRule) GetAttributes() string
func (x *RoutingRule) GetBalancingTag() string
func (x *RoutingRule) GetCidr() []*CIDR
Deprecated: Do not use.
func (x *RoutingRule) GetDomain() []*Domain
func (x *RoutingRule) GetGeoip() []*GeoIP
func (x *RoutingRule) GetInboundTag() []string
func (x *RoutingRule) GetNetworkList() *net.NetworkList
Deprecated: Do not use.
func (x *RoutingRule) GetNetworks() []net.Network
func (x *RoutingRule) GetPortList() *net.PortList
func (x *RoutingRule) GetPortRange() *net.PortRange
Deprecated: Do not use.
func (x *RoutingRule) GetProtocol() []string
func (x *RoutingRule) GetSourceCidr() []*CIDR
Deprecated: Do not use.
func (x *RoutingRule) GetSourceGeoip() []*GeoIP
func (x *RoutingRule) GetSourcePortList() *net.PortList
func (x *RoutingRule) GetTag() string
func (m *RoutingRule) GetTargetTag() isRoutingRule_TargetTag
func (x *RoutingRule) GetUserEmail() []string
func (*RoutingRule) ProtoMessage()
func (x *RoutingRule) ProtoReflect() protoreflect.Message
func (x *RoutingRule) Reset()
func (x *RoutingRule) String() string
type RoutingRule_BalancingTag struct { // Tag of routing balancer. BalancingTag string `protobuf:"bytes,12,opt,name=balancing_tag,json=balancingTag,proto3,oneof"` }
type RoutingRule_Tag struct { // Tag of outbound that this rule is pointing to. Tag string `protobuf:"bytes,1,opt,name=tag,proto3,oneof"` }
Apply checks rule matching of current routing context.
type UserMatcher struct {
// contains filtered or unexported fields
}
func NewUserMatcher(users []string) *UserMatcher
func (v *UserMatcher) Apply(ctx routing.Context) bool
Apply implements Condition.
Path | Synopsis |
---|---|
command |
Package router imports 21 packages (graph) and is imported by 7 packages. Updated 2020-10-31. Refresh now. Tools for package owners.