Documentation ¶
Index ¶
- Constants
- Variables
- func JoinRuleAndAddr(rule, addr string) string
- func RegisterMatchRule(name string, rule MatchRule, priority int) (replaced bool)
- func ResetRulePriority(name string, priority int)
- func SplitRuleAndAddr(s string) (rule, addr string)
- type Auth
- type File
- type Filepath
- type Fs
- type FsLocal
- func (FsLocal) Base(path string) string
- func (FsLocal) Chmod(name string, mode os.FileMode) error
- func (FsLocal) Chown(name string, uid, gid int) error
- func (FsLocal) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (FsLocal) Clean(path string) string
- func (FsLocal) Close() error
- func (FsLocal) Create(name string) (File, error)
- func (FsLocal) Dir(path string) string
- func (FsLocal) Ext(path string) string
- func (f FsLocal) Filepath() Filepath
- func (FsLocal) FromSlash(path string) string
- func (FsLocal) Getwd() (dir string, err error)
- func (FsLocal) IsAbs(path string) bool
- func (FsLocal) IsExist(err error) bool
- func (FsLocal) IsNotExist(err error) bool
- func (FsLocal) IsPathSeparator(c uint8) bool
- func (FsLocal) IsPermission(err error) bool
- func (FsLocal) Join(elem ...string) string
- func (FsLocal) ListSeparator() uint8
- func (FsLocal) Lstat(name string) (os.FileInfo, error)
- func (FsLocal) Mkdir(name string, perm os.FileMode) error
- func (FsLocal) MkdirAll(path string, perm os.FileMode) error
- func (FsLocal) Open(name string) (File, error)
- func (FsLocal) OpenFile(name string, flag int, perm os.FileMode) (File, error)
- func (FsLocal) Readlink(name string) (string, error)
- func (FsLocal) Rel(basepath, targpath string) (string, error)
- func (FsLocal) Remove(name string) error
- func (FsLocal) RemoveAll(path string) error
- func (FsLocal) Rename(oldpath, newpath string) error
- func (FsLocal) SameFile(fi1, fi2 os.FileInfo) bool
- func (FsLocal) Separator() uint8
- func (FsLocal) Split(path string) (dir, file string)
- func (FsLocal) SplitList(path string) []string
- func (FsLocal) Stat(name string) (os.FileInfo, error)
- func (FsLocal) Symlink(oldname, newname string) error
- func (FsLocal) ToSlash(path string) string
- func (FsLocal) Truncate(name string, size int64) error
- func (FsLocal) VolumeName(path string) string
- type FsSftp
- func (s FsSftp) Chmod(name string, mode os.FileMode) error
- func (s FsSftp) Chown(name string, uid, gid int) error
- func (s FsSftp) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (s FsSftp) Close() error
- func (s FsSftp) Create(name string) (File, error)
- func (s FsSftp) Filepath() Filepath
- func (s FsSftp) Getwd() (dir string, err error)
- func (s FsSftp) IsExist(err error) bool
- func (s FsSftp) IsNotExist(err error) bool
- func (s FsSftp) IsPermission(err error) bool
- func (s FsSftp) Lstat(name string) (os.FileInfo, error)
- func (s FsSftp) Mkdir(name string, perm os.FileMode) error
- func (s FsSftp) MkdirAll(path string, perm os.FileMode) error
- func (s FsSftp) Open(name string) (File, error)
- func (s FsSftp) OpenFile(name string, flag int, perm os.FileMode) (File, error)
- func (s FsSftp) Readlink(name string) (string, error)
- func (s FsSftp) Remove(name string) error
- func (s FsSftp) RemoveAll(path string) error
- func (s FsSftp) Rename(oldpath, newpath string) error
- func (s FsSftp) SameFile(fi1, fi2 os.FileInfo) bool
- func (s FsSftp) Stat(name string) (os.FileInfo, error)
- func (s FsSftp) Symlink(oldname, newname string) error
- func (s FsSftp) Truncate(name string, size int64) error
- type MatchRule
- type Matcher
- type Mux
- type MuxAuth
- type SSH
- func (s *SSH) ClearError()
- func (s *SSH) Close()
- func (s *SSH) Dial(addr string, auth *Auth) (*SSH, error)
- func (s *SSH) DialConn(net, addr string) (net.Conn, error)
- func (s *SSH) Error() error
- func (s *SSH) Get(remotePath, path string)
- func (s *SSH) Lcd(cwd string)
- func (s *SSH) Lcmd(cmd string, env ...string)
- func (s *SSH) LcmdBg(cmd, stdout, stderr string, env ...string)
- func (s *SSH) Lcwd() string
- func (s *SSH) Lexists(path string) bool
- func (s *SSH) Lfs() Fs
- func (s *SSH) LocalPipeInput(stdin io.Reader)
- func (s *SSH) LocalPipeOutput(stdout, stderr io.Writer)
- func (s *SSH) LreadFile(path string) []byte
- func (s *SSH) Lreaddir(path string, n int) []os.FileInfo
- func (s *SSH) Lremove(path string, recursive bool)
- func (s *SSH) LwriteFile(path string, data []byte)
- func (s *SSH) NopClose() *SSH
- func (s *SSH) Output() []byte
- func (s *SSH) Put(path, remotePath string)
- func (s *SSH) Rcd(cwd string)
- func (s *SSH) Rcmd(cmd string, env ...string)
- func (s *SSH) RcmdBg(cmd, stdout, stderr string, env ...string)
- func (s *SSH) Rcwd() string
- func (s *SSH) RemotePipeInput(stdin io.Reader)
- func (s *SSH) RemotePipeOutput(stdout, stderr io.Writer)
- func (s *SSH) Rexists(path string) bool
- func (s *SSH) Rfs() Fs
- func (s *SSH) RreadFile(path string) []byte
- func (s *SSH) Rreaddir(path string, n int) []os.FileInfo
- func (s *SSH) Rremove(path string, recursive bool)
- func (s *SSH) RwriteFile(path string, data []byte)
- func (s *SSH) SetError(err error)
- func (s *SSH) Status() (openAt time.Time, refs int32)
- func (s *SSH) TmpLcd(cwd string) *SSH
- func (s *SSH) TmpRcd(cwd string) *SSH
Constants ¶
View Source
const ( RulePlain = "plain" RuleRegexp = "regexp" RuleIpnet = "ipnet" )
Variables ¶
View Source
var ( ErrIsDir = errors.New("destination is directory") CopyBufferSize int64 = 1024 * 1024 CmdSeperator = "&&" // or ; )
View Source
var ( ErrMuxClosed = errors.New("mux has been closed") ErrNoAuthMethod = errors.New("no auth method can be applied to agent") )
View Source
var ErrConnClosed = errors.New("connection closed")
Functions ¶
func JoinRuleAndAddr ¶
func RegisterMatchRule ¶
func ResetRulePriority ¶
func SplitRuleAndAddr ¶
Types ¶
type Auth ¶
type Auth struct { User string Password string PrivateKey string PrivateKeyFile string HostKeyCheck ssh.HostKeyCallback TimeoutMs int MaxSession int // contains filtered or unexported fields }
func (*Auth) MustSSHConfig ¶
func (a *Auth) MustSSHConfig() *ssh.ClientConfig
type File ¶
type File interface { io.Closer Chmod(mode os.FileMode) error Chown(uid, gid int) error Name() string Read(b []byte) (n int, err error) Readdir(n int) ([]os.FileInfo, error) Readdirnames(n int) (names []string, err error) Seek(offset int64, whence int) (ret int64, err error) Stat() (os.FileInfo, error) Truncate(size int64) error Write(b []byte) (n int, err error) WriteString(s string) (n int, err error) }
File is the abstract interface for local and sftp file
type Filepath ¶
type Filepath interface { Separator() uint8 ListSeparator() uint8 IsPathSeparator(c uint8) bool Clean(path string) string ToSlash(path string) string FromSlash(path string) string SplitList(path string) []string Split(path string) (dir, file string) Join(elem ...string) string Ext(path string) string Rel(basepath, targpath string) (string, error) Base(path string) string Dir(path string) string VolumeName(path string) string IsAbs(path string) bool }
type Fs ¶
type Fs interface { Filepath() Filepath Chmod(name string, mode os.FileMode) error Chown(name string, uid, gid int) error Chtimes(name string, atime time.Time, mtime time.Time) error IsExist(err error) bool IsNotExist(err error) bool IsPermission(err error) bool Mkdir(name string, perm os.FileMode) error MkdirAll(path string, perm os.FileMode) error Readlink(name string) (string, error) Remove(name string) error RemoveAll(path string) error Rename(oldpath, newpath string) error SameFile(fi1, fi2 os.FileInfo) bool Symlink(oldname, newname string) error Truncate(name string, size int64) error Create(name string) (File, error) Open(name string) (File, error) OpenFile(name string, flag int, perm os.FileMode) (File, error) Lstat(name string) (os.FileInfo, error) Stat(name string) (os.FileInfo, error) io.Closer }
Fs is the abstract interface for local and sftp filesystem
type FsLocal ¶
type FsLocal struct {
// contains filtered or unexported fields
}
FsLocal is the wrapper for package os
func (FsLocal) IsNotExist ¶
func (FsLocal) IsPathSeparator ¶
func (FsLocal) IsPermission ¶
func (FsLocal) ListSeparator ¶
func (FsLocal) ListSeparator() uint8
func (FsLocal) VolumeName ¶
type FsSftp ¶
type FsSftp struct {
// contains filtered or unexported fields
}
func (FsSftp) IsNotExist ¶
func (FsSftp) IsPermission ¶
type MuxAuth ¶
type MuxAuth struct { // AuthMethods holds all auth methods to destination host. The key can be any // string. AuthMethods map[string]*Auth // DefaultAuth is the default auth method, it must be a key in AuthMethods field, // only used if no auth method is matched for destination, can be empty. DefaultAuth string // AgentAuths define the rule which auth method is used to connect to destination host. // The key is the format of "matcher:matchor", the value must be a key in // AuthMethods field. AgentAuths map[string]string // AgentGates define the rule which gate is used to connect to destination host. // The key is the format of "matcher:matchor", the value must be an valid "host:port" // like string. AgentGates map[string]string // KeepAliveSeconds limit the lifetime of idle ssh connection, default is 300. KeepAliveSeconds int }
MuxAuth holds auth and gate configs
func (*MuxAuth) ApplyDefaultHostCheck ¶
func (a *MuxAuth) ApplyDefaultHostCheck(check ssh.HostKeyCallback)
ApplyDefaultHostCheck apply the checking function or ssh.InsecureIgnoreHostKey to each Auth instance.
type SSH ¶
type SSH struct {
// contains filtered or unexported fields
}
func (*SSH) ClearError ¶
func (s *SSH) ClearError()
func (*SSH) Close ¶
func (s *SSH) Close()
Closed should be called only if reference count is zero or it's Cloned by NopClose
func (*SSH) LocalPipeInput ¶
func (*SSH) LocalPipeOutput ¶
func (*SSH) LwriteFile ¶
func (*SSH) NopClose ¶
NopClose create a clone of current SSH instance and increase the reference count. The Close method of returned instance will do nothing but decrease parent reference count.
func (*SSH) RemotePipeInput ¶
func (*SSH) RemotePipeOutput ¶
func (*SSH) RwriteFile ¶
Click to show internal directories.
Click to hide internal directories.