Help us shape the future of Go! Take the 2026 Go Developer Survey

egress

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func Dial(ctx context.Context, network, addr string) (net.Conn, error)

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

func ProxyFunc(cap Capability) func(*http.Request) (*url.URL, error)

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.

func Use

func Use(o config.Outbound, log *slog.Logger)

Use installs the owner setting. An enabled proxy with an unusable address stays enabled and fails closed. When the setting is on, it overrides HTTP_PROXY and HTTPS_PROXY for clients that use this package. ALL_PROXY is never read.

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

func PolicyFrom(o config.Outbound) Policy

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

func (p Policy) SnapshotClient(cap Capability, timeout time.Duration) *http.Client

SnapshotClient is an HTTP client bound to p, for a check that must not follow a policy saved later in the same process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL