console

package
v3.0.0-rc45 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package console serves the console sessions of a node.

The daemon listens on the console port and hands every connection it accepts to a process of its own, which does all the rest: the TLS handshake, the verification of the ticket, the websocket, and the command run in a terminal. The daemon never reads a byte of a session, and a session outlives it: a daemon restart does not interrupt the consoles.

Index

Constants

View Source
const DefaultPort = 1216

DefaultPort is the port the console listener listens on.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir is where the console sessions of the node keep what they share.

func Port

func Port() int

Port returns the console port of the node configuration.

func Serve

func Serve(conn net.Conn, cfg Config) error

Serve serves the console session of one connection, until it ends.

func ServeInherited

func ServeInherited() error

ServeInherited serves the console session of the connection the process inherited from the daemon.

func SessionDir

func SessionDir() string

SessionDir is where the running sessions are recorded.

Types

type Config

type Config struct {
	// Hostname is the name of this node: a ticket for another node
	// is relayed to it.
	Hostname string

	// Certificate is what the session authenticates the node to the
	// client with.
	Certificate tls.Certificate

	// VerifyKey is the public key of the key the tickets are signed
	// with.
	VerifyKey *rsa.PublicKey

	// TicketDir is where the used tickets are marked, and SessionDir
	// where the sessions are recorded.
	TicketDir  string
	SessionDir string

	// Command returns the command a session runs in its terminal.
	Command func(console.Target) ([]string, error)

	// PeerURL returns the url of the console endpoint of a peer
	// node, and PeerTLSConfig how to verify it.
	PeerURL       func(node string) (string, error)
	PeerTLSConfig *tls.Config

	// Authenticated is called once the ticket of the session is
	// accepted, to tell the daemon the connection is no longer one
	// of the unauthenticated connections it bounds the number of.
	Authenticated func()

	Log *plog.Logger
}

Config is what a session process needs of the node it runs on.

type Listener

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

Listener accepts the console connections and hands each of them to a session process of its own.

func NewListener

func NewListener(addr string) *Listener

NewListener returns the console listener of the address.

func (*Listener) Start

func (t *Listener) Start(ctx context.Context) error

Start listens and accepts until Stop.

func (*Listener) Stop

func (t *Listener) Stop() error

Stop stops accepting. The sessions already handed over are processes of their own, and go on.

type Session

type Session struct {
	PID       int            `json:"pid"`
	User      string         `json:"user"`
	Remote    string         `json:"remote"`
	Target    console.Target `json:"console"`
	StartedAt time.Time      `json:"started_at"`
}

Session is what a console session records of itself for the time it lasts.

The record is a file, so it is there for whoever needs it after the daemon that spawned the session is gone: the sessions outlive it.

Jump to

Keyboard shortcuts

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