bismuth

package module
v0.0.0-...-7f53389 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: ISC Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotConnectedError = errors.New("not connected")
View Source
var NotFoundError = errors.New("not found")
View Source
var NotHasConnectedError = errors.New("never connected")

Functions

func NewFilteredReader

func NewFilteredReader(underReader io.Reader, pidChan chan string, retCodeChan chan string) io.Reader

func SetVerbose

func SetVerbose(_verbose bool)

Types

type BufferCloser

type BufferCloser struct {
	bytes.Buffer
}

func (BufferCloser) Close

func (b BufferCloser) Close() error

type Conn

type Conn struct {
	net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Conn wraps a net.Conn, and sets a deadline for every read and write operation.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type ExecContext

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

func NewExecContext

func NewExecContext() *ExecContext

func (*ExecContext) AbsPath

func (ctx *ExecContext) AbsPath(p string) string

func (*ExecContext) Close

func (ctx *ExecContext) Close()

func (*ExecContext) CloseSession

func (ctx *ExecContext) CloseSession(session Session)

func (*ExecContext) Connect

func (ctx *ExecContext) Connect() (err error)

func (*ExecContext) DeleteFile

func (ctx *ExecContext) DeleteFile(p string) (err error)
func (ctx *ExecContext) DeleteLink(p string) (err error)

func (*ExecContext) ExecSession

func (ctx *ExecContext) ExecSession(setupFns ...SessionSetupFn) (retCode int, err error)

func (*ExecContext) Hostname

func (ctx *ExecContext) Hostname() string

func (*ExecContext) Init

func (ctx *ExecContext) Init()

func (*ExecContext) IsConnected

func (ctx *ExecContext) IsConnected() bool

func (*ExecContext) IsDarwin

func (ctx *ExecContext) IsDarwin() bool

func (*ExecContext) IsLinux

func (ctx *ExecContext) IsLinux() bool

func (*ExecContext) IsLocal

func (ctx *ExecContext) IsLocal() bool

func (*ExecContext) IsWindows

func (ctx *ExecContext) IsWindows() bool

func (*ExecContext) KillAllSessions

func (ctx *ExecContext) KillAllSessions()

func (*ExecContext) ListDirectory

func (ctx *ExecContext) ListDirectory(path string) (files []string, err error)

func (*ExecContext) Logger

func (ctx *ExecContext) Logger() *alog.Logger

func (*ExecContext) MakeSession

func (ctx *ExecContext) MakeSession() (Session, error)

func (*ExecContext) Mkdirp

func (ctx *ExecContext) Mkdirp(p string) (err error)

func (*ExecContext) NameAnsi

func (ctx *ExecContext) NameAnsi() string

func (*ExecContext) NewLogger

func (ctx *ExecContext) NewLogger(suffix string) *alog.Logger

func (*ExecContext) Output

func (ctx *ExecContext) Output(args ...string) (stdout string, err error)

func (*ExecContext) OutputCwd

func (ctx *ExecContext) OutputCwd(cwd string, args ...string) (stdout string, err error)

func (*ExecContext) OutputShell

func (ctx *ExecContext) OutputShell(s string) (stdout string, err error)

func (*ExecContext) PathExists

func (ctx *ExecContext) PathExists(path string) (bool, error)

func (*ExecContext) Quote

func (ctx *ExecContext) Quote(suffix string, args ...string) (retCode int, err error)

func (*ExecContext) QuoteCwd

func (ctx *ExecContext) QuoteCwd(suffix string, cwd string, args ...string) (retCode int, err error)

func (*ExecContext) QuoteCwdBuf

func (ctx *ExecContext) QuoteCwdBuf(suffix string, cwd string, args ...string) (stdout []byte, stderr []byte, retCode int, err error)

func (*ExecContext) QuoteCwdPipeIn

func (ctx *ExecContext) QuoteCwdPipeIn(suffix string, cwd string, chanStdin chan io.WriteCloser, args ...string) (retCode int, err error)

func (*ExecContext) QuoteCwdPipeInOut

func (ctx *ExecContext) QuoteCwdPipeInOut(suffix string, cwd string, chanStdin chan io.WriteCloser, chanStdout chan io.Reader, args ...string) (retCode int, err error)

func (*ExecContext) QuoteCwdPipeOut

func (ctx *ExecContext) QuoteCwdPipeOut(suffix string, cwd string, chanStdout chan io.Reader, args ...string) (retCode int, err error)

func (*ExecContext) QuoteDaemonCwd

func (ctx *ExecContext) QuoteDaemonCwd(suffix string, cwd string, args ...string) (pid int, retCodeChan chan int, err error)

func (*ExecContext) QuoteDaemonCwdPipeOut

func (ctx *ExecContext) QuoteDaemonCwdPipeOut(suffix string, cwd string, chanStdout chan io.Reader, args ...string) (pid int, retCodeChan chan int, err error)

func (*ExecContext) QuoteShell

func (ctx *ExecContext) QuoteShell(suffix string, s string) (retCode int, err error)

func (*ExecContext) ReadFile

func (ctx *ExecContext) ReadFile(p string) (b []byte, err error)

func (ExecContext) ReverseTunnel

func (ctx ExecContext) ReverseTunnel(srcAddr string, destAddr string) (listener net.Listener, errChan chan error, err error)

func (*ExecContext) Run

func (ctx *ExecContext) Run(args ...string) (stdout []byte, stderr []byte, retCode int, err error)

func (*ExecContext) RunCwd

func (ctx *ExecContext) RunCwd(cwd string, args ...string) (stdout []byte, stderr []byte, retCode int, err error)

func (*ExecContext) RunShell

func (ctx *ExecContext) RunShell(s string) (stdout []byte, stderr []byte, retCode int, err error)

func (*ExecContext) SessionQuoteErr

func (ctx *ExecContext) SessionQuoteErr(suffix string) SessionSetupFn

func (*ExecContext) SessionQuoteOut

func (ctx *ExecContext) SessionQuoteOut(suffix string) SessionSetupFn

func (*ExecContext) SetHostname

func (ctx *ExecContext) SetHostname(s string)

func (*ExecContext) SetLogPrefix

func (ctx *ExecContext) SetLogPrefix(prefix string)

func (*ExecContext) SetUsername

func (ctx *ExecContext) SetUsername(s string)

func (*ExecContext) ShellInteractive

func (ctx *ExecContext) ShellInteractive(s string) (retCode int, err error)

func (*ExecContext) SshAddress

func (ctx *ExecContext) SshAddress() string

func (*ExecContext) StartCmd

func (ctx *ExecContext) StartCmd(session Session, hasExited chan bool) (pid int, retCodeChan chan int, err error)

func (*ExecContext) StartSession

func (ctx *ExecContext) StartSession(setupFns ...SessionSetupFn) (pid int, retCodeChan chan int, err error)

func (*ExecContext) Stat

func (ctx *ExecContext) Stat(p string) (os.FileInfo, error)
func (ctx *ExecContext) Symlink(dest string, src string) (err error)

func (*ExecContext) Uname

func (ctx *ExecContext) Uname() string

func (*ExecContext) UploadRecursiveExcludes

func (ctx *ExecContext) UploadRecursiveExcludes(srcRootPath string, destContext *ExecContext, destRootPath string, excludes []string) error

func (*ExecContext) Username

func (ctx *ExecContext) Username() string

func (*ExecContext) WriteFile

func (ctx *ExecContext) WriteFile(p string, b []byte) (err error)

type FileInfoIsh

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

func NewFileInfoIsh

func NewFileInfoIsh(p string, stat string) (*FileInfoIsh, error)

func (*FileInfoIsh) IsDir

func (f *FileInfoIsh) IsDir() bool

func (*FileInfoIsh) ModTime

func (f *FileInfoIsh) ModTime() time.Time

func (*FileInfoIsh) Mode

func (f *FileInfoIsh) Mode() os.FileMode

func (*FileInfoIsh) Name

func (f *FileInfoIsh) Name() string

func (*FileInfoIsh) Size

func (f *FileInfoIsh) Size() int64

func (*FileInfoIsh) Sys

func (f *FileInfoIsh) Sys() interface{}

type FilteredReader

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

func (*FilteredReader) Read

func (r *FilteredReader) Read(p []byte) (int, error)

type LocalSession

type LocalSession struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func NewLocalSession

func NewLocalSession() *LocalSession

func (*LocalSession) Close

func (s *LocalSession) Close() error

func (*LocalSession) GetFullCmdShell

func (s *LocalSession) GetFullCmdShell() string

func (*LocalSession) OnClose

func (s *LocalSession) OnClose(onClose chan bool)

func (*LocalSession) Pid

func (s *LocalSession) Pid() (pid int)

func (*LocalSession) SetCmdArgs

func (s *LocalSession) SetCmdArgs(args ...string)

func (*LocalSession) SetCmdShell

func (s *LocalSession) SetCmdShell(cmd string)

func (*LocalSession) SetCwd

func (s *LocalSession) SetCwd(cwd string)

func (s *LocalSession) SetStdout(writer io.Writer) { s.Stdout = writer } func (s *LocalSession) SetStderr(writer io.Writer) { s.Stderr = writer }

func (*LocalSession) SetStdin

func (s *LocalSession) SetStdin(reader io.Reader)

func (*LocalSession) Start

func (s *LocalSession) Start() (pid int, err error)

func (*LocalSession) StderrPipe

func (s *LocalSession) StderrPipe() (io.Reader, error)

func (*LocalSession) StdoutPipe

func (s *LocalSession) StdoutPipe() (io.Reader, error)

func (*LocalSession) Wait

func (s *LocalSession) Wait() (retCode int, err error)

type PseudoCloser

type PseudoCloser struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewPseudoCloser

func NewPseudoCloser(writer io.Writer) *PseudoCloser

func (*PseudoCloser) Close

func (p *PseudoCloser) Close() error

func (*PseudoCloser) OnClose

func (p *PseudoCloser) OnClose(cb func())

type Session

type Session interface {
	Close() error
	OnClose(onClose chan bool)
	SetCwd(cwd string)
	GetFullCmdShell() string
	SetCmdShell(cmd string)
	SetCmdArgs(args ...string)
	Start() (pid int, err error)
	Wait() (retCode int, err error)
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.Reader, error)
	StderrPipe() (io.Reader, error)
	SetStdin(reader io.Reader)
	Pid() int
}

type SessionSetupFn

type SessionSetupFn func(session Session, ready chan error) error

func SessionArgs

func SessionArgs(args ...string) SessionSetupFn

func SessionBuffer

func SessionBuffer() (SessionSetupFn, chan []byte)

func SessionCwd

func SessionCwd(cwd string) SessionSetupFn

func SessionInteractive

func SessionInteractive() SessionSetupFn

func SessionPipeStdin

func SessionPipeStdin(chanStdin chan io.WriteCloser) SessionSetupFn

func SessionPipeStdout

func SessionPipeStdout(chanStdout chan io.Reader) SessionSetupFn

func SessionSetStdin

func SessionSetStdin(reader io.Reader) SessionSetupFn

func SessionShell

func SessionShell(cmd string) SessionSetupFn

type SshSession

type SshSession struct {
	*ssh.Session
	// contains filtered or unexported fields
}

Extend ssh.Session so that it implements the Session interface

func NewSshSession

func NewSshSession(_session *ssh.Session) *SshSession

func (*SshSession) Close

func (s *SshSession) Close() error

func (*SshSession) GetFullCmdShell

func (s *SshSession) GetFullCmdShell() string

func (*SshSession) OnClose

func (s *SshSession) OnClose(onClose chan bool)

func (*SshSession) Pid

func (s *SshSession) Pid() (pid int)

func (*SshSession) SetCmdArgs

func (s *SshSession) SetCmdArgs(args ...string)

func (*SshSession) SetCmdShell

func (s *SshSession) SetCmdShell(cmd string)

func (*SshSession) SetCwd

func (s *SshSession) SetCwd(cwd string)

func (s *SshSession) SetStdout(writer io.Writer) { s.Stdout = writer } func (s *SshSession) SetStderr(writer io.Writer) { s.Stderr = writer }

func (*SshSession) SetStdin

func (s *SshSession) SetStdin(reader io.Reader)

func (*SshSession) Start

func (s *SshSession) Start() (pid int, err error)

func (*SshSession) StderrPipe

func (s *SshSession) StderrPipe() (io.Reader, error)

func (*SshSession) Wait

func (s *SshSession) Wait() (retCode int, err error)

Jump to

Keyboard shortcuts

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