Documentation
¶
Overview ¶
Package serve is how hopsesh reaches the hopsesh running in the user's login session on the same machine (hopsesh serve): a private socket in a folder only the user can open, one connection per conversation. A connection starts with one JSON line saying what it carries, answered by one JSON line; then it carries that.
hopsesh serve runs where the user's sign-ins and apps are (a Mac's Keychain, its desktop apps), which a process started over SSH cannot reach, and it owns the terminals of sessions run on this machine for another one, so they outlive the connection that shows them.
Index ¶
- Constants
- Variables
- func Dir(home string) string
- func Proxy(c net.Conn, buffered *bufio.Reader, in io.Reader, out io.Writer) error
- func ReadFrame(r io.Reader) ([]byte, error)
- func Reply(c net.Conn, w Welcome) error
- func Running(ctx context.Context, home string) string
- func SocketPath(home string) string
- func WriteFrame(w io.Writer, p []byte) error
- type FrameConn
- type Hello
- type Listener
- type Welcome
Constants ¶
const ( // ModePeer is the peer protocol (internal/core/peer), as hopsesh peer --stdio speaks it. ModePeer = "peer" // ModeTerminal is one terminal tab's stream (internal/core/pty), in frames. ModeTerminal = "terminal" // ModePing asks only whether hopsesh serve is there, and which. ModePing = "ping" )
Modes: what a connection carries after its first line.
const MaxFrame = 1 << 20
MaxFrame bounds one frame of a terminal stream.
Variables ¶
var ErrNotRunning = errors.New("hopsesh is not running in the login session on this machine")
ErrNotRunning means no hopsesh serve answers on this machine.
var ErrRunning = errors.New("hopsesh serve is already running")
ErrRunning means another hopsesh serve already runs.
Functions ¶
func Proxy ¶
Proxy copies between a connection to hopsesh serve and standard input and output until either ends: how hopsesh peer --stdio hands a conversation over SSH to it.
func SocketPath ¶
SocketPath is where hopsesh serve listens. A Unix socket's path is limited to about 100 bytes; a longer home folder uses a private folder under /tmp instead.
Types ¶
type FrameConn ¶
type FrameConn struct {
// contains filtered or unexported fields
}
FrameConn carries whole frames over a byte stream: a terminal tab's stream between hopsesh serve and what shows the tab (pty.Conn).
func NewFrameConn ¶
NewFrameConn reads frames from r and writes them to w; close ends both.
type Listener ¶
Listener is hopsesh serve's socket, held with its lock.