gateway

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 49 Imported by: 0

Documentation

Overview

Package gateway implements enrollment, discovery, signaling, encrypted relay fallback, and fleet administration. It does not schedule or execute application work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URL

func URL(base, path string) string

Types

type APIKey

type APIKey struct {
	UserID    string    `json:"userId"`
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Role      string    `json:"role"`
	CreatedAt time.Time `json:"createdAt"`
	Revoked   bool      `json:"revoked"`
}

type AuditEvent added in v0.5.0

type AuditEvent struct {
	ID     int64     `json:"id"`
	At     time.Time `json:"at"`
	UserID string    `json:"userId"`
	// Fleet is the account name for UserID, resolved when events are listed.
	Fleet string `json:"fleet,omitempty"`
	// Actor is a browser login, an account name for its key, or "@operator".
	Actor    string `json:"actor"`
	Via      string `json:"via"`
	KeyID    string `json:"keyId,omitempty"`
	Action   string `json:"action"`
	Target   string `json:"target,omitempty"`
	TargetID string `json:"targetId,omitempty"`
	Detail   string `json:"detail,omitempty"`
	// SourceIP is the direct TCP peer. Behind a reverse proxy it is the proxy.
	SourceIP string `json:"sourceIp,omitempty"`
}

AuditEvent records one management action or browser sign-in. It never contains passwords, tokens, installation links, or execution arguments.

type Gateway

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

Gateway manages fleet membership and connectivity for nodes and clients.

func New

func New(dir, token string, options ...Options) (*Gateway, error)

func (*Gateway) Close

func (g *Gateway) Close() error

func (*Gateway) Handler

func (g *Gateway) Handler() http.Handler

func (*Gateway) StartUpdates

func (g *Gateway) StartUpdates(ctx context.Context)

StartUpdates begins managed rollout after the server is configured. A fresh heartbeat and an acknowledged idle reservation are required from every online peer before any binary replacement can start.

type GatewayMetrics

type GatewayMetrics struct {
	Limits                   Limits  `json:"limits"`
	AdmittedConnections      int     `json:"admittedConnections"`
	ActiveHandshakes         int     `json:"activeHandshakes"`
	QueuedPacketBytes        int64   `json:"queuedPacketBytes"`
	PeakQueuedPacketBytes    int64   `json:"peakQueuedPacketBytes"`
	AdmissionRejects         int64   `json:"admissionRejects"`
	NewIdentityRejects       int64   `json:"newIdentityRejects"`
	PacketQueueRejects       int64   `json:"packetQueueRejects"`
	HandshakeCount           int64   `json:"handshakeCount"`
	HandshakeDurationSeconds float64 `json:"handshakeDurationSeconds"`
	PacketWriteFailures      int64   `json:"packetWriteFailures"`
	ConnectedMachines        int     `json:"connectedMachines"`
	ConnectedClients         int     `json:"connectedClients"`
	QueuedRelayBytes         int64   `json:"queuedRelayBytes"`
	Connects                 int64   `json:"connects"`
	Disconnects              int64   `json:"disconnects"`
	AuthFailures             int64   `json:"authFailures"`
	RelayPackets             int64   `json:"relayPackets"`
	RelayBytes               int64   `json:"relayBytes"`
	// RelayOverflows counts relay sessions closed because their destination's
	// queue was full. The destination's gateway connection stays open.
	RelayOverflows int64 `json:"relayOverflows"`
	// RelayDropped counts signaling packets dropped for a full destination queue.
	RelayDropped int64 `json:"relayDropped"`
}

GatewayMetrics is the superuser diagnostic snapshot.

type Hello

type Hello struct {
	Version string     `json:"version"`
	Node    model.Node `json:"node"`
	// NodeBytes, when present, is the exact signed registration. Gateways that
	// advertise nodeBytes decode it leniently, so a newer node's unknown fields
	// no longer invalidate a signature computed over a re-encoding.
	NodeBytes        []byte `json:"nodeBytes,omitempty"`
	Client           bool   `json:"client,omitempty"`
	GatewayHeartbeat bool   `json:"gatewayHeartbeat,omitempty"`
	RelayDrain       bool   `json:"relayDrain,omitempty"`
	OwnerKey         []byte `json:"ownerKey,omitempty"`
	OwnerSignature   []byte `json:"ownerSignature,omitempty"`
	Signature        []byte `json:"signature"`
}

func (Hello) Message

func (h Hello) Message(challenge []byte) []byte

Message binds client proofs to their role while preserving machine proofs.

func (Hello) OwnerMessage

func (h Hello) OwnerMessage(challenge []byte) []byte

OwnerMessage authorizes this particular TLS identity to act for a stable client owner. A bearer credential alone cannot impersonate another owner.

func (Hello) RegisteredNode

func (h Hello) RegisteredNode() (model.Node, error)

RegisteredNode returns the registration covered by the hello signature.

type Limits added in v0.5.3

type Limits struct {
	Connections            int   `json:"connections"`
	ConnectionsPerAccount  int   `json:"connectionsPerAccount"`
	ClientsPerAccount      int   `json:"clientsPerAccount"`
	NodesPerAccount        int   `json:"nodesPerAccount"`
	Handshakes             int   `json:"handshakes"`
	HandshakesPerAccount   int   `json:"handshakesPerAccount"`
	NewIdentitiesPerMinute int   `json:"newIdentitiesPerMinute"`
	QueuedBytes            int64 `json:"queuedBytes"`
	QueuedBytesPerAccount  int64 `json:"queuedBytesPerAccount"`
}

Limits bound live admission and retained packet buffers, not process RSS or durable fleet history. Zero option fields select defaults; negatives fail.

func DefaultLimits added in v0.5.3

func DefaultLimits() Limits

func (Limits) Validate added in v0.5.3

func (l Limits) Validate() error

Validate checks explicit runtime settings, including flags. A zero-valued Options.Limits is separately defaulted by New for embedding callers.

type Options

type Options struct {
	Limits          Limits
	STUNServers     []string
	PublicURL       string
	SuperuserKey    string
	Software        buildinfo.Info
	Apply           func(string) error
	ReleaseRepo     string
	ReleaseAPI      string
	ReleaseToken    string
	ReleaseInterval time.Duration
}

type RelayDrainRequest added in v0.5.7

type RelayDrainRequest struct {
	Until time.Time `json:"until"`
	// Peer scopes a proxy-maintenance drain to carriers involving this node.
	// Older receivers conservatively drain all their outgoing relays.
	Peer string `json:"peer,omitempty"`
}

RelayDrainRequest is a bounded, gateway-authenticated transport instruction. It never cancels a stream and expires even if its resume packet is lost.

type User

type User struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	Disabled  bool      `json:"disabled"`
}

Jump to

Keyboard shortcuts

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