elfgate

package
v0.0.0-...-a4d04ad Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const APP_NAME = "elfgate"
View Source
const APP_VERSION = "1.4.0"

Variables

View Source
var (
	Username      string
	Password      string
	PublicKeyPath string

	Cmd     string
	Timeout int
	Hosts   []string

	SSHAgents *AgentPool
	SSHOput   *SSHOut

	OutputChan chan *CmdOutput
)

Functions

func AppInit

func AppInit() *cli.App

Init app details.

func CmdType

func CmdType(cmd string) string

Judge the command sudo or not.

func FileExist

func FileExist(path string) error

If file or path exist.

func FilePathExist

func FilePathExist(path string) error

If filepath exists, will auto create one if not exist.

func GetPasswd

func GetPasswd(masked bool) (string, error)

getPasswd returns the input read from terminal. If masked is true, typing will be matched by asterisks on the screen. Otherwise, typing will echo nothing.

func Getch

func Getch() byte

Get char from terminal

func ParseHosts

func ParseHosts(hosts []string) ([]string, error)

Parse Hosts & add default ssh ports. Supported simple preg, just like: 192.168.1.[1-100]:22.

func StdOutput

func StdOutput(outputs []*CmdOutput)

Output results to stdout.

Types

type AgentPool

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

func NewAgentPool

func NewAgentPool(user, passwd string, hosts []string, o chan *CmdOutput) *AgentPool

func (*AgentPool) Active

func (t *AgentPool) Active() bool

Is there alive clients.

func (*AgentPool) Close

func (t *AgentPool) Close()

Close all ssh clients.

func (*AgentPool) Exec

func (t *AgentPool) Exec(cmd string, timeout int) error

Exec cmds

func (*AgentPool) Len

func (t *AgentPool) Len() int

Return Alive client len.

func (*AgentPool) StopCmds

func (t *AgentPool) StopCmds() int

Stop running cmds

type CmdOutput

type CmdOutput struct {
	Host   string
	Output []string
	Error  error
}

type ConfigStruct

type ConfigStruct struct {
	Username  string
	Password  string
	PublicKey string `yaml:"public_key"`
	Groups    map[string][]string
}

type CpFile

type CpFile struct {
	Filename    string
	Destination string
	Content     []byte
}

func ScpCmdProc

func ScpCmdProc(user string, cmd string) ([]*CpFile, error)

Proc the scp command.

type SSHClient

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

SSH connection session instance

func NewSSHClient

func NewSSHClient(authType, user, passwd, host string, o chan<- *CmdOutput) (*SSHClient, error)

func (*SSHClient) Close

func (t *SSHClient) Close()

Close session & conn.

func (*SSHClient) RunCmd

func (t *SSHClient) RunCmd(cmdType, cmd string, timeout int)

func (*SSHClient) RunScp

func (t *SSHClient) RunScp(cpFiles []*CpFile)

Scp command, using sftp protocol.

func (*SSHClient) StopCmd

func (t *SSHClient) StopCmd()

Stop running cmd.

type SSHOut

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

Getting response from OutputChan

func NewSSHOut

func NewSSHOut(o <-chan *CmdOutput) *SSHOut

func (*SSHOut) GetOutput

func (t *SSHOut) GetOutput(length int) []*CmdOutput

func (*SSHOut) Stop

func (t *SSHOut) Stop()

type Signal

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

func NewSignal

func NewSignal() *Signal

func (*Signal) Run

func (t *Signal) Run()

type Stdin

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

Reading from keyboard

func NewStdin

func NewStdin() *Stdin

func (*Stdin) GetInput

func (t *Stdin) GetInput() string

Jump to

Keyboard shortcuts

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