bridge

package
v0.2.0-dev.8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 30 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

Index

Constants

View Source
const (
	CertificateHeader = "X-Mistgate-Bridge-Certificate"
	SignatureHeader   = "X-Mistgate-Bridge-Signature"
	RelayIDHeader     = "X-Mistgate-Relay-ID"
	ErrorHeader       = "X-Mistgate-Bridge-Error"
	ProtocolHeader    = "X-Mistgate-Bridge-Version"
	StreamHeader      = "X-Mistgate-Bridge-Stream"
	StreamKindHeader  = "X-Mistgate-Bridge-Kind"
	TargetHeader      = "X-Mistgate-Bridge-Target"
	PairIDHeader      = "X-Mistgate-Bridge-Pair-ID"
	StreamKindPanel   = "panel"
)
View Source
const (
	DefaultPoolSize           = 2
	MinPoolSize               = 2
	MaxPoolSize               = 4
	PendingWorkersPerConn     = 4
	MaxPendingWorkersPerConn  = 24
	DialRetryMin              = time.Second
	DialRetryMax              = time.Minute
	DialRetryResetAfter       = 30 * time.Second
	BridgePingInterval        = 15 * time.Second
	BridgePingTimeout         = 10 * time.Second
	BridgeConnectionAge       = time.Hour
	BridgeConnectionAgeJitter = BridgeConnectionAge / 5
	BridgeDrainTimeout        = 10 * time.Minute
	BridgeConnectionBytes     = uint64(1 << 30)
	BridgeRotateCheck         = time.Second
	BridgeDialTimeout         = 15 * time.Second
	BridgeTargetDialTimeout   = 5 * time.Second
	BridgeKeepAlive           = 30 * time.Second
)
View Source
const (
	MaxStreamsPerExit       = 4096
	MaxStreamsPerEntry      = 8192
	MaxPeopleConnsPerExit   = 2 * MaxPoolSize // the pool plus the connections that serve out their time
	MaxPanelConnsPerExit    = 2               // the control link's own TLS connection, plus the one a replacing link opens while the old one dies
	MaxConnectionsPerExit   = MaxPeopleConnsPerExit + MaxPanelConnsPerExit
	AcceptQueueSize         = 1024 // a burst of people arrives faster than the listener hands them out
	PendingStreamsPerExit   = 256
	MaxPendingClients       = 4096
	MaxClientsPerEntry      = 8192
	ClientWaitForStream     = time.Second
	BridgeStreamIdleTimeout = 2 * time.Minute
	BridgeRequestIdle       = 30 * time.Second
	BridgePairTimeout       = 5 * time.Second
	BridgePanelDialTimeout  = BridgeTargetDialTimeout
	BridgeProgressTimeout   = 30 * time.Second
	// The control link's byte budget: a bucket that holds ControlBudgetBytes and refills at ControlBudgetPerSecond. A busy exit's
	// session carries a few KiB per second for days, so a total per stream would cut it every hour or two; the bucket only stops an
	// exit that pumps data at the panel (2 Mbit/s sustained, a 64 MiB burst).
	ControlBudgetBytes     = uint64(64 << 20)
	ControlBudgetPerSecond = uint64(256 << 10)
)

Variables

This section is empty.

Functions

func VerifyProof

func VerifyProof(entryNodeID string, exporter []byte, proof Proof, roots *x509.CertPool, allowed map[string]struct{}, now time.Time) (string, error)

VerifyProof checks fleet trust, the node id in the certificate, and the connection-bound signature.

Types

type DialIdentity

type DialIdentity struct {
	NodeID         string
	CertificateDER []byte
	PrivateKey     *ecdsa.PrivateKey
}

type DialSpec

type DialSpec struct {
	Dial         plugin.BridgeDial
	Error        string // A bridge-wide configuration error; no socket is opened when set.
	TargetErrors map[string]string
}

type DialState

type DialState struct {
	PeerNodeID string
	Conns      uint32
	Since      time.Time
	RTT        time.Duration
	Streams    uint64
	BytesIn    uint64
	BytesOut   uint64
	Error      string
}

type Dialer

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

func NewDialer

func NewDialer(identity func() DialIdentity) *Dialer

func (*Dialer) Close

func (d *Dialer) Close()

func (*Dialer) DialPanel

func (d *Dialer) DialPanel(ctx context.Context, entryNodeID string) (net.Conn, error)

DialPanel opens one authenticated control stream through an already connected bridge. The entry chooses its panel target from its own configuration; this method does not accept a target address from the exit.

func (*Dialer) SetClock

func (d *Dialer) SetClock(now func() time.Time)

func (*Dialer) States

func (d *Dialer) States() []DialState

func (*Dialer) Sync

func (d *Dialer) Sync(ctx context.Context, specs []DialSpec)

Sync replaces the exit's bridge targets and starts or stops their dial pools.

type Entry

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

func NewEntry

func NewEntry() *Entry

func (*Entry) Close

func (e *Entry) Close()

func (*Entry) Handler

func (e *Entry) Handler(site http.Handler) http.Handler

Handler adds the private bridge route to a site without changing ordinary site responses.

func (*Entry) RelayCounters

func (e *Entry) RelayCounters() map[string]RelayCounters

func (*Entry) SetLogger

func (e *Entry) SetLogger(log *slog.Logger)

func (*Entry) SetServe

func (e *Entry) SetServe(cfg ServeConfig) error

func (*Entry) States

func (e *Entry) States() []PeerState

func (*Entry) StopListeners

func (e *Entry) StopListeners()

func (*Entry) SyncListeners

func (e *Entry) SyncListeners(relays []RelayListener) map[string]error

type PeerState

type PeerState struct {
	PeerNodeID string
	Conns      uint32
	Since      time.Time
	Streams    uint64
	BytesIn    uint64
	BytesOut   uint64
	Error      string
	// Clients is how many people the bridge carries now: pairs a person's connection was handed to and that have not ended.
	// Streams only counts up, and the waiting pairs are not people.
	Clients uint32
}

type Proof

type Proof struct {
	CertificateDER []byte
	Signature      []byte
}

Proof carries a node's certificate and a proof tied to one TLS connection.

func MakeProof

func MakeProof(entryNodeID string, exporter []byte, certificateDER []byte, key *ecdsa.PrivateKey) (Proof, error)

type RelayCounters

type RelayCounters struct {
	Bytes     uint64 // client to the exit's server
	BytesBack uint64 // exit's server to the client
}

type RelayListener

type RelayListener struct {
	RelayID    string
	ExitNodeID string
	Port       uint16
	Address    string // Only tests set an address; production listens on all local addresses.
}

type ServeConfig

type ServeConfig struct {
	EntryNodeID string
	Path        string
	ExitNodeIDs []string
	PanelVia    bool
	// PanelAddress is supplied only by the entry agent from its own enrollment configuration.
	PanelAddress string
	Roots        *x509.CertPool
	Now          func() time.Time
}

Jump to

Keyboard shortcuts

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