xclient

package
v0.0.0-...-f274578 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotRecommendCiphers = []string{
		"arcfour256", "arcfour128", "arcfour",
		"aes128-cbc", "3des-cbc",
	}

	NotRecommendKeyExchanges = []string{
		"diffie-hellman-group1-sha1", "diffie-hellman-group-exchange-sha1",
		"diffie-hellman-group-exchange-sha256",
	}
)

Functions

func InitSSHConfig

func InitSSHConfig() ssh.Config

Types

type GwSSHClient

type GwSSHClient struct {
	sync.Mutex
	*ssh.Client
	Config *SSHClientOptions

	//代理连接
	ProxyClient *SSHClient
	// contains filtered or unexported fields
}

func NewGwSSHClient

func NewGwSSHClient(opts ...SSHClientOption) (*GwSSHClient, error)

初始化网关用的SSH客户端

func NewSSHClientWithCfg

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

初始化网关用的SSH客户端

func (*GwSSHClient) AcquireSession

func (s *GwSSHClient) AcquireSession() (*ssh.Session, error)

获取复用连接

func (*GwSSHClient) Close

func (s *GwSSHClient) Close() error

func (*GwSSHClient) GetReferenceCount

func (s *GwSSHClient) GetReferenceCount() int32

获取连接引用计数

func (*GwSSHClient) ReleaseSession

func (s *GwSSHClient) ReleaseSession(sshSession *ssh.Session)

func (*GwSSHClient) String

func (s *GwSSHClient) String() string

type SSHClientOption

type SSHClientOption func(conf *SSHClientOptions)

func SetSSHClientHost

func SetSSHClientHost(host string) SSHClientOption

func SetSSHClientKeyboardAuth

func SetSSHClientKeyboardAuth(keyboardAuth ssh.KeyboardInteractiveChallenge) SSHClientOption

func SetSSHClientPassphrase

func SetSSHClientPassphrase(passphrase string) SSHClientOption

func SetSSHClientPassword

func SetSSHClientPassword(password string) SSHClientOption

func SetSSHClientPort

func SetSSHClientPort(port int) SSHClientOption

func SetSSHClientPrivateAuth

func SetSSHClientPrivateAuth(privateAuth ssh.Signer) SSHClientOption

func SetSSHClientPrivateKey

func SetSSHClientPrivateKey(privateKey string) SSHClientOption

func SetSSHClientTimeout

func SetSSHClientTimeout(timeout int) SSHClientOption

func SetSSHClientUsername

func SetSSHClientUsername(username string) SSHClientOption

type SSHClientOptions

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

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

type SSHClientsManager

type SSHClientsManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSSHClientsManager

func NewSSHClientsManager() *SSHClientsManager

func (*SSHClientsManager) GetClientsMap

func (m *SSHClientsManager) GetClientsMap() map[string]*UserSSHClient

type SShClient2Add

type SShClient2Add struct {
	UniqId string
	*GwSSHClient
}

type UserSSHClient

type UserSSHClient struct {
	UniqId string // uniqid
	// contains filtered or unexported fields
}

func NewUserSSHClient

func NewUserSSHClient(uniq_id string) *UserSSHClient

func (*UserSSHClient) AddSshClient

func (c *UserSSHClient) AddSshClient(client *GwSSHClient)

加入ssh-client

func (*UserSSHClient) Count

func (c *UserSSHClient) Count() int

func (*UserSSHClient) GetSshClient

func (c *UserSSHClient) GetSshClient() (*GwSSHClient, error)

获取可用的client

func (*UserSSHClient) Recycle

func (c *UserSSHClient) Recycle()

回收引用数为0的clients

func (*UserSSHClient) RemoveSshClient

func (c *UserSSHClient) RemoveSshClient(client *GwSSHClient)

Jump to

Keyboard shortcuts

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