sshshare

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 38 Imported by: 1 module, 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 sshshare implements croc's authenticated, reconnectable SSH sharing protocol and shared-terminal lifecycle.

Index

Constants

This section is empty.

Variables

View Source
var ErrDetached = errors.New("detached from shared SSH terminal")

ErrDetached indicates that the local host or guest detached while leaving the shared shell and other participants running.

Functions

func Join

func Join(ctx context.Context, config ClientConfig) error

Join authenticates an invitation, connects to its Tailcat SSH endpoint, and attaches the local terminal. After a successful attachment, transient disconnects re-run PAKE and reattach to the same shared PTY until the reconnect window expires.

Types

type ClientConfig

type ClientConfig struct {
	Code            string
	RelayAddress    string
	RelayPassword   string
	Curve           string
	Input           io.Reader
	Output          io.Writer
	ErrorOutput     io.Writer
	Terminal        *os.File
	InitialSize     WindowSize
	Reconnect       bool
	ReconnectWindow time.Duration
	TransportMode   TransportMode
	OnEvent         func(JoinEvent)
	Logf            func(string, ...any)
}

ClientConfig configures a participant joining a shared terminal.

type Host

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

Host owns one shared shell, one persistent Tailcat server, and repeatable read-write/read-only rendezvous loops. Invitation holders may disconnect and authenticate again while the host remains alive.

func StartHost

func StartHost(parent context.Context, config HostConfig) (*Host, error)

StartHost starts a reconnectable shared terminal and its two invitation listeners. It returns after the Tailcat server is reachable, without waiting for a participant.

func (*Host) AttachLocal

func (h *Host) AttachLocal(ctx context.Context, input io.Reader, output io.Writer, size WindowSize, resizes <-chan WindowSize) error

AttachLocal attaches the host's own terminal to the shared session.

func (*Host) AttachLocalTerminal

func (h *Host) AttachLocalTerminal(ctx context.Context, input *os.File, output io.Writer) error

AttachLocalTerminal attaches a real local terminal to the host session, maintaining raw mode and propagating window-size changes.

func (*Host) Close

func (h *Host) Close() error

Close revokes both invitations, disconnects participants, and stops the shared shell.

func (*Host) Code

func (h *Host) Code(role Role) string

Code returns the invitation for role.

func (*Host) Done

func (h *Host) Done() <-chan struct{}

Done closes when the host or its shared shell stops.

func (*Host) Relay

func (h *Host) Relay(role Role) string

Relay returns the rendezvous relay selected for role.

func (*Host) Wait

func (h *Host) Wait() error

Wait waits for shutdown and returns the shared shell's terminal error.

type HostConfig

type HostConfig struct {
	ReadWriteCode    string
	ReadOnlyCode     string
	RelayAddress     string
	RelayPassword    string
	Command          []string
	Directory        string
	InitialSize      WindowSize
	AuthorizationTTL time.Duration
	OnEvent          func(HostEvent)
	Logf             func(string, ...any)
}

HostConfig configures a shared SSH terminal host. AuthorizationTTL limits the time between a successful PAKE exchange and the first authenticated SSH connection; a zero value uses the secure default.

type HostEvent

type HostEvent struct {
	Role        Role
	Connected   bool
	Attachments int
}

HostEvent reports attachment lifecycle without exposing invitation codes or cryptographic key material.

type JoinEvent

type JoinEvent struct {
	State     JoinState
	Role      Role
	Transport Transport
	Attempt   int
	RetryIn   time.Duration
	Err       error
}

JoinEvent describes guest-visible connection state. Attempt is one for the initial connection and for the first reconnect after a successful session; it increases for consecutive failed reconnects.

type JoinState

type JoinState string

JoinState describes one phase of a guest connection.

const (
	JoinStateConnecting   JoinState = "connecting"
	JoinStateConnected    JoinState = "connected"
	JoinStateDisconnected JoinState = "disconnected"
	JoinStateReconnecting JoinState = "reconnecting"
)

type Role

type Role string

Role is the authority granted by an SSH invitation.

const (
	RoleReadWrite Role = "read-write"
	RoleReadOnly  Role = "read-only"
)

type Transport

type Transport string

Transport identifies the terminal data path selected after PAKE.

const (
	TransportTailcat Transport = "tailcat"
	TransportRelay   Transport = "relay"
)

type TransportMode

type TransportMode string

TransportMode controls which terminal transport a guest may use.

const (
	TransportModeAuto    TransportMode = "auto"
	TransportModeTailcat TransportMode = "tailcat"
	TransportModeRelay   TransportMode = "relay"
)

type WindowSize

type WindowSize struct {
	Width  int
	Height int
}

WindowSize is a terminal size in character cells.

Jump to

Keyboard shortcuts

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