protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: 0BSD Imports: 3 Imported by: 0

Documentation

Overview

Package protocol defines the wire contract shared by the CLI and server: exit codes, the JSON response envelope, and (later) the SSH command tokenizer.

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitFailure  = 1 // general failure
	ExitUsage    = 2 // usage error
	ExitNotFound = 3
	ExitDenied   = 4
	ExitProtocol = 5 // server/protocol error
)

Exit codes shared by the CLI and by control commands run over bare ssh.

View Source
const Version = 1

Version is the control-plane protocol version. It is embedded in every JSON response envelope; clients check it opportunistically and refuse on major mismatch. Bump the major on breaking envelope or command changes.

Variables

This section is empty.

Functions

func Tokenize

func Tokenize(s string) ([]string, error)

Tokenize splits an SSH exec command string into argv using POSIX shell-word rules: whitespace separates words; single quotes preserve everything literally; double quotes preserve everything except backslash before \, ", or $; a bare backslash escapes the next character. There is no expansion of any kind — no globbing, variables, or substitution. The client's shell has already applied one layer of quoting before the string reaches us.

Types

type Envelope

type Envelope struct {
	ProtocolVersion int    `json:"protocol_version"`
	Data            any    `json:"data,omitempty"`
	Error           string `json:"error,omitempty"`
}

Envelope wraps every JSON response from a control command.

Source Files

  • protocol.go
  • tokenize.go

Jump to

Keyboard shortcuts

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