Documentation
¶
Overview ¶
Package proxyroute pkg/proxyroute/proxyroute.go
Per-domain upstream selection for the resolving proxies. A resolver forwards every host it does not resolve itself to one upstream SOCKS5 proxy (normally skysocks-client). Rules pick a different upstream for chosen domains, so one browser proxy entry can send example.com out through one exit, a second skysocks-client instance for another domain, and leave a third domain direct.
Index ¶
Constants ¶
const Direct = "direct"
Direct is the upstream value that dials the destination from this host instead of through a SOCKS5 proxy.
const None = "none"
None is the upstream value that refuses the destination, for a resolver that should reach only its own mesh names and never the clearnet.
Variables ¶
var ErrRefused = errors.New("refused: the upstream for this host is none")
ErrRefused is the error a dial to a host routed to None returns.
Functions ¶
Types ¶
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder dials a destination through the upstream its rules pick. It caches one SOCKS5 dialer per upstream (proxy.SOCKS5 returns a dialer that is safe to share), and after a failed dial fast-fails that upstream for upstreamCooldown rather than blocking or queueing requests. There is no clean "skysocks-client connected" signal to wait on, so the cached dialer plus cooldown stands in for one.
func NewForwarder ¶
NewForwarder builds a Forwarder. def is the upstream for hosts no rule matches; empty or Direct dials directly and None refuses. rules must already be Normalized.
type Rule ¶
type Rule struct {
// Suffix is a domain: "example.com" matches example.com and every
// subdomain of it. A leading dot is ignored.
Suffix string `json:"suffix"`
// Upstream is a SOCKS5 host:port, "direct" or "none".
Upstream string `json:"upstream"`
}
Rule sends hosts matching Suffix to Upstream.