control

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 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 control provides a JSON-over-TCP API for managing ShellGuard connections without going through the MCP/agent layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addrPath string, handler Handler, logger *slog.Logger) error

ListenAndServe starts the control server on TCP localhost. It writes the resolved host:port to addrPath so clients can discover it. It blocks until ctx is cancelled, then cleans up the addr file.

Types

type ConnectParams

type ConnectParams struct {
	Host         string `json:"host"`
	User         string `json:"user,omitempty"`
	Port         int    `json:"port,omitempty"`
	IdentityFile string `json:"identity_file,omitempty"`
	Password     string `json:"password,omitempty"`
	Passphrase   string `json:"passphrase,omitempty"`
	Transport    string `json:"transport,omitempty"`
	UseTLS       bool   `json:"use_tls,omitempty"`
	Insecure     bool   `json:"insecure,omitempty"`
	// Command is the shell command line for transport="local". It is spawned
	// under a PTY (via `sh -c`) and held open for the lifetime of the
	// connection; subsequent execs are routed through that PTY.
	Command string `json:"command,omitempty"`
}

ConnectParams are the parameters for the "connect" command.

type CoreAdapter

type CoreAdapter struct {
	Core *server.Core
}

CoreAdapter implements Handler by delegating to a server.Core instance.

func (*CoreAdapter) Connect

func (a *CoreAdapter) Connect(ctx context.Context, params ConnectParams) error

func (*CoreAdapter) ConnectedHosts

func (a *CoreAdapter) ConnectedHosts() []string

func (*CoreAdapter) Disconnect

func (a *CoreAdapter) Disconnect(ctx context.Context, params DisconnectParams) error

type DisconnectParams

type DisconnectParams struct {
	Host string `json:"host"`
}

DisconnectParams are the parameters for the "disconnect" command.

type Handler

type Handler interface {
	Connect(ctx context.Context, params ConnectParams) error
	Disconnect(ctx context.Context, params DisconnectParams) error
	ConnectedHosts() []string
}

Handler is the interface that the control socket server dispatches to.

type Request

type Request struct {
	Command string          `json:"command"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request is the envelope sent by a client over the control socket.

type Response

type Response struct {
	OK    bool            `json:"ok"`
	Data  json.RawMessage `json:"data,omitempty"`
	Error string          `json:"error,omitempty"`
}

Response is the envelope sent back to the client.

type Server

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

Server listens on a Unix socket and dispatches JSON requests to a Handler.

type StatusData

type StatusData struct {
	ConnectedHosts []string `json:"connected_hosts"`
}

StatusData is returned by the "status" command.

Jump to

Keyboard shortcuts

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