hostexec

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 11 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 BorrowDockerSSH added in v0.3.0

func BorrowDockerSSH(user string, hop hosts.Record) (*ssh.Client, bool)

BorrowDockerSSH returns a shared SSH client when a borrower is registered and has a match.

func ConfiguredLocalBackends added in v0.3.0

func ConfiguredLocalBackends() []config.LocalBackend

ConfiguredLocalBackends returns backends.local from the last ReconfigureFromHoneyConfig call.

func ReconfigureFromHoneyConfig

func ReconfigureFromHoneyConfig(cfg *config.File)

ReconfigureFromHoneyConfig stores Proxmox backend credentials and exec modes for API transport. Safe to call from CLI after loading config and from the web server on startup.

func RegisterDockerSSHBorrower added in v0.3.0

func RegisterDockerSSHBorrower(fn DockerSSHBorrower)

RegisterDockerSSHBorrower registers an optional SSH client borrower for honey-ssh Docker transport.

func RegisterProxmoxExecutor

func RegisterProxmoxExecutor(fn func(r hosts.Record) Executor)

RegisterProxmoxExecutor registers a resolver that returns a non-nil Executor when this process should use Proxmox API transport for the given record (from proxmoxprovider.init).

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 (used for Proxmox hybrid/pve tunnel fallback).

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 SetDockerExecutor added in v0.3.0

func SetDockerExecutor(ex Executor)

SetDockerExecutor registers the Docker container executor (typically from ui.init).

func SetK8sExecutor

func SetK8sExecutor(ex Executor)

SetK8sExecutor registers the Kubernetes pod executor (typically from ui.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).

func SetTrueNASDialUpstream added in v0.3.1

func SetTrueNASDialUpstream(fn func(ctx context.Context, user string, r hosts.Record, address string) (net.Conn, error))

SetTrueNASDialUpstream registers the in-memory upstream dialer for proxy use.

func SetTrueNASRunTunnel added in v0.3.0

func SetTrueNASRunTunnel(fn func(ctx context.Context, user string, r hosts.Record, localFwd string, out io.Writer) error)

SetTrueNASRunTunnel registers the API-shell port-forward runner (from ui.init).

func TruenasTunnelUsesAPIShell added in v0.3.0

func TruenasTunnelUsesAPIShell(r hosts.Record) bool

TruenasTunnelUsesAPIShell reports whether RunTunnel should use the TrueNAS API-shell TCP dial bridge (guests without SSH primary_ip). Appliance and rows with IP use SSH.

Types

type DockerBackendRuntime added in v0.3.0

type DockerBackendRuntime struct {
	Name          string
	Host          string
	ViaLocal      string
	ViaSSH        config.DockerViaSSH
	Socket        string
	Platform      string
	RunAs         string
	Transport     string
	LocalBackends []config.LocalBackend
	TLSVerify     bool
	CACert        string
	Cert          string
	Key           string
}

DockerBackendRuntime holds Docker API connection settings (TLS paths stay in config, not records).

func DockerBackendByName added in v0.3.0

func DockerBackendByName(name string) (DockerBackendRuntime, bool)

DockerBackendByName returns runtime config for a named Docker backend (empty name matches first entry).

type DockerSSHBorrower added in v0.3.0

type DockerSSHBorrower func(user string, hop hosts.Record) (*ssh.Client, bool)

DockerSSHBorrower returns a shared SSH client for a hop record when available (e.g. TUI cache).

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 (SSH to IP, k8s exec, or Proxmox API when configured).

func TrueNASAPIShellExecutor added in v0.3.1

func TrueNASAPIShellExecutor() Executor

TrueNASAPIShellExecutor returns the API-shell executor.

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 ProxmoxBackendRuntime

type ProxmoxBackendRuntime struct {
	Name     string
	ExecMode ProxmoxExecMode
	URL      string
	User     string
	Password string
	TokenID  string
	TokenSec string
	Insecure bool
}

ProxmoxBackendRuntime holds in-memory Proxmox API credentials (never put secrets in hosts.Record JSON).

func ProxmoxBackendByName

func ProxmoxBackendByName(name string) (ProxmoxBackendRuntime, bool)

ProxmoxBackendByName returns API runtime config for a named Proxmox backend (empty name matches first entry).

type ProxmoxExecMode

type ProxmoxExecMode string

ProxmoxExecMode controls how honey runs commands against Proxmox guests.

const (
	// ProxmoxExecSSH runs commands and file ops over guest SSH (default).
	ProxmoxExecSSH ProxmoxExecMode = "ssh"
	// ProxmoxExecPVE uses the Proxmox API where supported (QEMU guest agent; LXC uses guest SSH for exec, PVE console for TTY).
	ProxmoxExecPVE ProxmoxExecMode = "pve"
	// ProxmoxExecHybrid uses API for QEMU exec / LXC exec path and SSH for file ops and tunnels where applicable.
	ProxmoxExecHybrid ProxmoxExecMode = "hybrid"
)

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.

type TrueNASBackendRuntime added in v0.3.0

type TrueNASBackendRuntime struct {
	Name     string
	URL      string
	Username string
	APIKey   string
	Insecure bool
}

TrueNASBackendRuntime holds in-memory TrueNAS API credentials (never put secrets in hosts.Record JSON).

func TrueNASBackendByName added in v0.3.0

func TrueNASBackendByName(name string) (TrueNASBackendRuntime, bool)

TrueNASBackendByName returns API runtime config for a named TrueNAS backend (empty name matches first entry).

Jump to

Keyboard shortcuts

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