hostexec

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package hostexec defines the execution surface (HostClient, Executor) shared by the TUI, web server, CUE runner, and provider-specific transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReconfigureFromHoneyConfig

func ReconfigureFromHoneyConfig(cfg *config.File)

ReconfigureFromHoneyConfig propagates config to all registered provider factories. Safe to call from CLI after loading config and from the web server on startup.

func RunSSHTunnel

func RunSSHTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error

RunSSHTunnel runs the SSH local-forward tunnel registered by sshclient.

func SetConfigReloader added in v0.3.3

func SetConfigReloader(fn func(cfg *config.File))

SetConfigReloader wires a provider config reloader (called from searchrun.init).

func SetDialHoney

func SetDialHoney(fn func(user, hostAlias string, overridePort int, identityFile string) (HostClient, error))

SetDialHoney registers the SSH HostClient dialer (from sshclient.init).

func SetExecutorResolver added in v0.3.3

func SetExecutorResolver(fn func(hosts.Record) Executor)

SetExecutorResolver wires the provider registry's executor dispatch (called from searchrun.init).

func SetSSHRunInteractive

func SetSSHRunInteractive(fn func(user string, r hosts.Record, recorder any) error)

SetSSHRunInteractive registers the TTY interactive runner (from ui.init).

func SetSSHRunTunnel

func SetSSHRunTunnel(fn func(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error)

SetSSHRunTunnel registers the SSH local-forward tunnel runner (from sshclient.init).

Types

type Executor

type Executor interface {
	Dial(user string, r hosts.Record) (HostClient, error)
	RunInteractive(user string, r hosts.Record) error
	RunTunnel(ctx context.Context, user string, r hosts.Record, localFwd string, out io.Writer) error
	DialUpstream(ctx context.Context, user string, r hosts.Record, address string) (net.Conn, error)
}

Executor creates HostClients and runs interactive SSH-style sessions or tunnels.

func ForRecord

func ForRecord(r hosts.Record) Executor

ForRecord returns the Executor for a search row. Provider-specific dispatch is handled by the resolver registered via SetExecutorResolver (searchrun). SSH is the fallback when no provider claims the record.

type HostClient

type HostClient interface {
	Run(cmd string) ([]byte, error)
	// RunWithStreams runs a remote command with stdin/stdout/stderr wired through.
	// stderr may be nil to discard remote stderr.
	RunWithStreams(cmd string, stdin io.Reader, stdout, stderr io.Writer) error
	Upload(localPath, remotePath string) error
	Download(remotePath, localPath string) error
	ListRemoteDir(path string) ([]RemoteFileEntry, error)
	StatRemote(path string) (RemoteFileEntry, error)
	MkdirAllRemote(path string) error
	RemoveRemote(path string, recursive bool) error
	Close() error
}

HostClient defines running commands and file operations on a single host.

type RemoteFileEntry

type RemoteFileEntry struct {
	Name       string    `json:"name"`
	Path       string    `json:"path"`
	IsDir      bool      `json:"is_dir"`
	Size       int64     `json:"size"`
	Mode       string    `json:"mode"`
	ModifiedAt time.Time `json:"modified_at"`
}

RemoteFileEntry describes one filesystem object on the remote host.

Jump to

Keyboard shortcuts

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