console

package
v0.4.29 Latest Latest
Warning

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

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

A channel may name another node of the cluster, one with no agent of its own (ADR 0021). It is still piped to this node's sshd: the Advisor's SSH session there runs the hop to the peer, as root over the cluster's node-to-node SSH. This side only checks the peer is on the cluster's node list and is not this node, and audits the open.

Two kinds of channel arrive here, and both are served the same way: a person's interactive console, and an agent-driven one the SaaS opens to run one shell-tool command (ADR 0017), marked AgentDriven on the channel open. Since ADR 0019 the agent serves the marked channel at every action level: the SaaS grades the command, an admin approves it, and the session is recorded there, under a certificate whose key ID names the agent and the person.

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: a relayed channel is piped here too, so there is no address 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.

View Source
var ErrRelayRefused = errors.New("console: target is not a peer this node relays to")

ErrRelayRefused is returned when a channel names a node that is not one of the cluster's other nodes, or relaying is off.

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

	// Peers lists the cluster's nodes. Nil turns relaying off: a channel
	// naming another node is refused.
	Peers func(ctx context.Context) ([]string, error)

	// Audit records each relay open, allowed or refused. Nil records nothing.
	Audit func(node string, allowed bool, reason string)
}

Handler serves console channels for one node.

func (*Handler) Relays added in v0.4.29

func (h *Handler) Relays() bool

Relays reports whether this handler serves channels for other nodes.

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: this node, checked by equality against the identity this agent enrolled with, or a peer on the cluster's node list when relaying is on (checkRelay).

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