Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(text string) (string, error)
- func AesEncrypt(plaintext string) (string, error)
- func CheckEnv() bool
- func CheckIp(ip string) bool
- func CheckIp4(ip string) bool
- func CheckName(name string) bool
- func ContainsAddress(address string, hostDetails []HostDetail) bool
- func GetMaskPassword(pass string) (string, error)
- func GetPlainPassword(pass string) (string, error)
- func InitXAuth()
- func InitXConfig()
- func InitXHost()
- func NewLiner() (*liner.State, error)
- func Prompt(l *liner.State) (string, error)
- func SaveEnv()
- type Auth
- type CurrentEnv
- type Host
- type HostDetail
Constants ¶
View Source
const ( Version = "1.0.1" RootPath = ".xsh" ConfigFile = "config.yaml" AuthFile = "auth.yaml" HostFile = "host.yaml" HisFile = "xsh.his" EnvFile = "xsh.env" TempPath = ".xsh/temp" LogPath = ".xsh/logs" PromptStr = "[xsh]# " )
Variables ¶
View Source
var ( TimeoutErr = errors.New("timeout") ActionTimeoutErr = errors.New("do action timeout") ActionEmptyErr = errors.New("action empty") CommandEmptyErr = errors.New("command can not empty") CommandSuErr = errors.New("su info illegal") CopyDirectionErr = errors.New("copy direction illegal") LocalPathNotFullErr = errors.New("local path must be full path") LocalPathIllegalErr = errors.New("local path name illegal") RemotePathNotFullErr = errors.New("remote path must be full path") RemotePathIllegalErr = errors.New("remote path name illegal") CryptTypeUnknown = errors.New("crypt type unknown") CryptKeyIllegal = errors.New("crypt key illegal") PromptAborted = errors.New("prompt aborted") PromptHisErr = errors.New("prompt history error") )
View Source
var ( Mode = flag.String("mode", "prompt", "running mode. value ranges: task/cmd/copy/crypt/prompt") Output = flag.String("o", "text", "output mode in task cmd and copy mode. value ranges: text/json/yaml") Task = flag.String("task", "", "task yaml file in task mode") Value = flag.String("value", "", "value yaml file in task mode") Group = flag.String("group", "", "group name in cmd and copy mode") Cmd = flag.String("cmd", "", "command line in cmd mode") Su = flag.Bool("su", false, "su or not in cmd mode") Direction = flag.String("direction", "", "upload or download in copy mode") Local = flag.String("local", "", "local path in copy mode") Remote = flag.String("remote", "", "remote path in copy mode") Plain = flag.String("plain", "", "plain text to encrypt in crypt mode") Cipher = flag.String("cipher", "", "cipher text to decrypt in crypt mode") CryptType = flag.String("ctype", "aes", "crypt or decrypt type in crypt mode") CryptKey = flag.String("ckey", "", "crypt or decrypt key in crypt mode, length must be 32") )
View Source
var (
GOOS = runtime.GOOS
)
View Source
var (
Keywords = []string{":help", ":show", ":set", ":reload", ":do", ":sudo", ":copy"}
)
View Source
var XAuth = xAuth{}
View Source
var XAuthMap = make(map[string]Auth)
View Source
var XBlackCommandRegexps = make([]*regexp.Regexp, 0)
View Source
var XCommonCommandSet = make(map[string]bool)
View Source
var XConfig = config{}
View Source
var XHost = xHost{}
View Source
var XHostMap = make(map[string]Host)
Functions ¶
func AesDecrypt ¶
func AesEncrypt ¶
func ContainsAddress ¶
func ContainsAddress(address string, hostDetails []HostDetail) bool
func GetMaskPassword ¶
func GetPlainPassword ¶
func InitXConfig ¶
func InitXConfig()
Types ¶
type Auth ¶
type Auth struct { Name string `yaml:"name"` Username string `yaml:"username"` Password string `yaml:"password,omitempty"` PrivateKey string `yaml:"privatekey,omitempty"` Passphrase string `yaml:"passphrase,omitempty"` SuType string `yaml:"sutype,omitempty"` SuPass string `yaml:"supass,omitempty"` }
type CurrentEnv ¶
type CurrentEnv struct { Single bool `yaml:"single,omitempty"` Group string `yaml:"group,omitempty"` Address string `yaml:"address,omitempty"` Auth string `yaml:"auth,omitempty"` Prompt string `yaml:"prompt,omitempty"` Action string `yaml:"action,omitempty"` Output string `yaml:"output,omitempty"` }
Single: group/address
var CurEnv CurrentEnv
type Host ¶
type Host struct { Name string `yaml:"name"` Auth string `yaml:"auth,omitempty"` Addresses []string `yaml:"addresses,omitempty"` Groups []string `yaml:"groups,omitempty"` Details []HostDetail `yaml:"details,omitempty"` Port int `yaml:"port,omitempty"` AllHost []HostDetail }
type HostDetail ¶
type HostDetail struct { Address string `yaml:"address,omitempty"` Port int `yaml:"port,omitempty"` Username string `yaml:"username,omitempty"` Password string `yaml:"password,omitempty"` PrivateKey string `yaml:"privatekey,omitempty"` Passphrase string `yaml:"passphrase,omitempty"` SuType string `yaml:"sutype,omitempty"` SuPass string `yaml:"supass,omitempty"` }
Click to show internal directories.
Click to hide internal directories.