remoteexec

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package remoteexec executes broker requests on a remote backend. It receives command, environment, stream, signal, and extra-fd requests from broker, and feeds remote sessions or mproxy-agent over agentproto while returning stdout, stderr, and exit status to the broker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentRunner

type AgentRunner struct {
	Provider    SessionProvider
	Transferer  *agenttransfer.Transferer
	Recorder    *agentproto.Recorder    // nil disables recording
	AgentConfig *agentproto.AgentConfig // sent to agent before exec; nil skips
	Log         *slog.Logger
}

AgentRunner executes remote commands by launching the mproxy-agent binary on the remote host and communicating over CBOR mux.

func (*AgentRunner) EnumeratePaths added in v1.1.0

func (r *AgentRunner) EnumeratePaths(ctx context.Context, paths []string) ([]agentproto.PathInfoEntry, error)

EnumeratePaths asks the remote agent to enumerate executables reachable through the given PATH-style directories. An empty paths slice tells the agent to use its own $PATH. The session is short- lived: the agent sends one FramePathInfo and exits.

func (*AgentRunner) Run

func (r *AgentRunner) Run(ctx context.Context, req Request, stdin io.Reader, stdout io.Writer, stderr io.Writer) (int, error)

func (*AgentRunner) RunWithControl

func (r *AgentRunner) RunWithControl(ctx context.Context, req Request, ctrl *Control) (int, error)

RunWithControl extends Run with signal forwarding and extra fd bridging.

type Control

type Control struct {
	Stdin    io.Reader
	Stdout   io.Writer
	Stderr   io.Writer
	Signals  <-chan int
	ExtraFDs map[uint32]io.ReadWriteCloser
}

Control provides additional channels for signal delivery and extra file descriptor bridging beyond basic stdin/stdout/stderr.

type ExitCoder added in v1.2.0

type ExitCoder interface {
	ExitStatus() int
}

ExitCoder is satisfied by errors that carry a remote process exit code. Backend session adapters wrap their native error type (e.g. *ssh.ExitError) so the runner doesn't need backend-specific imports.

type Request

type Request struct {
	Path     string   `cbor:"path"`
	Argv     []string `cbor:"argv"`
	Env      []string `cbor:"env"`
	Cwd      string   `cbor:"cwd"`
	ExtraFDs []uint32 `cbor:"extra_fds,omitempty"`
}

type Runner

type Runner interface {
	Run(ctx context.Context, req Request, stdin io.Reader, stdout io.Writer, stderr io.Writer) (int, error)
}

Runner executes a request and writes command output to stdout/stderr. It returns the process exit code and an error if the request could not be started.

type RunnerFunc

type RunnerFunc func(ctx context.Context, req Request, stdin io.Reader, stdout io.Writer, stderr io.Writer) (int, error)

func (RunnerFunc) Run

func (f RunnerFunc) Run(ctx context.Context, req Request, stdin io.Reader, stdout io.Writer, stderr io.Writer) (int, error)

type SSHRunner

type SSHRunner struct {
	Provider SessionProvider
}

func (*SSHRunner) Run

func (r *SSHRunner) Run(ctx context.Context, req Request, stdin io.Reader, stdout io.Writer, stderr io.Writer) (int, error)

type SessionProvider

type SessionProvider interface {
	NewSession(ctx context.Context) (remote.Session, error)
}

SessionProvider creates remote command sessions. Satisfied by any remote.Backend.

type SignalableRunner

type SignalableRunner interface {
	Runner
	RunWithControl(ctx context.Context, req Request, ctrl *Control) (int, error)
}

SignalableRunner extends Runner with signal and extra fd support.

Jump to

Keyboard shortcuts

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