srvconn

package
v0.0.0-...-ec5e93e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolSSH = "ssh"
)

Variables

View Source
var (
	ErrGatewayDial = errors.New("gateway dial addr failed")
	ErrSSHClient   = errors.New("new ssh client failed")
)
View Source
var (
	ErrUnSupportedProtocol = errors.New("unsupported protocol")
)

Functions

func AddClientCache

func AddClientCache(key string, client *SSHClient)

func IsSupportedProtocol

func IsSupportedProtocol(p string) error

func MakeReuseSSHClientKey

func MakeReuseSSHClientKey(userId, assetId, systemUserId,
	ip, username string) string

Types

type SSHClient

type SSHClient struct {
	*gossh.Client
	Cfg         *SSHClientOptions
	ProxyClient *SSHClient

	sync.Mutex
	// contains filtered or unexported fields
}

func GetClientFromCache

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

func NewSSHClient

func NewSSHClient(opts ...SSHClientOption) (*SSHClient, error)

func NewSSHClientWithCfg

func NewSSHClientWithCfg(cfg *SSHClientOptions) (*SSHClient, error)

func (*SSHClient) AcquireSession

func (s *SSHClient) AcquireSession() (*gossh.Session, error)

func (*SSHClient) Close

func (s *SSHClient) Close() error

func (*SSHClient) RefCount

func (s *SSHClient) RefCount() int32

func (*SSHClient) ReleaseSession

func (s *SSHClient) ReleaseSession(sess *gossh.Session)

func (*SSHClient) String

func (s *SSHClient) String() string

type SSHClientOption

type SSHClientOption func(conf *SSHClientOptions)

func BuildSSHClientOptions

func BuildSSHClientOptions(asset *model.Asset, systemUser *model.SystemUser) []SSHClientOption

func SSHClientHost

func SSHClientHost(host string) SSHClientOption

func SSHClientKeyboardAuth

func SSHClientKeyboardAuth(keyboardAuth gossh.KeyboardInteractiveChallenge) SSHClientOption

func SSHClientPassphrase

func SSHClientPassphrase(passphrase string) SSHClientOption

func SSHClientPassword

func SSHClientPassword(password string) SSHClientOption

func SSHClientPort

func SSHClientPort(port int) SSHClientOption

func SSHClientPrivateAuth

func SSHClientPrivateAuth(privateAuth gossh.Signer) SSHClientOption

func SSHClientPrivateKey

func SSHClientPrivateKey(privateKey string) SSHClientOption

func SSHClientTimeout

func SSHClientTimeout(timeout int) SSHClientOption

func SSHClientUsername

func SSHClientUsername(username string) SSHClientOption

type SSHClientOptions

type SSHClientOptions struct {
	Host       string
	Port       string
	Username   string
	Password   string
	PrivateKey string
	Passphrase string
	Timeout    int

	PrivateAuth gossh.Signer
	// contains filtered or unexported fields
}

func (*SSHClientOptions) AuthMethods

func (cfg *SSHClientOptions) AuthMethods() []gossh.AuthMethod

type SSHConnection

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

func NewSSHConnection

func NewSSHConnection(sess *gossh.Session, opts ...SSHOption) (*SSHConnection, error)

func (*SSHConnection) Close

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

func (*SSHConnection) KeepAlive

func (sc *SSHConnection) KeepAlive() error

func (*SSHConnection) Read

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

func (*SSHConnection) SetWinSize

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

func (*SSHConnection) Write

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

type SSHManager

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

func (*SSHManager) AddClientCache

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

type SSHOption

type SSHOption func(*SSHOptions)

func SSHPtyWin

func SSHPtyWin(win Windows) SSHOption

func SSHTerm

func SSHTerm(termType string) SSHOption

type SSHOptions

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

type ServerConnection

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

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) Count

func (u *UserSSHClient) Count() int

func (*UserSSHClient) GetClient

func (u *UserSSHClient) GetClient() *SSHClient

type Windows

type Windows struct {
	Width  int
	Height int
}

Jump to

Keyboard shortcuts

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