Documentation
¶
Index ¶
- type Service
- type ServiceImpl
- func (s *ServiceImpl) CloseHostSessions(hostID string)
- func (s *ServiceImpl) CreateSession(ctx context.Context, hostID, clientIP, userID string) (string, error)
- func (s *ServiceImpl) DisconnectSession(ctx context.Context, sessionID string) error
- func (s *ServiceImpl) GetSessionConn(sessionID string) (*conn.SSHConn, bool)
- func (s *ServiceImpl) GetSessionManager() *conn.SessionManager
- func (s *ServiceImpl) ResizeWindow(ctx context.Context, sessionID string, w, h int) error
- func (s *ServiceImpl) SessionBelongsToUser(sessionID, userID string) bool
- func (s *ServiceImpl) SftpDelete(ctx context.Context, sessionID, filePath string) error
- func (s *ServiceImpl) SftpDownload(ctx context.Context, sessionID, filePath string) (*sftp.File, int64, string, error)
- func (s *ServiceImpl) SftpList(ctx context.Context, sessionID string, dirPath string) (interface{}, error)
- func (s *ServiceImpl) SftpMkdir(ctx context.Context, sessionID, dirPath string) error
- func (s *ServiceImpl) SftpUpload(ctx context.Context, sessionID string, dstPath string, ...) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service interface {
// SSH 会话。主机来自登记表 t_hosts,终端与文件只能连接登记了 SSH 信息的主机。
CreateSession(ctx context.Context, hostID, clientIP, userID string) (string, error)
DisconnectSession(ctx context.Context, sessionID string) error
// CloseHostSessions 关闭某台主机上全部在线会话(主机连接信息变化或被删除后调用)。
CloseHostSessions(hostID string)
ResizeWindow(ctx context.Context, sessionID string, w, h int) error
GetSessionConn(sessionID string) (*conn.SSHConn, bool)
SessionBelongsToUser(sessionID, userID string) bool
// SFTP
SftpList(ctx context.Context, sessionID string, dirPath string) (interface{}, error)
SftpUpload(ctx context.Context, sessionID string, dstPath string, files []*multipart.FileHeader) ([]string, error)
SftpDownload(ctx context.Context, sessionID, filePath string) (*sftp.File, int64, string, error)
SftpDelete(ctx context.Context, sessionID, path string) error
SftpMkdir(ctx context.Context, sessionID, path string) error
// 获取会话管理器(供 WebSocket handler 使用)
GetSessionManager() *conn.SessionManager
}
Service SSH 服务接口
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
ServiceImpl SSH 服务实现
func (*ServiceImpl) CloseHostSessions ¶
func (s *ServiceImpl) CloseHostSessions(hostID string)
func (*ServiceImpl) CreateSession ¶
func (*ServiceImpl) DisconnectSession ¶
func (s *ServiceImpl) DisconnectSession(ctx context.Context, sessionID string) error
func (*ServiceImpl) GetSessionConn ¶
func (s *ServiceImpl) GetSessionConn(sessionID string) (*conn.SSHConn, bool)
func (*ServiceImpl) GetSessionManager ¶
func (s *ServiceImpl) GetSessionManager() *conn.SessionManager
GetSessionManager 获取会话管理器
func (*ServiceImpl) ResizeWindow ¶
func (*ServiceImpl) SessionBelongsToUser ¶
func (s *ServiceImpl) SessionBelongsToUser(sessionID, userID string) bool
func (*ServiceImpl) SftpDelete ¶
func (s *ServiceImpl) SftpDelete(ctx context.Context, sessionID, filePath string) error
func (*ServiceImpl) SftpDownload ¶
func (*ServiceImpl) SftpMkdir ¶
func (s *ServiceImpl) SftpMkdir(ctx context.Context, sessionID, dirPath string) error
func (*ServiceImpl) SftpUpload ¶
func (s *ServiceImpl) SftpUpload(ctx context.Context, sessionID string, dstPath string, files []*multipart.FileHeader) ([]string, error)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dao 读取 SSH 连接需要的主机登记与凭据,并记录主机密钥指纹。
|
Package dao 读取 SSH 连接需要的主机登记与凭据,并记录主机密钥指纹。 |
|
Package model 定义 SSH 服务使用的数据结构。
|
Package model 定义 SSH 服务使用的数据结构。 |
|
Package rpc 提供 ssh 直连端点(WebSocket 终端、SFTP 流式上传/下载)的裸 HTTP 处理器, 经统一 HTTP 转发层 rawhandler 分派。
|
Package rpc 提供 ssh 直连端点(WebSocket 终端、SFTP 流式上传/下载)的裸 HTTP 处理器, 经统一 HTTP 转发层 rawhandler 分派。 |
Click to show internal directories.
Click to hide internal directories.