Documentation
¶
Index ¶
- Variables
- func NewRule(name string, outboundTag, selectorTag string, conditions ...Condition) *rule
- func NewUserMatcher(users []string) *userMatcher
- type AllMatcher
- type AppIdMatcher
- type Condition
- type ConditionFakeIp
- type ConditionProtocol
- type ConditionTrue
- type ContextWithDNS
- type DomainMatcher
- type InboundTagMatcher
- type IpMatcher
- type Ipv6Matcher
- type NetworkMatcher
- type PortMatcher
- type Router
- type RouterConfig
- type RouterWrapper
- func (r *RouterWrapper) GetRouter() *Router
- func (r *RouterWrapper) PickHandler(ctx context.Context, si *session.Info) (i.Outbound, error)
- func (r *RouterWrapper) PickHandlerWithData(ctx context.Context, si *session.Info, rw interface{}) (interface{}, i.Outbound, error)
- func (r *RouterWrapper) UpdateRouter(router *Router)
- type SessionInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBlocked = errors.New("block")
View Source
var ErrNoHandler = errors.New("no handler")
View Source
var ErrNoHandlerPick = errors.New("no handler picked")
View Source
var ErrNoRule = errors.New("no rule matched")
View Source
var ErrSelectorNotFound = errors.New("selector not found")
Functions ¶
func NewUserMatcher ¶
func NewUserMatcher(users []string) *userMatcher
Types ¶
type AllMatcher ¶
type AllMatcher struct {
// contains filtered or unexported fields
}
type AppIdMatcher ¶
func ToIndexMatcher(appIds []*configs.AppId) (strmatcher.IndexMatcher, error) {
indexMatcher := strmatcher.NewMphIndexMatcher()
for _, appId := range appIds {
matcher, err := ToStrMatcher(appId)
if err != nil {
return nil, err
}
indexMatcher.Add(matcher)
}
if err := indexMatcher.Build(); err != nil {
return nil, err
}
return indexMatcher, nil
}
func ToStrMatcher(d *configs.AppId) (strmatcher.Matcher, error) {
lowerValue := strings.ToLower(d.Value)
switch d.Type {
case configs.AppId_Exact:
return strmatcher.Full.New(lowerValue)
case configs.AppId_Prefix:
return strmatcher.Prefix.New(lowerValue)
case configs.AppId_Keyword:
return strmatcher.Substr.New(lowerValue)
default:
return nil, errors.New("unknown domain type")
}
}
type ConditionFakeIp ¶
type ConditionFakeIp struct {
}
type ConditionProtocol ¶ added in v1.0.2
type ConditionTrue ¶
type ConditionTrue struct{}
type ContextWithDNS ¶
type ContextWithDNS struct {
SessionInfo
// contains filtered or unexported fields
}
func NewInfoWithDNS ¶
func NewInfoWithDNS(ctx SessionInfo, dns i.IPResolver) *ContextWithDNS
func (*ContextWithDNS) GetTargetIP ¶
func (ctx *ContextWithDNS) GetTargetIP() net.IP
GetTargetIPs overrides original routing.Context's implementation.
type DomainMatcher ¶
type InboundTagMatcher ¶
type InboundTagMatcher struct {
// contains filtered or unexported fields
}
func NewInboundTagMatcher ¶
func NewInboundTagMatcher(tags []string) *InboundTagMatcher
type IpMatcher ¶
a IpMatcher consists of a list of geoIpMatcher, each geoIpMatcher is created from a geo.GeoIP which corresponds to ips of a specific country.
type Ipv6Matcher ¶
type Ipv6Matcher struct{}
type NetworkMatcher ¶
type NetworkMatcher struct {
// contains filtered or unexported fields
}
func NewNetworkMatcher ¶
func NewNetworkMatcher(network []net.Network) NetworkMatcher
type PortMatcher ¶
type PortMatcher struct {
// contains filtered or unexported fields
}
func NewPortMatcher ¶
func NewPortMatcher(portRanges []*net.PortRange, onSource bool) *PortMatcher
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
determine a outbound handler for a session
func NewRouter ¶
func NewRouter(config *RouterConfig) (*Router, error)
func (*Router) PickHandler ¶
type RouterConfig ¶
type RouterConfig struct {
*configs.RouterConfig
GeoHelper i.GeoHelper
Selectors *selector.Selectors
OutboundManager i.OutboundManager
IpResolver i.IPResolver
}
type RouterWrapper ¶
func (*RouterWrapper) GetRouter ¶
func (r *RouterWrapper) GetRouter() *Router
func (*RouterWrapper) PickHandler ¶
func (*RouterWrapper) PickHandlerWithData ¶
func (*RouterWrapper) UpdateRouter ¶
func (r *RouterWrapper) UpdateRouter(router *Router)
type SessionInfo ¶
type SessionInfo 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.
GetTargetIP() 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
// GetUser returns the user email from the connection content, if exists.
GetUser() uuid.UUID
GetSourceAddr() net.Destination
GetTargetAddr() net.Destination
// GetAttributes returns extra attributes from the connection content.
// GetAttributes() map[string]string
GetAppId() string
GetFakeIP() net.IP
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.