Documentation ¶
Index ¶
- Variables
- type DomainSet
- type DomainSetConfig
- type Route
- type RouteConfig
- type Router
- func (r *Router) GetTCPClient(serverName string, sourceAddrPort netip.AddrPort, targetAddr conn.Addr) (tcpClient zerocopy.TCPClient, err error)
- func (r *Router) GetUDPClient(serverName string, sourceAddrPort netip.AddrPort, targetAddr conn.Addr) (udpClient zerocopy.UDPClient, err error)
- func (r *Router) Stop() error
- type RouterConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrRejected = errors.New("rejected")
)
Functions ¶
This section is empty.
Types ¶
type DomainSet ¶
type DomainSet struct { Domains []string Suffixes []string Keywords []string Regexps []*regexp.Regexp }
DomainSet is a set of domain rules.
type DomainSetConfig ¶
DomainSetConfig is the configuration for a DomainSet.
func (DomainSetConfig) DomainSet ¶
func (dsc DomainSetConfig) DomainSet() (ds DomainSet, err error)
DomainSet creates a DomainSet from the configuration.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route controls where a request is routed.
type RouteConfig ¶
type RouteConfig struct { // Name of this route. Used in logs to identify matched routes. Name string `json:"name"` // Apply this route to "tcp" or "udp" only. If empty, match all requests. Network string `json:"network"` // Route matched requests to this client. Must not be empty. ClientName string `json:"clientName"` // When matching a domain target to IP prefixes, use this resolver to resolve the domain name. // If unspecified, use all resolvers by order. ResolverName string `json:"resolverName"` // Match requests from these servers. If empty, match all requests. ServerNames []string `json:"serverNames"` // Match requests to these domain targets. If empty, match all requests. Domains []string `json:"domains"` // Match requests to domains in these domain sets. If empty, match all requests. DomainSets []string `json:"domainSets"` // Match requests to these IP prefixes. If empty, match all requests. Prefixes []netip.Prefix `json:"prefixes"` // Match requests from these IP prefixes. If empty, match all requests. SourcePrefixes []netip.Prefix `json:"sourcePrefixes"` // Match requests to these ports. If empty, match all requests. Ports []uint16 `json:"ports"` // Match requests from these ports. If empty, match all requests. SourcePorts []uint16 `json:"sourcePorts"` // Match requests to IP addresses in these countries. If empty, match all requests. GeoIPCountries []string `json:"geoIPCountries"` // Invert domain matching logic. Match requests to all domains except those in Domains or DomainSets. InvertDomains bool `json:"invertDomains"` // Invert IP prefix matching logic. Match requests to all IP prefixes except those in Prefixes. InvertPrefixes bool `json:"invertPrefixes"` // Invert port matching logic. Match requests to all ports except those in Ports. InvertPorts bool `json:"invertPorts"` // Invert source IP prefix matching logic. Match requests from all IP prefixes except those in SourcePrefixes. InvertSourcePrefixes bool `json:"invertSourcePrefixes"` // Invert source port matching logic. Match requests from all ports except those in SourcePorts. InvertSourcePorts bool `json:"invertSourcePorts"` // Invert GeoIP country matching logic. Match requests to all IP addresses except those in GeoIPCountries. InvertGeoIPCountries bool `json:"invertGeoIPCountries"` }
RouteConfig is a routing rule.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router looks up the destination client for requests received by servers.
func (*Router) GetTCPClient ¶
func (r *Router) GetTCPClient(serverName string, sourceAddrPort netip.AddrPort, targetAddr conn.Addr) (tcpClient zerocopy.TCPClient, err error)
GetTCPClient returns the zerocopy.TCPClient for a TCP request received by serverName from sourceAddrPort to targetAddr.
func (*Router) GetUDPClient ¶
func (r *Router) GetUDPClient(serverName string, sourceAddrPort netip.AddrPort, targetAddr conn.Addr) (udpClient zerocopy.UDPClient, err error)
GetUDPClient returns the zerocopy.UDPClient for a UDP session received by serverName. The first received packet of the session is from sourceAddrPort to targetAddr.
type RouterConfig ¶
type RouterConfig struct { DisableNameResolutionForIPRules bool `json:"disableNameResolutionForIPRules"` DefaultTCPClientName string `json:"defaultTCPClientName"` DefaultUDPClientName string `json:"defaultUDPClientName"` GeoLite2CountryDbPath string `json:"geoLite2CountryDbPath"` DomainSets []DomainSetConfig `json:"domainSets"` Routes []RouteConfig `json:"routes"` }
RouterConfig is the configuration for a Router.
Click to show internal directories.
Click to hide internal directories.