conf

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package conf is a package used to read configuration file (~/.bssh.toml).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile added in v1.0.1

func AppendFile(file, line string) error

func CheckFormatServerConf added in v1.0.1

func CheckFormatServerConf(c Config) (isFormat bool)

CheckFormatServerConf checkes format of server config.

Note: Checking Addr, User and authentications having a value. No checking a validity of each fields.

See also: checkFormatServerConfAuth function.

func CheckFormatServerConfAuth added in v1.0.1

func CheckFormatServerConfAuth(c ServerConfig) (isFormat bool)

CheckFormatServerConfAuth checkes format of server config authentication.

Note: Checking Pass, Key, Cert, AgentAuth, PKCS11Use, PKCS11Provider, Keys or Passes having a value. No checking a validity of each fields.

func IsDirectServer added in v1.0.1

func IsDirectServer(server string) bool

IsDirectServer tells that the server is a direct server address like user:pass@host:port.

Types

type Config

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

	SSHConfig map[string]OpenSSHConfig

	// DisableAutoEncryptPwd disable auto PBE passwords in config file.
	DisableAutoEncryptPwd bool
	Passphrase            string
	Hosts                 []string
	// contains filtered or unexported fields
}

Config is Struct that stores the entire configuration file.

func ReadConf

func ReadConf(confPath string) (config Config)

ReadConf load configuration file and return Config structure.

func (*Config) EnsureSearchHost added in v1.0.1

func (cf *Config) EnsureSearchHost(host string) (string, []string)

EnsureSearchHost searches the host name by glob pattern.

func (*Config) ExpandHosts added in v0.6.13

func (cf *Config) ExpandHosts(c *cli.Context) ([]string, []string)

ExpandHosts expand hosts to comma-separated or wild match (file name pattern).

func (*Config) FilterNamesByGroup added in v0.6.13

func (cf *Config) FilterNamesByGroup(group string, names []string) []string

FilterNamesByGroup filter server names by group.

func (*Config) GetGrouping added in v0.6.13

func (cf *Config) GetGrouping() map[string]map[string]ServerConfig

GetGrouping get grouping map.

func (*Config) GetNameList added in v0.6.13

func (cf *Config) GetNameList() (nameList []string)

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

func (*Config) GetNameSortedList added in v0.6.13

func (cf *Config) GetNameSortedList() (nameList []string)

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

func (*Config) GroupsNames added in v0.6.13

func (cf *Config) GroupsNames() []string

GroupsNames get groups' names.

func (*Config) IsDisableAutoEncryptPwd added in v1.0.1

func (cf *Config) IsDisableAutoEncryptPwd() bool

func (*Config) PrintServerList added in v1.0.1

func (cf *Config) PrintServerList(names []string, printTitle bool)

PrintServerList prints server list which has names.

func (*Config) WriteTempHosts added in v1.0.1

func (cf *Config) WriteTempHosts(tempHost string)

WriteTempHosts writes a new host to temporary file.

type ExtraConfig added in v0.6.13

type ExtraConfig struct {
	// Passphrase used to decrypt {PBE}xxx
	Passphrase string
	// DisableGrouping disable server names grouping
	DisableGrouping bool
	// DisableAutoEncryptPwd disable auto PBE passwords in config file.
	DisableAutoEncryptPwd bool
}

ExtraConfig store extra configs.

type IncludeConfig

type IncludeConfig struct {
	Path string
}

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

type IncludesConfig added in v0.5.2

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

IncludesConfig specify the configuration file to include (ServerConfig only). Struct that can specify multiple files in array.

type LogConfig

type LogConfig struct {
	// Enable terminal logging.
	Enable bool

	// Add a timestamp at the beginning of the terminal log line.
	Timestamp bool

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

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

type OpenSSHConfig added in v0.6.13

type OpenSSHConfig struct {
	Path    string // This is preferred
	Command string
	ServerConfig
}

OpenSSHConfig to read OpenSSH configuration file.

WARN: This struct is not use...

type ProxyConfig added in v0.4.4

type ProxyConfig struct {
	Addr      string
	Port      string
	User      string
	Pass      string
	Proxy     string
	ProxyType string `toml:"proxy_type"`
	Note      string
}

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

type ServerConfig

type ServerConfig struct {
	// templates, host:port user/pass
	Tmpl  string
	Group []string

	// Connect basic Setting
	Addr string
	Port string
	User string

	// Connect auth Setting
	Pass           string
	Passes         []string
	Key            string
	KeyCommand     string   `toml:"keycmd"`
	KeyCommandPass string   `toml:"keycmdpass"`
	KeyPass        string   `toml:"keypass"`
	Keys           []string `toml:"keys"` // "keypath::passphrase"
	Cert           string
	CertKey        string `toml:"certkey"`
	CertKeyPass    string `toml:"certkeypass"`

	CertPKCS11  bool `toml:"certpkcs11"`
	AgentAuth   bool `toml:"agentauth"`
	SSHAgentUse bool `toml:"ssh_agent"`
	PKCS11Use   bool `toml:"pkcs11"`
	// x11 forwarding setting
	X11 bool

	SSHAgentKeyPath []string `toml:"ssh_agent_key"` // "keypath::passphrase"

	PKCS11Provider string `toml:"pkcs11provider"` // PKCS11 Provider PATH
	PKCS11PIN      string `toml:"pkcs11pin"`      // PKCS11 PIN code

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

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

	// local rcfile setting
	LocalRcUse       string   `toml:"local_rc"` // yes|no (default: yes)
	LocalRcPath      []string `toml:"local_rc_file"`
	LocalRcDecodeCmd string   `toml:"local_rc_decode_cmd"`

	// local/remote port forwarding setting
	PortForwardMode   string `toml:"port_forward"`        // [`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]
	PortForwardLocal  string `toml:"port_forward_local"`  // port forward (local). "host:port"
	PortForwardRemote string `toml:"port_forward_remote"` // port forward (remote). "host:port"

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

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

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

ServerConfig structure for holding SSH connection information.

func ParseDirectServer added in v1.0.1

func ParseDirectServer(server string) (ServerConfig, bool)

ParseDirectServer parses a direct server address.

func ServerConfigDeduct added in v1.0.1

func ServerConfigDeduct(perConfig, childConfig ServerConfig) ServerConfig

ServerConfigDeduct returns a new server config that set perConfig field to childConfig empty filed.

func (ServerConfig) BelongsToGroup added in v0.6.13

func (c ServerConfig) BelongsToGroup(cf *Config, name string) bool

BelongsToGroup belongs to group or not.

type ShellConfig added in v0.6.13

type ShellConfig struct {
	// prompt
	Prompt  string `toml:"PROMPT"`  // bssh shell prompt
	OPrompt string `toml:"OPROMPT"` // bssh shell output prompt

	// message,title etc...
	Title string

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

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

ShellConfig structure for storing bssh-shell settings.

type Tmpl added in v0.6.13

type Tmpl struct {
	ID       string
	Host     string
	Port     string
	User     string
	Password string // empty when using public key

	Props map[string]string
}

Tmpl represents the structure of remote host information for ssh.

func ParseTmpl added in v0.6.13

func ParseTmpl(tmpl string) []Tmpl

ParseTmpl parses the tmpl.

Jump to

Keyboard shortcuts

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