Documentation
¶
Overview ¶
Package egress routes Ether's outbound dials. One optional, node-local proxy is off by default. While it is off, clients follow the process environment the way they did before the setting existed. While it is on, source traffic uses that proxy and does not fall back to a direct route, and Plex, updates, UPnP and remote access stay direct.
Index ¶
- Variables
- func Client(cap Capability, timeout time.Duration) *http.Client
- func Dial(ctx context.Context, network, addr string) (net.Conn, error)
- func ProxyFunc(cap Capability) func(*http.Request) (*url.URL, error)
- func Set(p Policy)
- func Transport(cap Capability) *http.Transport
- func Use(o config.Outbound, log *slog.Logger)
- type Capability
- type Policy
Constants ¶
This section is empty.
Variables ¶
var ErrNotConfigured = errors.New("outbound proxy is not configured")
ErrNotConfigured is returned when a routed call has no proxy to dial. The request fails. It is not retried on the normal route.
Functions ¶
func Client ¶
func Client(cap Capability, timeout time.Duration) *http.Client
Client is an HTTP client for cap. A zero timeout means no client timeout. The proxy selector reads the live policy on every request.
func Dial ¶
Dial opens an NNTP connection. With the proxy off, or with Usenet left on the normal route, it dials addr directly. Otherwise it dials through the proxy and returns the proxy's error unchanged in kind: a failed gateway is never followed by a direct dial.
func ProxyFunc ¶
ProxyFunc is an http.Transport proxy selector for cap. It reads the live policy on every request.
func Set ¶
func Set(p Policy)
Set replaces the process-wide policy. Tests should restore the previous policy with t.Cleanup.
func Transport ¶
func Transport(cap Capability) *http.Transport
Transport is a default-like transport whose proxy selector follows cap.
Types ¶
type Capability ¶
type Capability int
Capability is one class of outbound call.
const ( // CapDirect is Plex, the update feed, UPnP, reachability and anything // else that must stay on the normal route while a source proxy is on. CapDirect Capability = iota // CapIndexers is Newznab, Torznab, built-in sites and their definitions. CapIndexers // CapStremio is addon APIs, NZB downloads and direct addon HTTP streams. CapStremio // CapDebrid is debrid APIs and debrid CDN streams. CapDebrid // CapUsenet is NNTP. CapUsenet // CapMetadata is catalogues, artwork, ratings, subtitles, Trakt, Simkl // and the language model. It stays direct unless the owner opts in. CapMetadata // CapProbe is the public address source traffic leaves from. CapProbe )
type Policy ¶
type Policy struct {
Enabled bool
Proxy *url.URL
Indexers bool
Stremio bool
Debrid bool
Usenet bool
Metadata bool
Bypass []string
}
Policy is the live routing decision. Proxy is nil when there is nothing to dial. The URL may carry a username and password; callers must not log it.
func Current ¶
func Current() Policy
Current returns a copy of the live policy. The proxy URL is shared and must not be mutated.
func PolicyFrom ¶
PolicyFrom builds a policy. Credentials from Username and Password are attached to the URL. An invalid URL yields an enabled policy with no proxy, so routed dials fail instead of going direct.
func (Policy) SnapshotClient ¶
SnapshotClient is an HTTP client bound to p, for a check that must not follow a policy saved later in the same process.