control

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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"`
}

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