Documentation
¶
Overview ¶
Package sshshare implements croc's authenticated, reconnectable SSH sharing protocol and shared-terminal lifecycle.
Index ¶
- Variables
- func Join(ctx context.Context, config ClientConfig) error
- type ClientConfig
- type Host
- func (h *Host) AttachLocal(ctx context.Context, input io.Reader, output io.Writer, size WindowSize, ...) error
- func (h *Host) AttachLocalTerminal(ctx context.Context, input *os.File, output io.Writer) error
- func (h *Host) Close() error
- func (h *Host) Code(role Role) string
- func (h *Host) Done() <-chan struct{}
- func (h *Host) Relay(role Role) string
- func (h *Host) Wait() error
- type HostConfig
- type HostEvent
- type JoinEvent
- type JoinState
- type Role
- type Transport
- type TransportMode
- type WindowSize
Constants ¶
This section is empty.
Variables ¶
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 ¶
AttachLocalTerminal attaches a real local terminal to the host session, maintaining raw mode and propagating window-size changes.
func (*Host) Close ¶
Close revokes both invitations, disconnects participants, and stops the shared shell.
func (*Host) Done ¶
func (h *Host) Done() <-chan struct{}
Done closes when the host or its shared shell stops.
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 ¶
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 Transport ¶
type Transport string
Transport identifies the terminal data path selected after PAKE.
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 ¶
WindowSize is a terminal size in character cells.