conf

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNameList

func GetNameList(listConf Config) (nameList []string)

GetNameList return a list of server names from the Config structure.

Types

type Config

type Config struct {
	Log      LogConfig
	Mux      MuxConfig
	Shell    ShellConfig
	Include  map[string]IncludeConfig
	Includes IncludesConfig
	Common   ServerConfig
	Server   map[string]ServerConfig
	Proxy    map[string]ProxyConfig

	SSHConfig map[string]OpenSSHConfig
}

Config is Struct that stores the entire configuration file.

func Read

func Read(confPath string) (c Config)

ReadConf load configuration file and return Config structure TODO(blacknon): リファクタリング!(v0.6.5) 外出しや処理のまとめなど

func (*Config) ReadIncludeFiles

func (c *Config) ReadIncludeFiles()

ReadIncludeFiles read include files and append to Config.Server.

func (*Config) ReadOpenSSHConfig

func (c *Config) ReadOpenSSHConfig()

ReadOpenSSHConfig read OpenSSH config file and append to Config.Server.

func (*Config) ReduceCommon

func (c *Config) ReduceCommon()

ReduceCommon reduce common setting (in .lssh.conf servers)

func (*Config) ResolveConditionalMatches added in v0.8.0

func (c *Config) ResolveConditionalMatches() error

type ControlPersistDuration

type ControlPersistDuration int

ControlPersistDuration stores ControlPersist in seconds while allowing TOML/OpenSSH duration strings.

func (*ControlPersistDuration) UnmarshalTOML

func (d *ControlPersistDuration) UnmarshalTOML(v interface{}) error

type IncludeConfig

type IncludeConfig struct {
	Path string `toml:"path"`
}

IncludeConfig specify the configuration file to include (ServerConfig only).

type IncludesConfig

type IncludesConfig struct {
	// example:
	// 	path = [
	// 		 "~/.lssh.d/home.conf"
	// 		,"~/.lssh.d/cloud.conf"
	// 	]
	Path []string `toml:"path"`
}

IncludesConfig specify the configuration file to include (ServerConfig only). Struct that can specify multiple files in array. TODO: ワイルドカード指定可能にする

type LogConfig

type LogConfig struct {
	// Enable terminal logging.
	Enable bool `toml:"enable" yaml:"enable"`

	// Add a timestamp at the beginning of the terminal log line.
	Timestamp bool `toml:"timestamp" yaml:"timestamp"`

	// Specifies the directory for creating terminal logs.
	Dir string `toml:"dirpath" yaml:"dirpath"`

	// Logging with remove ANSI code.
	RemoveAnsiCode bool `toml:"remove_ansi_code" yaml:"remove_ansi_code"`
}

LogConfig store the contents about the terminal log. The log file name is created in "YYYYmmdd_HHMMSS_servername.log" of the specified directory.

type MuxConfig added in v0.8.0

type MuxConfig struct {
	Prefix               string `toml:"prefix"`
	Quit                 string `toml:"quit"`
	NewPage              string `toml:"new_page"`
	NewPane              string `toml:"new_pane"`
	SplitHorizontal      string `toml:"split_horizontal"`
	SplitVertical        string `toml:"split_vertical"`
	NextPane             string `toml:"next_pane"`
	NextPage             string `toml:"next_page"`
	PrevPage             string `toml:"prev_page"`
	PageList             string `toml:"page_list"`
	ClosePane            string `toml:"close_pane"`
	Broadcast            string `toml:"broadcast"`
	Transfer             string `toml:"transfer"`
	FocusBorderColor     string `toml:"focus_border_color"`
	FocusTitleColor      string `toml:"focus_title_color"`
	BroadcastBorderColor string `toml:"broadcast_border_color"`
	BroadcastTitleColor  string `toml:"broadcast_title_color"`
	DoneBorderColor      string `toml:"done_border_color"`
	DoneTitleColor       string `toml:"done_title_color"`
}

MuxConfig stores lsmux key bindings.

func (MuxConfig) ApplyDefaults added in v0.8.0

func (m MuxConfig) ApplyDefaults() MuxConfig

ApplyDefaults fills empty key bindings with tmux-like defaults.

type OpenSSHConfig

type OpenSSHConfig struct {
	Path    string `toml:"path"` // This is preferred
	Command string `toml:"command"`
	ServerConfig
}

OpenSSHConfig is read OpenSSH configuration file.

type PortForward

type PortForward struct {
	Mode          string // L or R.
	Local         string // localhost:8080 or /tmp/local.sock
	Remote        string // localhost:80 or /tmp/remote.sock
	LocalNetwork  string // tcp or unix
	RemoteNetwork string // tcp or unix
}

PortForward

type ProxyConfig

type ProxyConfig struct {
	Addr      string `toml:"addr"`
	Port      string `toml:"port"`
	User      string `toml:"user"`
	Pass      string `toml:"pass"`
	Proxy     string `toml:"proxy"`
	ProxyType string `toml:"proxy_type"`
	Note      string `toml:"note"`
}

ProxyConfig is that stores Proxy server settings connected via http and socks5.

type ServerConfig

type ServerConfig struct {
	// Connect basic Setting
	Addr string `toml:"addr"`
	Port string `toml:"port"`
	User string `toml:"user"`

	// Connect auth Setting
	Pass            string   `toml:"pass"`
	Passes          []string `toml:"passes"`
	Key             string   `toml:"key"`
	KeyCommand      string   `toml:"keycmd"`
	KeyCommandPass  string   `toml:"keycmdpass"`
	KeyPass         string   `toml:"keypass"`
	Keys            []string `toml:"keys"` // "keypath::passphrase"
	Cert            string   `toml:"cert"`
	Certs           []string `toml:"certs"` // "certpath::keypath::passphrase"
	CertKey         string   `toml:"certkey"`
	CertKeyPass     string   `toml:"certkeypass"`
	CertPKCS11      bool     `toml:"certpkcs11"`
	AgentAuth       bool     `toml:"agentauth"`
	SSHAgentUse     bool     `toml:"ssh_agent"`
	SSHAgentKeyPath []string `toml:"ssh_agent_key"` // "keypath::passphrase"
	PKCS11Use       bool     `toml:"pkcs11"`
	PKCS11Provider  string   `toml:"pkcs11provider"` // PKCS11 Provider PATH
	PKCS11PIN       string   `toml:"pkcs11pin"`      // PKCS11 PIN code

	// pre execute command
	PreCmd string `toml:"pre_cmd"`

	// post execute command
	PostCmd string `toml:"post_cmd"`

	// proxy setting
	ProxyType string `toml:"proxy_type"`

	Proxy string `toml:"proxy"`

	// OpenSSH type proxy setting
	ProxyCommand string `toml:"proxy_cmd"`

	// local rcfile setting
	// yes|no (default: yes)
	LocalRcUse string `toml:"local_rc"`

	// LocalRcPath
	LocalRcPath []string `toml:"local_rc_file"`

	// If LocalRcCompress is true, gzip the localrc file to base64
	LocalRcCompress bool `toml:"local_rc_compress"`

	// LocalRcDecodeCmd is localrc decode command. run remote machine.
	LocalRcDecodeCmd string `toml:"local_rc_decode_cmd"`

	// LocalRcUncompressCmd is localrc un compress command. run remote machine.
	LocalRcUncompressCmd string `toml:"local_rc_uncompress_cmd"`

	// local/remote port forwarding setting.
	// ex. [`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]
	PortForwardMode string `toml:"port_forward"`

	// port forward (local). "host:port"
	PortForwardLocal string `toml:"port_forward_local"`

	// port forward (remote). "host:port"
	PortForwardRemote string `toml:"port_forward_remote"`

	// local/remote port forwarding settings
	// ex. {[`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]}:[localaddress]:[localport]:[remoteaddress]:[remoteport]
	PortForwards []string `toml:"port_forwards"`

	// local/remote Port Forwarding slice.
	Forwards []*PortForward

	// Dynamic Port Forward setting
	// ex.) "11080"
	DynamicPortForward string `toml:"dynamic_port_forward"`

	// Reverse Dynamic Port Forward setting
	// ex.) "11080"
	ReverseDynamicPortForward string `toml:"reverse_dynamic_port_forward"`

	// HTTP Dynamic Port Forward setting
	// ex.) "11080"
	HTTPDynamicPortForward string `toml:"http_dynamic_port_forward"`

	// HTTP Reverse Dynamic Port Forward setting
	// ex.) "11080"
	HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward"`

	// NFS Dynamic Forward port setting
	// ex.) "12049"
	NFSDynamicForwardPort string `toml:"nfs_dynamic_forward"`

	// NFS Dynamic Forward path setting
	// ex.) "/path/to/remote"
	NFSDynamicForwardPath string `toml:"nfs_dynamic_forward_path"`

	// NFS Reverse Dynamic Forward port setting
	// ex.) "12049"
	NFSReverseDynamicForwardPort string `toml:"nfs_reverse_dynamic_forward"`

	// NFS Reverse Dynamic Forward path setting
	// ex.) "/path/to/local"
	NFSReverseDynamicForwardPath string `toml:"nfs_reverse_dynamic_forward_path"`

	// x11 forwarding setting
	X11 bool `toml:"x11"`

	// x11 trusted forwarding setting
	X11Trusted bool `toml:"x11_trusted"`

	// Connection Timeout second
	ConnectTimeout int `toml:"connect_timeout"`

	// Server Alive
	ServerAliveCountMax      int `toml:"alive_max"`
	ServerAliveCountInterval int `toml:"alive_interval"`

	// Check KnownHosts
	CheckKnownHosts bool `toml:"check_known_hosts"`

	// Check KnownHosts File
	KnownHostsFiles []string `toml:"known_hosts_files"`

	// OpenSSH ControlMaster settings
	ControlMaster  bool                   `toml:"control_master"`
	ControlPath    string                 `toml:"control_path"`
	ControlPersist ControlPersistDuration `toml:"control_persist"`

	// note
	Note string `toml:"note"`

	// ignore this server from selection / execution targets
	Ignore bool `toml:"ignore"`

	// Conditional overrides under [server.<name>.match.<branch>]
	Match map[string]ServerMatchConfig `toml:"match"`
}

ServerConfig Structure for holding SSH connection information

type ServerMatchConfig added in v0.8.0

type ServerMatchConfig struct {
	Addr string `toml:"addr"`
	Port string `toml:"port"`
	User string `toml:"user"`

	Pass            string   `toml:"pass"`
	Passes          []string `toml:"passes"`
	Key             string   `toml:"key"`
	KeyCommand      string   `toml:"keycmd"`
	KeyCommandPass  string   `toml:"keycmdpass"`
	KeyPass         string   `toml:"keypass"`
	Keys            []string `toml:"keys"`
	Cert            string   `toml:"cert"`
	Certs           []string `toml:"certs"`
	CertKey         string   `toml:"certkey"`
	CertKeyPass     string   `toml:"certkeypass"`
	CertPKCS11      bool     `toml:"certpkcs11"`
	AgentAuth       bool     `toml:"agentauth"`
	SSHAgentUse     bool     `toml:"ssh_agent"`
	SSHAgentKeyPath []string `toml:"ssh_agent_key"`
	PKCS11Use       bool     `toml:"pkcs11"`
	PKCS11Provider  string   `toml:"pkcs11provider"`
	PKCS11PIN       string   `toml:"pkcs11pin"`

	PreCmd       string `toml:"pre_cmd"`
	PostCmd      string `toml:"post_cmd"`
	ProxyType    string `toml:"proxy_type"`
	Proxy        string `toml:"proxy"`
	ProxyCommand string `toml:"proxy_cmd"`

	LocalRcUse           string   `toml:"local_rc"`
	LocalRcPath          []string `toml:"local_rc_file"`
	LocalRcCompress      bool     `toml:"local_rc_compress"`
	LocalRcDecodeCmd     string   `toml:"local_rc_decode_cmd"`
	LocalRcUncompressCmd string   `toml:"local_rc_uncompress_cmd"`

	PortForwardMode               string   `toml:"port_forward"`
	PortForwardLocal              string   `toml:"port_forward_local"`
	PortForwardRemote             string   `toml:"port_forward_remote"`
	PortForwards                  []string `toml:"port_forwards"`
	Forwards                      []*PortForward
	DynamicPortForward            string `toml:"dynamic_port_forward"`
	ReverseDynamicPortForward     string `toml:"reverse_dynamic_port_forward"`
	HTTPDynamicPortForward        string `toml:"http_dynamic_port_forward"`
	HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward"`
	NFSDynamicForwardPort         string `toml:"nfs_dynamic_forward"`
	NFSDynamicForwardPath         string `toml:"nfs_dynamic_forward_path"`
	NFSReverseDynamicForwardPort  string `toml:"nfs_reverse_dynamic_forward"`
	NFSReverseDynamicForwardPath  string `toml:"nfs_reverse_dynamic_forward_path"`

	X11        bool `toml:"x11"`
	X11Trusted bool `toml:"x11_trusted"`

	ConnectTimeout           int                    `toml:"connect_timeout"`
	ServerAliveCountMax      int                    `toml:"alive_max"`
	ServerAliveCountInterval int                    `toml:"alive_interval"`
	CheckKnownHosts          bool                   `toml:"check_known_hosts"`
	KnownHostsFiles          []string               `toml:"known_hosts_files"`
	ControlMaster            bool                   `toml:"control_master"`
	ControlPath              string                 `toml:"control_path"`
	ControlPersist           ControlPersistDuration `toml:"control_persist"`
	Note                     string                 `toml:"note"`
	Ignore                   bool                   `toml:"ignore"`

	Priority int             `toml:"priority"`
	When     ServerMatchWhen `toml:"when"`
	// contains filtered or unexported fields
}

ServerMatchConfig stores a single conditional override branch.

Keep override fields aligned with ServerConfig so branch tables can override the same keys as normal server definitions.

func (ServerMatchConfig) EffectivePriority added in v0.8.0

func (m ServerMatchConfig) EffectivePriority() int

EffectivePriority returns the branch priority, defaulting to 100 when omitted.

func (ServerMatchConfig) IsDefined added in v0.8.0

func (m ServerMatchConfig) IsDefined(key string) bool

IsDefined reports whether the TOML key was explicitly set in the match branch.

func (ServerMatchConfig) OverrideConfig added in v0.8.0

func (m ServerMatchConfig) OverrideConfig() ServerConfig

OverrideConfig converts a branch override into a ServerConfig for merging.

type ServerMatchWhen added in v0.8.0

type ServerMatchWhen struct {
	LocalIPIn     []string `toml:"local_ip_in"`
	LocalIPNotIn  []string `toml:"local_ip_not_in"`
	GatewayIn     []string `toml:"gateway_in"`
	GatewayNotIn  []string `toml:"gateway_not_in"`
	UsernameIn    []string `toml:"username_in"`
	UsernameNotIn []string `toml:"username_not_in"`
	HostnameIn    []string `toml:"hostname_in"`
	HostnameNotIn []string `toml:"hostname_not_in"`
	OSIn          []string `toml:"os_in"`
	OSNotIn       []string `toml:"os_not_in"`
	TermIn        []string `toml:"term_in"`
	TermNotIn     []string `toml:"term_not_in"`
	EnvIn         []string `toml:"env_in"`
	EnvNotIn      []string `toml:"env_not_in"`
	EnvValueIn    []string `toml:"env_value_in"`
	EnvValueNotIn []string `toml:"env_value_not_in"`
}

ServerMatchWhen stores match conditions for conditional server overrides.

func (ServerMatchWhen) Empty added in v0.8.0

func (w ServerMatchWhen) Empty() bool

Empty reports whether no match conditions are defined.

type ShellAliasConfig

type ShellAliasConfig struct {
	// command
	Command string `toml:"command"`
}

type ShellConfig

type ShellConfig struct {
	// prompt
	Prompt  string `toml:"PROMPT"`  // lssh shell(parallel shell) prompt
	OPrompt string `toml:"OPROMPT"` // lssh shell(parallel shell) output prompt

	// message,title etc...
	Title string `toml:"title"`

	// history file
	HistoryFile string `toml:"histfile"`

	// pre | post command setting
	PreCmd  string `toml:"pre_cmd"`
	PostCmd string `toml:"post_cmd"`

	// alias
	Alias map[string]ShellAliasConfig `toml:"alias"`

	// outexec
	OutexecCmdConfigs map[string]ShellOutexecCmdConfig `toml:"outexecs"`
}

ShellConfig Structure for storing lssh-shell(parallel shell) settings.

type ShellOutexecCmdConfig

type ShellOutexecCmdConfig struct {
	// path
	Path string `toml:"path"`
}

OutexecCmdConfig

Jump to

Keyboard shortcuts

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