subhost

package
v0.2.2-dev.6 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package subhost is the intake of a subscription host (design/adr/0018-panel-behind-nat.md): it takes the connections the front of TCP 443 hands it for the subscription names and passes each, untouched, to the panel through the public bridge. A connection it cannot pass goes to the node's site (the front's default route), never to a reset, which would tell a prober the name is handled apart. Authenticated agents use a separate control bridge.

Index

Constants

View Source
const (
	RelaySub  = "sub"
	RelayLink = "link"
)

The relay ids of the panel's two targets (its listener takes both; the host counts them apart).

Variables

This section is empty.

Functions

func AgentPath

func AgentPath(path string) string

AgentPath derives the path used by remote agents after they prove their TLS identity.

func ControlCapacity

func ControlCapacity(nodes int) int

ControlCapacity budgets one session per agent plus space for reconnects and enrollment.

func ControlPath

func ControlPath(path string) string

ControlPath derives the private bridge path the panel uses to carry agent links.

Types

type Entry

type Entry interface {
	Connected(exitID string) bool
	Attach(ctx context.Context, exitID string, c bridge.Client) error
	DialExit(ctx context.Context, exitID, relayID string, idle time.Duration) (net.Conn, error)
}

Entry is what the intake needs of the host's bridge entry (*bridge.Entry).

type Front

type Front interface {
	TryDivert(conn net.Conn) bool
	SetDown(id string, down bool)
}

Front is what the intake needs of the front (*front.Front).

type Intake

type Intake struct {
	// contains filtered or unexported fields
}

Intake serves one route of a front. It is safe for concurrent use.

func New

func New(public, control Entry, front Front, routeID string) *Intake

New makes the intake of the front's route routeID; Serve runs it.

func (*Intake) Close

func (in *Intake) Close()

Close ends the intake: the streams it carries are cut (their people reconnect, to the site or to a new host) and it waits for them.

func (in *Intake) DialLink(ctx context.Context) (net.Conn, error)

DialLink opens an authenticated agent's link to the panel through the dedicated control bridge. Only the host's own agent and peers whose TLS proof was verified can use it.

func (*Intake) Serve

func (in *Intake) Serve(ln net.Listener)

Serve accepts from ln until it is closed or the intake is. While the panel holds no connection the route is down: the front sends the subscription names to the site at once, without waiting for a pair.

func (*Intake) SetControlCapacity

func (in *Intake) SetControlCapacity(control int)

SetControlCapacity updates admission for new streams. Established streams are not evicted.

func (*Intake) SetLimits

func (in *Intake) SetLimits(l Limits)

SetLimits replaces the limits (tests).

func (*Intake) Stats

func (in *Intake) Stats() Stats

Stats returns the counters.

type Limits

type Limits struct {
	Subscriptions int // public subscriptions carried at once
	Links         int // authenticated agent links carried at once
	SubPerSource  int // subscriptions carried at once from one address (an IPv6 one by its /64)
	// SubPerNetwork: subscriptions carried at once from one network, an IPv4 /24 or an IPv6 /48, so that a few dozen
	// addresses of one network cannot fill the subscription class. 0 = no such bound.
	SubPerNetwork int
	// SoftFrom: the per-source and per-network subscription caps apply only once this many subscriptions are carried
	// (about 75% of the class), so that a prober cannot make the host switch a name to the site with a few dozen
	// connections. 0 = they always apply.
	SoftFrom int
	// QueueWait: up to maxSubQueued over-limit connections can wait this long (at most two seconds).
	QueueWait time.Duration
	SubIdle   time.Duration
	LinkIdle  time.Duration // agents ping every 20 s
}

Limits are the intake's bounds for the independent public and control bridges.

type Stats

type Stats struct {
	ClientsSub, ClientsLink uint32
	PanelConnected          bool
	Diverted                uint64 // sent to the node's site instead
	RefusedPerSource        uint64 // of those, over a per-source or per-network limit
}

Stats are the intake's counters: people carried now, and since the start.

Jump to

Keyboard shortcuts

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