config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const LibDir = "/usr/lib/machineproxy"

LibDir is the standard install location for machineproxy support binaries.

Variables

View Source
var (
	Version = "0.1.0"
	Commit  = ""
	Date    = ""
)

Build-time metadata, populated via ldflags.

Functions

func MatchLocalCommand

func MatchLocalCommand(entry, pathname string) bool

MatchLocalCommand is a convenience that compiles entry and matches in one step. Returns false for malformed entries.

func ResolveAgentBinaryPath

func ResolveAgentBinaryPath(configPath, goos, goarch string) (string, error)

ResolveAgentBinaryPath finds the mproxy-agent binary. It checks the MPROXY_AGENT_BIN env var first, then the config value, adjacent binary, and well-known install paths. The goos and goarch parameters select the correct platform-specific binary for the remote host.

func ResolveShimPath

func ResolveShimPath(configPath string) (string, error)

ResolveShimPath finds the mproxy-shim binary using the config value, then falling back to adjacent binary and well-known install paths.

func ResolveTracerPath

func ResolveTracerPath(configPath string) (string, error)

ResolveTracerPath finds the mproxy-tracer binary using the config value, then falling back to adjacent binary and well-known install paths.

Types

type Config

type Config struct {
	LogLevel string `yaml:"log_level" toml:"log_level" json:"log_level"` // trace, debug, info, warn, error

	Remote struct {
		// SSH is resolved via the user's ssh_config (see ssh_config(5)).
		// Host accepts either a literal hostname/IP or a Host alias defined
		// in ~/.ssh/config; User and Port, when set, override the resolved
		// values from ssh_config.
		SSH struct {
			Host string `yaml:"host" toml:"host" json:"host"`
			User string `yaml:"user" toml:"user" json:"user"`
			Port int    `yaml:"port" toml:"port" json:"port"`
		} `yaml:"ssh" toml:"ssh" json:"ssh"`
		OS   string `yaml:"os" toml:"os" json:"os"`       // remote OS for agent binary resolution; defaults to runtime.GOOS
		Arch string `yaml:"arch" toml:"arch" json:"arch"` // remote arch for agent binary resolution; defaults to runtime.GOARCH
	} `yaml:"remote" toml:"remote" json:"remote"`

	Container struct {
		LocalCommands []string `yaml:"local_commands" toml:"local_commands" json:"local_commands"`
		Mounts        []string `yaml:"mounts" toml:"mounts" json:"mounts"`                // docker-compose style: [local:]remote
		WorkingDir    string   `yaml:"working_dir" toml:"working_dir" json:"working_dir"` // override container working directory; defaults to first mount's local path
		EnvRemove     []string `yaml:"env_remove" toml:"env_remove" json:"env_remove"`    // glob/regex patterns for env vars to strip from the container process
	} `yaml:"container" toml:"container" json:"container"`

	Agent struct {
		EnvKeep   []string `yaml:"env_keep" toml:"env_keep" json:"env_keep"`       // glob/regex patterns for inherited env vars to forward to remote
		EnvRemove []string `yaml:"env_remove" toml:"env_remove" json:"env_remove"` // glob/regex patterns for env vars to always strip from remote
	} `yaml:"agent" toml:"agent" json:"agent"`

	Components struct {
		ShimPath        string `yaml:"shim_path" toml:"shim_path" json:"shim_path"`
		TracerPath      string `yaml:"tracer_path" toml:"tracer_path" json:"tracer_path"`
		AgentLocalPath  string `yaml:"agent_local_path" toml:"agent_local_path" json:"agent_local_path"`
		AgentRemotePath string `yaml:"agent_remote_path" toml:"agent_remote_path" json:"agent_remote_path"`
	} `yaml:"components" toml:"components" json:"components"`

	Recording struct {
		Path string `yaml:"path" toml:"path" json:"path"` // empty disables recording
	} `yaml:"recording" toml:"recording" json:"recording"`
}

Config describes machineproxy runtime behavior.

func Load

func Load(r io.Reader) (*Config, error)

Load reads from r, auto-detecting YAML vs TOML by sniffing the bytes. Use LoadFile when you have a path so the extension hint applies first.

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile reads and decodes the config at path. Format is detected by file extension first (.yaml/.yml/.json → YAML, .toml → TOML); if the extension is unrecognized, the contents are sniffed (see detectFormat).

func (*Config) Validate

func (c *Config) Validate() error

type Format

type Format int

Format identifies the on-disk format of a config file.

const (
	FormatYAML Format = iota
	FormatTOML
)

type LocalCommandRule

type LocalCommandRule struct {
	// contains filtered or unexported fields
}

LocalCommandRule is a compiled local_commands entry that can match against executable pathnames. Supported forms:

  • "/absolute/path" — exact full path match
  • "/regex/" — regex matched against the full pathname
  • "basename" — matched against the last segment of the path

func CompileLocalCommand

func CompileLocalCommand(s string) (*LocalCommandRule, error)

CompileLocalCommand parses and validates a local_commands entry, returning a rule that can match pathnames.

func (*LocalCommandRule) Match

func (r *LocalCommandRule) Match(pathname string) bool

Match reports whether pathname matches this rule.

type Mount

type Mount struct {
	// RemotePath is the path on the remote machine (FUSE source).
	RemotePath string
	// ContainerPath is the path inside the container (bind target).
	// Equals RemotePath when no explicit local path is given.
	ContainerPath string
}

Mount represents a parsed container mount entry in docker-compose style. Format: [local_path:]remote_path

func ParseMount

func ParseMount(s string) (Mount, error)

ParseMount parses a docker-compose style mount string.

Jump to

Keyboard shortcuts

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