console

package
v0.4.26 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 9 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 console serves the human plane on the agent side: a console channel is piped to the node's own sshd and to nothing else.

The agent never forks a PTY, never spawns a shell and never authenticates an end user (ADR 0002). It moves bytes between the tunnel and a local TCP connection, which is what keeps the node's own keys, PAM, sudo and audit authoritative — a shell this process spawned would answer to this process's privileges, not the operator's.

Index

Constants

View Source
const LocalSSH = "127.0.0.1:22"

LocalSSH is the only address a console channel can reach. Loopback, and literal: with one agent per node there is no cross-node dialling to permit, so there is no allowlist to widen and no configuration that could widen it.

Variables

View Source
var ErrNoSSHD = errors.New("console: sshd is not accepting connections on this node")

ErrNoSSHD is returned when nothing is listening on the node's sshd port.

View Source
var ErrNotAllowed = errors.New("console: target is not in this node's web allowlist")

ErrNotAllowed is returned for a target this node does not expose.

View Source
var ErrNotThisNode = errors.New("console: target names another node")

ErrNotThisNode is returned when a channel names a node this agent is not.

The caller must not pass this text to the SaaS: a probing SaaS learns the cluster's topology by watching which names come back differently. The distinction is for this node's own log.

Functions

This section is empty.

Types

type Dialer

type Dialer func(ctx context.Context, address string) (net.Conn, error)

Dialer opens the local connection. Injected so tests can stand in a fake sshd without a listener on port 22.

type FileAllowlist

type FileAllowlist struct{ Path string }

FileAllowlist resolves against the file each time it is asked.

The file changes underneath a running agent -- `advisor target_set` writes it, and config_advisor's Commit seeds one -- and reading it once at startup meant every such change needed a restart. A read per channel costs nothing: a channel is opened by a person clicking a button.

A parse error refuses rather than falling back to the last good copy: an allowlist nobody can read is not one to keep enforcing from memory.

func (FileAllowlist) Resolve

func (f FileAllowlist) Resolve(name string) (string, error)

type Handler

type Handler struct {
	// NodeID is this agent's own node. A target naming anything else is
	// refused — the check is here, on the node, and not only in the SaaS,
	// because the SaaS is never trusted to scope its own requests.
	NodeID string

	// Dial opens the local sshd connection; nil uses a real TCP dialler.
	Dial Dialer
}

Handler serves console channels for one node.

func (*Handler) Serve

func (h *Handler) Serve(ctx context.Context, target string, rw io.ReadWriter) error

Serve pipes rw to the node's local sshd until either side closes.

target is the name the channel asked for. It must be this node: the check is an equality against the identity this agent enrolled with, so a compromised SaaS cannot reach a neighbour by asking politely.

type WebAllowlist

type WebAllowlist map[string]string

WebAllowlist maps a symbolic target name to one host:port.

One host per name, not a set: the protocol carries a name and nothing else, so a name that meant several addresses could not say which one it wanted.

func LoadWebAllowlist

func LoadWebAllowlist(path string) (WebAllowlist, error)

LoadWebAllowlist reads the allowlist. A missing file is an empty allowlist: a node that exposes no web target still serves SSH.

JSON, not YAML, because the agent runs on customer nodes and does not take a dependency to read four lines of configuration.

func (WebAllowlist) Resolve

func (a WebAllowlist) Resolve(name string) (string, error)

Resolve maps a name to its address, or refuses.

type WebHandler

type WebHandler struct {
	// Allow is the only source of addresses. Nil refuses everything.
	Allow WebResolver

	// Dial opens the upstream connection; nil uses a real TCP dialler.
	Dial Dialer
}

WebHandler serves web channels for one node.

func (*WebHandler) Serve

func (h *WebHandler) Serve(ctx context.Context, name string, rw io.ReadWriter) error

Serve pipes rw to the allowlisted address for name.

Bytes only: the agent parses no HTTP, so there is no request it can be tricked into rewriting.

type WebResolver

type WebResolver interface {
	Resolve(name string) (string, error)
}

WebResolver is what a handler asks for an address. A fixed WebAllowlist is one; so is a file read fresh on every channel.

Jump to

Keyboard shortcuts

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