Documentation
¶
Overview ¶
Package bypass implements address-based routing that decides whether a target address should skip the proxy chain and connect directly.
The package provides:
- NewBypass: a local bypass that matches addresses against CIDR, IP range, wildcard, and exact-address patterns, with optional periodic reload from file, Redis, or HTTP sources.
- BypassGroup: composes multiple bypass rules; whitelist rules use AND logic, blacklist rules use OR logic (evaluated only if whitelist fails).
- Plugin-based bypass (gRPC and HTTP) in the plugin sub-package.
Matching modes:
- Blacklist (whitelist=false): matching addresses bypass the proxy. This is the default.
- Whitelist (whitelist=true): matching addresses go through the proxy chain; all other addresses bypass the proxy.
Index ¶
- Variables
- func BypassGroup(bypasses ...bypass.Bypass) bypass.Bypass
- func NewBypass(opts ...Option) bypass.Bypass
- type Option
- func FileLoaderOption(fileLoader loader.Loader) Option
- func HTTPLoaderOption(httpLoader loader.Loader) Option
- func LoggerOption(logger logger.Logger) Option
- func MatchersOption(matchers []string) Option
- func NetworkOption(network string) Option
- func RedisLoaderOption(redisLoader loader.Loader) Option
- func ReloadPeriodOption(period time.Duration) Option
- func WhitelistOption(whitelist bool) Option
Constants ¶
This section is empty.
Variables ¶
var ErrBypass = errors.New("bypass")
ErrBypass is returned by wrapped connections when the bypass rule determines that the connection should skip the proxy chain.
Functions ¶
func BypassGroup ¶ added in v0.0.3
BypassGroup creates a composite Bypass from multiple rules. Whitelist rules use AND logic (all must match); blacklist rules use OR logic (any match triggers bypass) and are only evaluated when whitelist rules fail.
func NewBypass ¶
NewBypass creates and initializes a local Bypass instance.
In blacklist mode (the default), addresses matching any pattern bypass the proxy. In whitelist mode (set via WhitelistOption(true)), matching addresses go through the proxy chain and all others bypass the proxy.
If a reload period is configured, patterns from external loaders are refreshed automatically in the background.
Types ¶
type Option ¶
type Option func(opts *options)
Option is a functional option for configuring a Bypass instance.
func FileLoaderOption ¶
FileLoaderOption sets the file loader for reading bypass patterns from a file or directory.
func HTTPLoaderOption ¶
HTTPLoaderOption sets the HTTP loader for reading bypass patterns from an HTTP endpoint.
func LoggerOption ¶
LoggerOption sets the logger for debug and warning messages.
func MatchersOption ¶
MatchersOption sets the static bypass patterns (CIDR, IP range, wildcard, or address).
func NetworkOption ¶ added in v0.28.1
NetworkOption restricts this bypass to a specific network protocol. Network and address predicates are combined before whitelist mode is applied to the resulting match. Accepts values like "tcp" or "udp".
func RedisLoaderOption ¶
RedisLoaderOption sets the Redis loader for reading bypass patterns from a Redis set or key.
func ReloadPeriodOption ¶
ReloadPeriodOption sets the interval between automatic reloads of bypass patterns from external loaders (file, Redis, HTTP).
func WhitelistOption ¶
WhitelistOption sets whether the bypass operates in whitelist mode. In whitelist mode, matching addresses go through the proxy chain; all others bypass the proxy.