webshell

package
v0.0.0-...-66ffdac Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServerSystemInfo

func ServerSystemInfo(c *gin.Context)

ServerSystemInfo 一个查询对应接入的服务器的运行状态的接口

func SftPUpload

func SftPUpload(c *gin.Context)

SftPUpload 上传一个文件

func SftpCat

func SftpCat(c *gin.Context)

SftpCat 获取sftp文件

func SftpCreate

func SftpCreate(login SftpLoginModel) (*goSftp.Client, error)

SftpCreate 创建一个sftp连接

func SftpDownload

func SftpDownload(c *gin.Context)

SftpDownload 通过sftp下载文件

func SftpLs

func SftpLs(c *gin.Context)

SftpLs 获取对应文件列表

func SftpMkdir

func SftpMkdir(c *gin.Context)

SftpMkdir sftp的创建文件夹接口

func SftpRenameEndpoint

func SftpRenameEndpoint(c *gin.Context)

SftpRenameEndpoint sftp的文件或文件夹重命名接口

func SftpRm

func SftpRm(c *gin.Context)

SftpRm sftp的删除接口

func SshRemoteRunCommand

func SshRemoteRunCommand(sshClient *ssh.Client, command string) (string, error)

SshRemoteRunCommand 通过链接ssh远程执行命令

func WebSocketHandler

func WebSocketHandler(w http.ResponseWriter, r *http.Request, checkUserToken func(string) bool, getServerInfo func(string, int, int) SshLoginModel)

WebSocketHandler 启动一个WS并进行SSH数据交互

Types

type File

type File struct {
	Name    string   `json:"name"`
	Path    string   `json:"path"`
	IsDir   bool     `json:"isDir"`
	Mode    string   `json:"mode"`
	IsLink  bool     `json:"isLink"`
	ModTime mod.Time `json:"modTime"`
	Size    int64    `json:"size"`
}

type HardwareInfo

type HardwareInfo struct {
	Disk    string `json:"hi_disk"`
	Mem     string `json:"hi_mem"`
	NetCard string `json:"hi_net_card"`
	Cpu     string `json:"hi_cpu"`
	System  string `json:"hi_system"`
	Login   string `json:"hi_login"`
	Ps      string `json:"hi_ps"`
	Port    string `json:"hi_port"`
}

func CreateHardwareInfo

func CreateHardwareInfo(sid string, cols int, rows int) (hi *HardwareInfo, err error)

CreateHardwareInfo 获取对应服务器的运行信息

type Request

type Request struct {
	MsgType  int    `json:"msg_type"`  //如果为1进行ssh连接验证为2进行代码执行
	Token    string `json:"token"`     //用户token
	ServerID string `json:"server_id"` //wehShell服务器id
	Command  string `json:"command"`   //用户命令
	Cols     int    `json:"cols"`      //终端窗口的列数, 可以在创建Terminal指定cols(大概和分辨率的比拟是1:7.5)
	Rows     int    `json:"rows"`      //终端窗口的行数, 可以在创建Terminal指定rows(大概和分辨率的比拟是1:18)
}

Request WS数据接受结构体

type ServerInfo

type ServerInfo struct {
	mod.Model
	Memo          string `gorm:"column:memo;size:128;" json:"memo" form:"memo"`                                        // 备注
	ServerAddress string `gorm:"column:server_address;size:128;not null;" json:"server_address" form:"server_address"` // 服务器地址
	UserName      string `gorm:"column:user_name;size:128;not null;" json:"user_name" form:"user_name"`                // 登录用户名
	SshType       int    `json:"ssh_type" gorm:"column:ssh_type;default:1" form:"ssh_type"`                            // 鉴权方式,默认1是password 2是key
	Password      string `gorm:"column:password;type:char(128);not null;" json:"password" form:"password"`             // 登录密码
	AliasName     string `gorm:"column:alias_name;size:64;" json:"alias_name" form:"alias_name"`                       // 服务器别名
	UpdateUser    string `json:"update_user" gorm:"comment:'更新人'"`                                                     // 更新人
}

ServerInfo 服务器信息

func (ServerInfo) AddShell

func (ServerInfo) AddShell(c *gin.Context)

AddShell 新增服务器

func (ServerInfo) DelShell

func (ServerInfo) DelShell(c *gin.Context)

DelShell 删除服务器

func (ServerInfo) EditShell

func (ServerInfo) EditShell(c *gin.Context)

EditShell 修改服务器

func (ServerInfo) GetShellList

func (ServerInfo) GetShellList(c *gin.Context)

GetShellList 查看服务器列表

func (ServerInfo) Ws

func (ServerInfo) Ws(c *gin.Context)

Ws 开启一个ws传输shell数据

type SftpLoginModel

type SftpLoginModel struct {
	SshType int
	// contains filtered or unexported fields
}

type SshLoginModel

type SshLoginModel struct {
	Addr     string
	UserName string
	SshType  int
	Pwd      string
	PemKey   string
	PtyCols  uint32
	PtyRows  uint32
}

Jump to

Keyboard shortcuts

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