router

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DomainStrategy_name = map[int32]string{
		0: "AsIs",
		1: "UseIp",
		2: "IpIfNonMatch",
		3: "IpOnDemand",
	}
	DomainStrategy_value = map[string]int32{
		"AsIs":         0,
		"UseIp":        1,
		"IpIfNonMatch": 2,
		"IpOnDemand":   3,
	}
)

Enum value maps for DomainStrategy.

View Source
var File_app_router_config_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AttributeMatcher added in v1.1.0

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

func NewAttributeMatcher added in v1.1.0

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

func (*AttributeMatcher) Apply added in v1.1.0

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

Apply implements Condition.

func (*AttributeMatcher) Match added in v1.1.0

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

Match implements attributes matching.

type Balancer added in v1.1.0

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

func (*Balancer) InjectContext added in v1.1.0

func (b *Balancer) InjectContext(ctx context.Context)

func (*Balancer) PickOutbound added in v1.1.0

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

PickOutbound picks the tag of an outbound

func (*Balancer) SelectOutbounds added in v1.1.0

func (b *Balancer) SelectOutbounds() ([]string, error)

SelectOutbounds select outbounds with selectors of the Balancer

type BalancingPrincipleTarget added in v1.1.0

type BalancingPrincipleTarget interface {
	GetPrincipleTarget([]string) []string
}

type BalancingRule added in v1.1.0

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"`
	Strategy         string     `protobuf:"bytes,3,opt,name=strategy,proto3" json:"strategy,omitempty"`
	StrategySettings *anypb.Any `protobuf:"bytes,4,opt,name=strategy_settings,json=strategySettings,proto3" json:"strategy_settings,omitempty"`
	FallbackTag      string     `protobuf:"bytes,5,opt,name=fallback_tag,json=fallbackTag,proto3" json:"fallback_tag,omitempty"`
	// contains filtered or unexported fields
}

func (*BalancingRule) Build added in v1.1.0

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

Build builds the balancing rule

func (*BalancingRule) Descriptor deprecated added in v1.1.0

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

Deprecated: Use BalancingRule.ProtoReflect.Descriptor instead.

func (*BalancingRule) GetFallbackTag added in v1.1.0

func (x *BalancingRule) GetFallbackTag() string

func (*BalancingRule) GetOutboundSelector added in v1.1.0

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

func (*BalancingRule) GetStrategy added in v1.1.0

func (x *BalancingRule) GetStrategy() string

func (*BalancingRule) GetStrategySettings added in v1.1.0

func (x *BalancingRule) GetStrategySettings() *anypb.Any

func (*BalancingRule) GetTag added in v1.1.0

func (x *BalancingRule) GetTag() string

func (*BalancingRule) ProtoMessage added in v1.1.0

func (*BalancingRule) ProtoMessage()

func (*BalancingRule) ProtoReflect added in v1.1.0

func (x *BalancingRule) ProtoReflect() protoreflect.Message

func (*BalancingRule) Reset added in v1.1.0

func (x *BalancingRule) Reset()

func (*BalancingRule) String added in v1.1.0

func (x *BalancingRule) String() string

func (*BalancingRule) UnmarshalJSONPB added in v1.1.0

func (br *BalancingRule) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error

type BalancingStrategy added in v1.1.0

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

type Condition added in v1.1.0

type Condition interface {
	Apply(ctx routing.Context) bool
}

type ConditionChan added in v1.1.0

type ConditionChan []Condition

func NewConditionChan added in v1.1.0

func NewConditionChan() *ConditionChan

func (*ConditionChan) Add added in v1.1.0

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

func (*ConditionChan) Apply added in v1.1.0

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

Apply applies all conditions registered in this chan.

func (*ConditionChan) Len added in v1.1.0

func (v *ConditionChan) Len() int

type Config added in v1.1.0

type Config struct {
	DomainStrategy DomainStrategy   `` /* 146-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"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated added in v1.1.0

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

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetBalancingRule added in v1.1.0

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

func (*Config) GetDomainStrategy added in v1.1.0

func (x *Config) GetDomainStrategy() DomainStrategy

func (*Config) GetRule added in v1.1.0

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

func (*Config) ProtoMessage added in v1.1.0

func (*Config) ProtoMessage()

func (*Config) ProtoReflect added in v1.1.0

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset added in v1.1.0

func (x *Config) Reset()

func (*Config) String added in v1.1.0

func (x *Config) String() string

type DomainMatcher added in v1.1.0

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

func NewDomainMatcher added in v1.1.0

func NewDomainMatcher(matcherType string, domains []*routercommon.Domain) (*DomainMatcher, error)

func (*DomainMatcher) Apply added in v1.1.0

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

Apply implements Condition.

func (*DomainMatcher) Match added in v1.1.0

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

type DomainStrategy added in v1.1.0

type DomainStrategy int32
const (
	// Use domain as is.
	DomainStrategy_AsIs DomainStrategy = 0
	// Always resolve IP for domains.
	DomainStrategy_UseIp DomainStrategy = 1
	// Resolve to IP if the domain doesn't match any rules.
	DomainStrategy_IpIfNonMatch DomainStrategy = 2
	// Resolve to IP if any rule requires IP matching.
	DomainStrategy_IpOnDemand DomainStrategy = 3
)

func (DomainStrategy) Descriptor added in v1.1.0

func (DomainStrategy) Enum added in v1.1.0

func (x DomainStrategy) Enum() *DomainStrategy

func (DomainStrategy) EnumDescriptor deprecated added in v1.1.0

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

Deprecated: Use DomainStrategy.Descriptor instead.

func (DomainStrategy) Number added in v1.1.0

func (DomainStrategy) String added in v1.1.0

func (x DomainStrategy) String() string

func (DomainStrategy) Type added in v1.1.0

type GeoIPMatcher added in v1.1.0

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

func (*GeoIPMatcher) Init added in v1.1.0

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

func (*GeoIPMatcher) Match added in v1.1.0

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

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

func (*GeoIPMatcher) SetReverseMatch added in v1.1.0

func (m *GeoIPMatcher) SetReverseMatch(isReverseMatch bool)

type GeoIPMatcherContainer added in v1.1.0

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 added in v1.1.0

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 InboundTagMatcher added in v1.1.0

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

func NewInboundTagMatcher added in v1.1.0

func NewInboundTagMatcher(tags []string) *InboundTagMatcher

func (*InboundTagMatcher) Apply added in v1.1.0

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

Apply implements Condition.

type LeastLoadStrategy added in v1.1.0

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

LeastLoadStrategy represents a least load balancing strategy

func NewLeastLoadStrategy added in v1.1.0

func NewLeastLoadStrategy(settings *StrategyLeastLoadConfig) *LeastLoadStrategy

NewLeastLoadStrategy creates a new LeastLoadStrategy with settings

func (*LeastLoadStrategy) GetPrincipleTarget added in v1.1.0

func (l *LeastLoadStrategy) GetPrincipleTarget(strings []string) []string

func (*LeastLoadStrategy) InjectContext added in v1.1.0

func (l *LeastLoadStrategy) InjectContext(ctx context.Context)

func (*LeastLoadStrategy) PickOutbound added in v1.1.0

func (l *LeastLoadStrategy) PickOutbound(candidates []string) string

type LeastPingStrategy added in v1.1.0

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

func (*LeastPingStrategy) GetPrincipleTarget added in v1.1.0

func (l *LeastPingStrategy) GetPrincipleTarget(strings []string) []string

func (*LeastPingStrategy) InjectContext added in v1.1.0

func (l *LeastPingStrategy) InjectContext(ctx context.Context)

func (*LeastPingStrategy) PickOutbound added in v1.1.0

func (l *LeastPingStrategy) PickOutbound(strings []string) string

type MultiGeoIPMatcher added in v1.1.0

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

func NewMultiGeoIPMatcher added in v1.1.0

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

func (*MultiGeoIPMatcher) Apply added in v1.1.0

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

Apply implements Condition.

type NetworkMatcher added in v1.1.0

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

func NewNetworkMatcher added in v1.1.0

func NewNetworkMatcher(network []net.Network) NetworkMatcher

func (NetworkMatcher) Apply added in v1.1.0

func (v NetworkMatcher) Apply(ctx routing.Context) bool

Apply implements Condition.

type PortMatcher added in v1.1.0

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

func NewPortMatcher added in v1.1.0

func NewPortMatcher(list *net.PortList, onSource bool) *PortMatcher

NewPortMatcher creates a new port matcher that can match source or destination port

func (*PortMatcher) Apply added in v1.1.0

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

Apply implements Condition.

type ProtocolMatcher added in v1.1.0

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

func NewProtocolMatcher added in v1.1.0

func NewProtocolMatcher(protocols []string) *ProtocolMatcher

func (*ProtocolMatcher) Apply added in v1.1.0

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

Apply implements Condition.

type RandomStrategy added in v1.1.0

type RandomStrategy struct{}

RandomStrategy represents a random balancing strategy

func (*RandomStrategy) GetPrincipleTarget added in v1.1.0

func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string

func (*RandomStrategy) PickOutbound added in v1.1.0

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

type Route added in v1.1.0

type Route struct {
	routing.Context
	// contains filtered or unexported fields
}

Route is an implementation of routing.Route.

func (*Route) GetOutboundGroupTags added in v1.1.0

func (r *Route) GetOutboundGroupTags() []string

GetOutboundGroupTags implements routing.Route.

func (*Route) GetOutboundTag added in v1.1.0

func (r *Route) GetOutboundTag() string

GetOutboundTag implements routing.Route.

type Router

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

Router is an implementation of routing.Router.

func (*Router) Close added in v1.1.0

func (r *Router) Close() error

Close implements common.Closable.

func (*Router) GetOverrideTarget added in v1.1.0

func (r *Router) GetOverrideTarget(tag string) (string, error)

GetOverrideTarget implements routing.BalancerOverrider

func (*Router) GetPrincipleTarget added in v1.1.0

func (r *Router) GetPrincipleTarget(tag string) ([]string, error)

GetPrincipleTarget implements routing.BalancerPrincipleTarget

func (*Router) Init added in v1.1.0

func (r *Router) Init(ctx context.Context, config *Config, d dns.Client, ohm outbound.Manager, dispatcher routing.Dispatcher) error

Init initializes the Router.

func (*Router) OverrideBalancer added in v1.1.0

func (r *Router) OverrideBalancer(balancer string, target string) error

func (*Router) PickRoute added in v1.1.0

func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error)

PickRoute implements routing.Router.

func (*Router) SetOverrideTarget added in v1.1.0

func (r *Router) SetOverrideTarget(tag, target string) error

SetOverrideTarget implements routing.BalancerOverrider

func (*Router) Start added in v1.1.0

func (r *Router) Start() error

Start implements common.Runnable.

func (*Router) Type added in v1.1.0

func (*Router) Type() interface{}

Type implements common.HasType.

type RoutingRule added in v1.1.0

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 []*routercommon.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 []*routercommon.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 []*routercommon.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 []*routercommon.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 []*routercommon.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"`
	DomainMatcher  string        `protobuf:"bytes,17,opt,name=domain_matcher,json=domainMatcher,proto3" json:"domain_matcher,omitempty"`
	// geo_domain instruct simplified config loader to load geo domain rule and fill in domain field.
	GeoDomain []*routercommon.GeoSite `protobuf:"bytes,68001,rep,name=geo_domain,json=geoDomain,proto3" json:"geo_domain,omitempty"`
	// contains filtered or unexported fields
}

func (*RoutingRule) BuildCondition added in v1.1.0

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

func (*RoutingRule) Descriptor deprecated added in v1.1.0

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

Deprecated: Use RoutingRule.ProtoReflect.Descriptor instead.

func (*RoutingRule) GetAttributes added in v1.1.0

func (x *RoutingRule) GetAttributes() string

func (*RoutingRule) GetBalancingTag added in v1.1.0

func (x *RoutingRule) GetBalancingTag() string

func (*RoutingRule) GetCidr deprecated added in v1.1.0

func (x *RoutingRule) GetCidr() []*routercommon.CIDR

Deprecated: Do not use.

func (*RoutingRule) GetDomain added in v1.1.0

func (x *RoutingRule) GetDomain() []*routercommon.Domain

func (*RoutingRule) GetDomainMatcher added in v1.1.0

func (x *RoutingRule) GetDomainMatcher() string

func (*RoutingRule) GetGeoDomain added in v1.1.0

func (x *RoutingRule) GetGeoDomain() []*routercommon.GeoSite

func (*RoutingRule) GetGeoip added in v1.1.0

func (x *RoutingRule) GetGeoip() []*routercommon.GeoIP

func (*RoutingRule) GetInboundTag added in v1.1.0

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

func (*RoutingRule) GetNetworkList deprecated added in v1.1.0

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

Deprecated: Do not use.

func (*RoutingRule) GetNetworks added in v1.1.0

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

func (*RoutingRule) GetPortList added in v1.1.0

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

func (*RoutingRule) GetPortRange deprecated added in v1.1.0

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

Deprecated: Do not use.

func (*RoutingRule) GetProtocol added in v1.1.0

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

func (*RoutingRule) GetSourceCidr deprecated added in v1.1.0

func (x *RoutingRule) GetSourceCidr() []*routercommon.CIDR

Deprecated: Do not use.

func (*RoutingRule) GetSourceGeoip added in v1.1.0

func (x *RoutingRule) GetSourceGeoip() []*routercommon.GeoIP

func (*RoutingRule) GetSourcePortList added in v1.1.0

func (x *RoutingRule) GetSourcePortList() *net.PortList

func (*RoutingRule) GetTag added in v1.1.0

func (x *RoutingRule) GetTag() string

func (*RoutingRule) GetTargetTag added in v1.1.0

func (m *RoutingRule) GetTargetTag() isRoutingRule_TargetTag

func (*RoutingRule) GetUserEmail added in v1.1.0

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

func (*RoutingRule) ProtoMessage added in v1.1.0

func (*RoutingRule) ProtoMessage()

func (*RoutingRule) ProtoReflect added in v1.1.0

func (x *RoutingRule) ProtoReflect() protoreflect.Message

func (*RoutingRule) Reset added in v1.1.0

func (x *RoutingRule) Reset()

func (*RoutingRule) String added in v1.1.0

func (x *RoutingRule) String() string

type RoutingRule_BalancingTag added in v1.1.0

type RoutingRule_BalancingTag struct {
	// Tag of routing balancer.
	BalancingTag string `protobuf:"bytes,12,opt,name=balancing_tag,json=balancingTag,proto3,oneof"`
}

type RoutingRule_Tag added in v1.1.0

type RoutingRule_Tag struct {
	// Tag of outbound that this rule is pointing to.
	Tag string `protobuf:"bytes,1,opt,name=tag,proto3,oneof"`
}

type Rule added in v1.1.0

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

func (*Rule) Apply added in v1.1.0

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

Apply checks rule matching of current routing context.

func (*Rule) GetTag added in v1.1.0

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

type SimplifiedConfig added in v1.1.0

type SimplifiedConfig struct {
	DomainStrategy DomainStrategy           `` /* 146-byte string literal not displayed */
	Rule           []*SimplifiedRoutingRule `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
}

func (*SimplifiedConfig) Descriptor deprecated added in v1.1.0

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

Deprecated: Use SimplifiedConfig.ProtoReflect.Descriptor instead.

func (*SimplifiedConfig) GetBalancingRule added in v1.1.0

func (x *SimplifiedConfig) GetBalancingRule() []*BalancingRule

func (*SimplifiedConfig) GetDomainStrategy added in v1.1.0

func (x *SimplifiedConfig) GetDomainStrategy() DomainStrategy

func (*SimplifiedConfig) GetRule added in v1.1.0

func (x *SimplifiedConfig) GetRule() []*SimplifiedRoutingRule

func (*SimplifiedConfig) ProtoMessage added in v1.1.0

func (*SimplifiedConfig) ProtoMessage()

func (*SimplifiedConfig) ProtoReflect added in v1.1.0

func (x *SimplifiedConfig) ProtoReflect() protoreflect.Message

func (*SimplifiedConfig) Reset added in v1.1.0

func (x *SimplifiedConfig) Reset()

func (*SimplifiedConfig) String added in v1.1.0

func (x *SimplifiedConfig) String() string

type SimplifiedRoutingRule added in v1.1.0

type SimplifiedRoutingRule struct {

	// Types that are assignable to TargetTag:
	//
	//	*SimplifiedRoutingRule_Tag
	//	*SimplifiedRoutingRule_BalancingTag
	TargetTag isSimplifiedRoutingRule_TargetTag `protobuf_oneof:"target_tag"`
	// List of domains for target domain matching.
	Domain []*routercommon.Domain `protobuf:"bytes,2,rep,name=domain,proto3" json:"domain,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 []*routercommon.GeoIP `protobuf:"bytes,10,rep,name=geoip,proto3" json:"geoip,omitempty"`
	// List of ports.
	PortList string `protobuf:"bytes,14,opt,name=port_list,json=portList,proto3" json:"port_list,omitempty"`
	// List of networks for matching.
	Networks *net.NetworkList `protobuf:"bytes,13,opt,name=networks,proto3" json:"networks,omitempty"`
	// List of GeoIPs for source IP address matching. If this entry exists, the
	// source_cidr above will have no effect.
	SourceGeoip []*routercommon.GeoIP `protobuf:"bytes,11,rep,name=source_geoip,json=sourceGeoip,proto3" json:"source_geoip,omitempty"`
	// List of ports for source port matching.
	SourcePortList string   `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"`
	DomainMatcher  string   `protobuf:"bytes,17,opt,name=domain_matcher,json=domainMatcher,proto3" json:"domain_matcher,omitempty"`
	// geo_domain instruct simplified config loader to load geo domain rule and fill in domain field.
	GeoDomain []*routercommon.GeoSite `protobuf:"bytes,68001,rep,name=geo_domain,json=geoDomain,proto3" json:"geo_domain,omitempty"`
	// contains filtered or unexported fields
}

func (*SimplifiedRoutingRule) Descriptor deprecated added in v1.1.0

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

Deprecated: Use SimplifiedRoutingRule.ProtoReflect.Descriptor instead.

func (*SimplifiedRoutingRule) GetAttributes added in v1.1.0

func (x *SimplifiedRoutingRule) GetAttributes() string

func (*SimplifiedRoutingRule) GetBalancingTag added in v1.1.0

func (x *SimplifiedRoutingRule) GetBalancingTag() string

func (*SimplifiedRoutingRule) GetDomain added in v1.1.0

func (x *SimplifiedRoutingRule) GetDomain() []*routercommon.Domain

func (*SimplifiedRoutingRule) GetDomainMatcher added in v1.1.0

func (x *SimplifiedRoutingRule) GetDomainMatcher() string

func (*SimplifiedRoutingRule) GetGeoDomain added in v1.1.0

func (x *SimplifiedRoutingRule) GetGeoDomain() []*routercommon.GeoSite

func (*SimplifiedRoutingRule) GetGeoip added in v1.1.0

func (x *SimplifiedRoutingRule) GetGeoip() []*routercommon.GeoIP

func (*SimplifiedRoutingRule) GetInboundTag added in v1.1.0

func (x *SimplifiedRoutingRule) GetInboundTag() []string

func (*SimplifiedRoutingRule) GetNetworks added in v1.1.0

func (x *SimplifiedRoutingRule) GetNetworks() *net.NetworkList

func (*SimplifiedRoutingRule) GetPortList added in v1.1.0

func (x *SimplifiedRoutingRule) GetPortList() string

func (*SimplifiedRoutingRule) GetProtocol added in v1.1.0

func (x *SimplifiedRoutingRule) GetProtocol() []string

func (*SimplifiedRoutingRule) GetSourceGeoip added in v1.1.0

func (x *SimplifiedRoutingRule) GetSourceGeoip() []*routercommon.GeoIP

func (*SimplifiedRoutingRule) GetSourcePortList added in v1.1.0

func (x *SimplifiedRoutingRule) GetSourcePortList() string

func (*SimplifiedRoutingRule) GetTag added in v1.1.0

func (x *SimplifiedRoutingRule) GetTag() string

func (*SimplifiedRoutingRule) GetTargetTag added in v1.1.0

func (m *SimplifiedRoutingRule) GetTargetTag() isSimplifiedRoutingRule_TargetTag

func (*SimplifiedRoutingRule) GetUserEmail added in v1.1.0

func (x *SimplifiedRoutingRule) GetUserEmail() []string

func (*SimplifiedRoutingRule) ProtoMessage added in v1.1.0

func (*SimplifiedRoutingRule) ProtoMessage()

func (*SimplifiedRoutingRule) ProtoReflect added in v1.1.0

func (x *SimplifiedRoutingRule) ProtoReflect() protoreflect.Message

func (*SimplifiedRoutingRule) Reset added in v1.1.0

func (x *SimplifiedRoutingRule) Reset()

func (*SimplifiedRoutingRule) String added in v1.1.0

func (x *SimplifiedRoutingRule) String() string

type SimplifiedRoutingRule_BalancingTag added in v1.1.0

type SimplifiedRoutingRule_BalancingTag struct {
	// Tag of routing balancer.
	BalancingTag string `protobuf:"bytes,12,opt,name=balancing_tag,json=balancingTag,proto3,oneof"`
}

type SimplifiedRoutingRule_Tag added in v1.1.0

type SimplifiedRoutingRule_Tag struct {
	// Tag of outbound that this rule is pointing to.
	Tag string `protobuf:"bytes,1,opt,name=tag,proto3,oneof"`
}

type StrategyLeastLoadConfig added in v1.1.0

type StrategyLeastLoadConfig struct {

	// weight settings
	Costs []*StrategyWeight `protobuf:"bytes,2,rep,name=costs,proto3" json:"costs,omitempty"`
	// RTT baselines for selecting, int64 values of time.Duration
	Baselines []int64 `protobuf:"varint,3,rep,packed,name=baselines,proto3" json:"baselines,omitempty"`
	// expected nodes count to select
	Expected int32 `protobuf:"varint,4,opt,name=expected,proto3" json:"expected,omitempty"`
	// max acceptable rtt, filter away high delay nodes. defalut 0
	MaxRTT int64 `protobuf:"varint,5,opt,name=maxRTT,proto3" json:"maxRTT,omitempty"`
	// acceptable failure rate
	Tolerance   float32 `protobuf:"fixed32,6,opt,name=tolerance,proto3" json:"tolerance,omitempty"`
	ObserverTag string  `protobuf:"bytes,7,opt,name=observer_tag,json=observerTag,proto3" json:"observer_tag,omitempty"`
	// contains filtered or unexported fields
}

func (*StrategyLeastLoadConfig) Descriptor deprecated added in v1.1.0

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

Deprecated: Use StrategyLeastLoadConfig.ProtoReflect.Descriptor instead.

func (*StrategyLeastLoadConfig) GetBaselines added in v1.1.0

func (x *StrategyLeastLoadConfig) GetBaselines() []int64

func (*StrategyLeastLoadConfig) GetCosts added in v1.1.0

func (x *StrategyLeastLoadConfig) GetCosts() []*StrategyWeight

func (*StrategyLeastLoadConfig) GetExpected added in v1.1.0

func (x *StrategyLeastLoadConfig) GetExpected() int32

func (*StrategyLeastLoadConfig) GetMaxRTT added in v1.1.0

func (x *StrategyLeastLoadConfig) GetMaxRTT() int64

func (*StrategyLeastLoadConfig) GetObserverTag added in v1.1.0

func (x *StrategyLeastLoadConfig) GetObserverTag() string

func (*StrategyLeastLoadConfig) GetTolerance added in v1.1.0

func (x *StrategyLeastLoadConfig) GetTolerance() float32

func (*StrategyLeastLoadConfig) ProtoMessage added in v1.1.0

func (*StrategyLeastLoadConfig) ProtoMessage()

func (*StrategyLeastLoadConfig) ProtoReflect added in v1.1.0

func (x *StrategyLeastLoadConfig) ProtoReflect() protoreflect.Message

func (*StrategyLeastLoadConfig) Reset added in v1.1.0

func (x *StrategyLeastLoadConfig) Reset()

func (*StrategyLeastLoadConfig) String added in v1.1.0

func (x *StrategyLeastLoadConfig) String() string

type StrategyLeastPingConfig added in v1.1.0

type StrategyLeastPingConfig struct {
	ObserverTag string `protobuf:"bytes,7,opt,name=observer_tag,json=observerTag,proto3" json:"observer_tag,omitempty"`
	// contains filtered or unexported fields
}

func (*StrategyLeastPingConfig) Descriptor deprecated added in v1.1.0

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

Deprecated: Use StrategyLeastPingConfig.ProtoReflect.Descriptor instead.

func (*StrategyLeastPingConfig) GetObserverTag added in v1.1.0

func (x *StrategyLeastPingConfig) GetObserverTag() string

func (*StrategyLeastPingConfig) ProtoMessage added in v1.1.0

func (*StrategyLeastPingConfig) ProtoMessage()

func (*StrategyLeastPingConfig) ProtoReflect added in v1.1.0

func (x *StrategyLeastPingConfig) ProtoReflect() protoreflect.Message

func (*StrategyLeastPingConfig) Reset added in v1.1.0

func (x *StrategyLeastPingConfig) Reset()

func (*StrategyLeastPingConfig) String added in v1.1.0

func (x *StrategyLeastPingConfig) String() string

type StrategyRandomConfig added in v1.1.0

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

func (*StrategyRandomConfig) Descriptor deprecated added in v1.1.0

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

Deprecated: Use StrategyRandomConfig.ProtoReflect.Descriptor instead.

func (*StrategyRandomConfig) ProtoMessage added in v1.1.0

func (*StrategyRandomConfig) ProtoMessage()

func (*StrategyRandomConfig) ProtoReflect added in v1.1.0

func (x *StrategyRandomConfig) ProtoReflect() protoreflect.Message

func (*StrategyRandomConfig) Reset added in v1.1.0

func (x *StrategyRandomConfig) Reset()

func (*StrategyRandomConfig) String added in v1.1.0

func (x *StrategyRandomConfig) String() string

type StrategyWeight added in v1.1.0

type StrategyWeight struct {
	Regexp bool    `protobuf:"varint,1,opt,name=regexp,proto3" json:"regexp,omitempty"`
	Match  string  `protobuf:"bytes,2,opt,name=match,proto3" json:"match,omitempty"`
	Value  float32 `protobuf:"fixed32,3,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*StrategyWeight) Descriptor deprecated added in v1.1.0

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

Deprecated: Use StrategyWeight.ProtoReflect.Descriptor instead.

func (*StrategyWeight) GetMatch added in v1.1.0

func (x *StrategyWeight) GetMatch() string

func (*StrategyWeight) GetRegexp added in v1.1.0

func (x *StrategyWeight) GetRegexp() bool

func (*StrategyWeight) GetValue added in v1.1.0

func (x *StrategyWeight) GetValue() float32

func (*StrategyWeight) ProtoMessage added in v1.1.0

func (*StrategyWeight) ProtoMessage()

func (*StrategyWeight) ProtoReflect added in v1.1.0

func (x *StrategyWeight) ProtoReflect() protoreflect.Message

func (*StrategyWeight) Reset added in v1.1.0

func (x *StrategyWeight) Reset()

func (*StrategyWeight) String added in v1.1.0

func (x *StrategyWeight) String() string

type UserMatcher added in v1.1.0

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

func NewUserMatcher added in v1.1.0

func NewUserMatcher(users []string) *UserMatcher

func (*UserMatcher) Apply added in v1.1.0

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

Apply implements Condition.

type WeightManager added in v1.1.0

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

WeightManager manages weights for specific settings

func NewWeightManager added in v1.1.0

func NewWeightManager(s []*StrategyWeight, defaultWeight float64, scaler weightScaler) *WeightManager

NewWeightManager creates a new WeightManager with settings

func (*WeightManager) Apply added in v1.1.0

func (s *WeightManager) Apply(tag string, value float64) float64

Apply applies weight to the value

func (*WeightManager) Get added in v1.1.0

func (s *WeightManager) Get(tag string) float64

Get gets the weight of specified tag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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