hostexec

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 8 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 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 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 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).

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
}

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).

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.

Jump to

Keyboard shortcuts

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