srvconn

package
v0.0.0-...-f69eaad Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchFolderName = "_Search"
)

Variables

This section is empty.

Functions

func GetClientFromCache

func GetClientFromCache(key string) (client *sshClient, ok bool)

func GetPubKeyFromFile

func GetPubKeyFromFile(keypath string) (ssh.Signer, error)

func KeepAlive

func KeepAlive(c *sshClient, closed <-chan struct{}, keepInterval time.Duration)

func MakeReuseSSHClientKey

func MakeReuseSSHClientKey(user *model.User, asset *model.Asset, systemUser *model.SystemUser) string

func NewClient

func NewClient(user *model.User, asset *model.Asset, systemUser *model.SystemUser, timeout time.Duration,
	useCache bool) (client *sshClient, err error)

Types

type AssetDir

type AssetDir struct {
	ShowHidden bool
	Overtime   time.Duration
	// contains filtered or unexported fields
}

func NewAssetDir

func NewAssetDir(user *model.User, asset model.Asset, addr string, logChan chan<- *model.FTPLog) AssetDir

func (*AssetDir) Create

func (ad *AssetDir) Create(path string) (*sftp.File, error)

func (*AssetDir) CreateFTPLog

func (ad *AssetDir) CreateFTPLog(su *model.SystemUser, operate, filename string, isSuccess bool)

func (*AssetDir) GetSFTPAndRealPath

func (ad *AssetDir) GetSFTPAndRealPath(su *model.SystemUser, path string) (conn *SftpConn, realPath string)

func (*AssetDir) GetSftpClient

func (ad *AssetDir) GetSftpClient(su *model.SystemUser) (conn *SftpConn, err error)

func (*AssetDir) IsDir

func (ad *AssetDir) IsDir() bool

func (*AssetDir) IsUniqueSu

func (ad *AssetDir) IsUniqueSu() (folderName string, ok bool)

func (*AssetDir) MkdirAll

func (ad *AssetDir) MkdirAll(path string) (err error)

func (*AssetDir) ModTime

func (ad *AssetDir) ModTime() time.Time

func (*AssetDir) Mode

func (ad *AssetDir) Mode() os.FileMode

func (*AssetDir) Name

func (ad *AssetDir) Name() string

func (*AssetDir) Open

func (ad *AssetDir) Open(path string) (*sftp.File, error)

func (*AssetDir) ReadDir

func (ad *AssetDir) ReadDir(path string) (res []os.FileInfo, err error)
func (ad *AssetDir) ReadLink(path string) (res string, err error)

func (*AssetDir) Remove

func (ad *AssetDir) Remove(path string) (err error)

func (*AssetDir) RemoveDirectory

func (ad *AssetDir) RemoveDirectory(path string) (err error)

func (*AssetDir) Rename

func (ad *AssetDir) Rename(oldNamePath, newNamePath string) (err error)

func (*AssetDir) Size

func (ad *AssetDir) Size() int64

func (*AssetDir) Stat

func (ad *AssetDir) Stat(path string) (res os.FileInfo, err error)
func (ad *AssetDir) Symlink(oldNamePath, newNamePath string) (err error)

func (*AssetDir) Sys

func (ad *AssetDir) Sys() interface{}

type FakeFileInfo

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

func NewFakeFile

func NewFakeFile(name string, isDir bool) *FakeFileInfo

func NewFakeSymFile

func NewFakeSymFile(name string) *FakeFileInfo

func (*FakeFileInfo) IsDir

func (f *FakeFileInfo) IsDir() bool

func (*FakeFileInfo) ModTime

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

func (*FakeFileInfo) Mode

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

func (*FakeFileInfo) Name

func (f *FakeFileInfo) Name() string

func (*FakeFileInfo) Size

func (f *FakeFileInfo) Size() int64

func (*FakeFileInfo) Sys

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

type FileInfoList

type FileInfoList []os.FileInfo

func (FileInfoList) Len

func (fl FileInfoList) Len() int

func (FileInfoList) Less

func (fl FileInfoList) Less(i, j int) bool

func (FileInfoList) Swap

func (fl FileInfoList) Swap(i, j int)

type NodeDir

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

func NewNodeDir

func NewNodeDir(node model.Node) NodeDir

func (*NodeDir) IsDir

func (nd *NodeDir) IsDir() bool

func (*NodeDir) List

func (nd *NodeDir) List() (res []os.FileInfo, err error)

func (*NodeDir) ModTime

func (nd *NodeDir) ModTime() time.Time

func (*NodeDir) Mode

func (nd *NodeDir) Mode() os.FileMode

func (*NodeDir) Name

func (nd *NodeDir) Name() string

func (*NodeDir) Size

func (nd *NodeDir) Size() int64

func (*NodeDir) Sys

func (nd *NodeDir) Sys() interface{}

type SSHClientConfig

type SSHClientConfig struct {
	Host           string        `json:"host"`
	Port           string        `json:"port"`
	User           string        `json:"user"`
	Password       string        `json:"password"`
	PrivateKey     string        `json:"private_key"`
	PrivateKeyPath string        `json:"private_key_path"`
	Timeout        time.Duration `json:"timeout"`
	Proxy          []*SSHClientConfig
	// contains filtered or unexported fields
}

func MakeConfig

func MakeConfig(asset *model.Asset, systemUser *model.SystemUser, timeout time.Duration) (conf *SSHClientConfig)

func (*SSHClientConfig) Config

func (sc *SSHClientConfig) Config() (config *gossh.ClientConfig, err error)

func (*SSHClientConfig) Dial

func (sc *SSHClientConfig) Dial() (client *gossh.Client, err error)

func (*SSHClientConfig) DialProxy

func (sc *SSHClientConfig) DialProxy() (client *gossh.Client, err error)

func (*SSHClientConfig) String

func (sc *SSHClientConfig) String() string

type SSHManager

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

func (*SSHManager) AddClientCache

func (s *SSHManager) AddClientCache(key string, client *sshClient)

type SearchResultDir

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

func (*SearchResultDir) IsDir

func (sd *SearchResultDir) IsDir() bool

func (*SearchResultDir) List

func (sd *SearchResultDir) List() (res []os.FileInfo, err error)

func (*SearchResultDir) ModTime

func (sd *SearchResultDir) ModTime() time.Time

func (*SearchResultDir) Mode

func (sd *SearchResultDir) Mode() os.FileMode

func (*SearchResultDir) Name

func (sd *SearchResultDir) Name() string

func (*SearchResultDir) SetSubDirs

func (sd *SearchResultDir) SetSubDirs(subDirs map[string]os.FileInfo)

func (*SearchResultDir) Size

func (sd *SearchResultDir) Size() int64

func (*SearchResultDir) Sys

func (sd *SearchResultDir) Sys() interface{}

type ServerConnection

type ServerConnection interface {
	io.ReadWriteCloser
	Protocol() string
	SetWinSize(width, height int) error
}

type ServerMysqlConnection

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

func NewMysqlServer

func NewMysqlServer(ops ...SqlOption) *ServerMysqlConnection

func (*ServerMysqlConnection) Close

func (dbconn *ServerMysqlConnection) Close() (err error)

func (*ServerMysqlConnection) Connect

func (dbconn *ServerMysqlConnection) Connect() (err error)

func (*ServerMysqlConnection) Protocol

func (dbconn *ServerMysqlConnection) Protocol() string

func (*ServerMysqlConnection) Read

func (dbconn *ServerMysqlConnection) Read(p []byte) (int, error)

func (*ServerMysqlConnection) SetWinSize

func (dbconn *ServerMysqlConnection) SetWinSize(w, h int) error

func (*ServerMysqlConnection) Timeout

func (dbconn *ServerMysqlConnection) Timeout() time.Duration

func (*ServerMysqlConnection) Write

func (dbconn *ServerMysqlConnection) Write(p []byte) (int, error)

type ServerSSHConnection

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

func NewServerSSHConnection

func NewServerSSHConnection(sess *gossh.Session) *ServerSSHConnection

func (*ServerSSHConnection) Close

func (sc *ServerSSHConnection) Close() (err error)

func (*ServerSSHConnection) Connect

func (sc *ServerSSHConnection) Connect(h, w int, term string) (err error)

func (*ServerSSHConnection) Protocol

func (sc *ServerSSHConnection) Protocol() string

func (*ServerSSHConnection) Read

func (sc *ServerSSHConnection) Read(p []byte) (n int, err error)

func (*ServerSSHConnection) SetWinSize

func (sc *ServerSSHConnection) SetWinSize(w, h int) error

func (*ServerSSHConnection) Write

func (sc *ServerSSHConnection) Write(p []byte) (n int, err error)

type ServerTelnetConnection

type ServerTelnetConnection struct {
	User                 *model.User
	Asset                *model.Asset
	SystemUser           *model.SystemUser
	Overtime             time.Duration
	CustomString         string
	CustomSuccessPattern *regexp.Regexp
	// contains filtered or unexported fields
}

func (*ServerTelnetConnection) Close

func (tc *ServerTelnetConnection) Close() (err error)

func (*ServerTelnetConnection) Connect

func (tc *ServerTelnetConnection) Connect(h, w int, term string) (err error)

func (*ServerTelnetConnection) Protocol

func (tc *ServerTelnetConnection) Protocol() string

func (*ServerTelnetConnection) Read

func (tc *ServerTelnetConnection) Read(p []byte) (n int, err error)

func (*ServerTelnetConnection) SetWinSize

func (tc *ServerTelnetConnection) SetWinSize(w, h int) error

func (*ServerTelnetConnection) Timeout

func (tc *ServerTelnetConnection) Timeout() time.Duration

func (*ServerTelnetConnection) Write

func (tc *ServerTelnetConnection) Write(p []byte) (n int, err error)

type SftpConn

type SftpConn struct {
	HomeDirPath string
	// contains filtered or unexported fields
}

func (*SftpConn) Close

func (s *SftpConn) Close()

type SqlOption

type SqlOption func(*SqlOptions)

func SqlDBName

func SqlDBName(dbName string) SqlOption

func SqlHost

func SqlHost(host string) SqlOption

func SqlPassword

func SqlPassword(password string) SqlOption

func SqlPort

func SqlPort(port int) SqlOption

func SqlUsername

func SqlUsername(username string) SqlOption

type SqlOptions

type SqlOptions struct {
	Username string
	Password string
	DBName   string
	Host     string
	Port     int
}

func (*SqlOptions) CommandArgs

func (opts *SqlOptions) CommandArgs() []string

func (*SqlOptions) Envs

func (opts *SqlOptions) Envs() []string

type UserSSHClient

type UserSSHClient struct {
	ID string // userID_assetID_systemUserID_systemUsername
	// contains filtered or unexported fields
}

func (*UserSSHClient) AddClient

func (u *UserSSHClient) AddClient(client *sshClient)

func (*UserSSHClient) DeleteClient

func (u *UserSSHClient) DeleteClient(client *sshClient)

func (*UserSSHClient) GetClient

func (u *UserSSHClient) GetClient() *sshClient

type UserSftpConn

type UserSftpConn struct {
	User *model.User
	Addr string
	Dirs map[string]os.FileInfo
	// contains filtered or unexported fields
}

func NewUserSftpConn

func NewUserSftpConn(user *model.User, addr string) *UserSftpConn

func NewUserSftpConnWithAssets

func NewUserSftpConnWithAssets(user *model.User, addr string, assets ...model.Asset) *UserSftpConn

func (*UserSftpConn) Close

func (u *UserSftpConn) Close()

func (*UserSftpConn) Create

func (u *UserSftpConn) Create(path string) (*sftp.File, error)

func (*UserSftpConn) IsDir

func (u *UserSftpConn) IsDir() bool

func (*UserSftpConn) List

func (u *UserSftpConn) List() (res []os.FileInfo, err error)

func (*UserSftpConn) MkdirAll

func (u *UserSftpConn) MkdirAll(path string) (err error)

func (*UserSftpConn) ModTime

func (u *UserSftpConn) ModTime() time.Time

func (*UserSftpConn) Mode

func (u *UserSftpConn) Mode() os.FileMode

func (*UserSftpConn) Name

func (u *UserSftpConn) Name() string

func (*UserSftpConn) Open

func (u *UserSftpConn) Open(path string) (*sftp.File, error)

func (*UserSftpConn) ParsePath

func (u *UserSftpConn) ParsePath(path string) (fi os.FileInfo, restPath string)

func (*UserSftpConn) ReadDir

func (u *UserSftpConn) ReadDir(path string) (res []os.FileInfo, err error)
func (u *UserSftpConn) ReadLink(path string) (name string, err error)

func (*UserSftpConn) Remove

func (u *UserSftpConn) Remove(path string) (err error)

func (*UserSftpConn) RemoveDirectory

func (u *UserSftpConn) RemoveDirectory(path string) (err error)

func (*UserSftpConn) Rename

func (u *UserSftpConn) Rename(oldNamePath, newNamePath string) (err error)

func (*UserSftpConn) Search

func (u *UserSftpConn) Search(key string) (res []os.FileInfo, err error)

func (*UserSftpConn) Size

func (u *UserSftpConn) Size() int64

func (*UserSftpConn) Stat

func (u *UserSftpConn) Stat(path string) (res os.FileInfo, err error)
func (u *UserSftpConn) Symlink(oldNamePath, newNamePath string) (err error)

func (*UserSftpConn) Sys

func (u *UserSftpConn) Sys() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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