controllers

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPreviewSize = 8 * 1024 * 1024
	Utf8Dom        = "\xEF\xBB\xBF"
)
View Source
const (
	HttpStatusOk        = "200"
	HttpStatusError     = "400"
	HttpResponseSuccess = "success"
)
View Source
const IndexPage = "dist/index.html"

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	*gin.Context
}

func (*Context) ResponseError

func (c *Context) ResponseError(msg string)

func (*Context) ResponseOk

func (c *Context) ResponseOk(data interface{})

type FileInfo

type FileInfo struct {
	Id            string    `json:"id"`
	Name          string    `json:"name"`
	ModTime       time.Time `json:"modDate"`
	Size          int64     `json:"size"`
	IsDir         bool      `json:"isDir,omitempty"`
	IsSymlink     bool      `json:"isSymlink,omitempty"`
	IsHidden      bool      `json:"isHidden,omitempty"`
	Ext           string    `json:"ext"`
	ChildrenCount int       `json:"childrenCount,omitempty"`
	ParentId      string    `json:"parentId,omitempty"`
	ChildrenIds   []string  `json:"children_ids,omitempty"`
	Icon          string    `json:"icon,omitempty"`
}

type FilePath

type FilePath struct {
	Files        []*FileInfo `json:"files"`
	FolderChains []*FileInfo `json:"folderChains"`
}

type Service

type Service struct {
	Engine *gin.Engine
	Addr   string
	Logger *logger.Logger
	// contains filtered or unexported fields
}

func NewService

func NewService(conf config.App, sshManager *ssh.Manager, taskManager *task.Manager, tunnelManager *tunnel.Manager) *Service

func (*Service) CacheUpload

func (s *Service) CacheUpload(c *Context)

CacheUpload @Summary 上传临时文件 @Description 上传临时文件 @Param files formData file true "multi文件" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /cache/upload [post]

func (*Service) DataExport

func (s *Service) DataExport(c *Context)

DataExport @Summary 导出资产文件csv @Description 导出资产文件csv @Tags tool @Accept x-www-form-urlencoded @Produce application/octet-stream @Success 200 @Failure 400 {object} payload.Response @Router /tools/export [get]

func (*Service) DataImport

func (s *Service) DataImport(c *Context)

DataImport @Summary 导入资产文件csv @Description 导入资产文件csv @Param files formData file true "csv文件" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.HostExport} @Failure 400 {object} payload.Response @Router /tools/import [post]

func (*Service) DeleteCommandHistory

func (s *Service) DeleteCommandHistory(c *Context)

DeleteCommandHistory @Summary 删除命令历史 @Description 删除命令历史 @Param id path int true "命令历史 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /command/history/{id} [delete]

func (*Service) DeleteFile

func (s *Service) DeleteFile(c *Context)

DeleteFile @Summary 删除文件 @Description 删除文件 @Param id formData string true "远端文件路径" @Param host_id formData integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/delete [post]

func (*Service) DeleteFileOrDir

func (s *Service) DeleteFileOrDir(hostId int, path string) error

func (*Service) DeleteGroup

func (s *Service) DeleteGroup(c *Context)

DeleteGroup @Summary 删除组 @Description 删除组 @Param id path int true "组 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /group/{id} [delete]

func (*Service) DeleteHost

func (s *Service) DeleteHost(c *Context)

DeleteHost @Summary 删除主机 @Description 删除主机 @Param id path int true "主机 ID" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /host/{id} [delete]

func (*Service) DeleteInstances

func (s *Service) DeleteInstances(c *Context)

DeleteInstances @Summary 删除任务执行结果 @Description 删除任务执行结果 @Param job_id formData integer false "任务 ID" @Param time_stamp formData integer false "截止时间戳(之前的数据都将删除)" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /task/instance [delete]

func (*Service) DeleteJob

func (s *Service) DeleteJob(c *Context)

DeleteJob @Summary 删除任务 @Description 删除任务 @Param id path int true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /job/{id} [delete]

func (*Service) DeletePlayBook

func (s *Service) DeletePlayBook(c *Context)

DeletePlayBook @Summary 删除剧本 @Description 删除剧本 @Param id path int true "剧本 ID" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /player/{id} [delete]

func (*Service) DeletePrivateKey

func (s *Service) DeletePrivateKey(c *Context)

DeletePrivateKey @Summary 删除密钥 @Description 删除密钥 @Param id path int true "密钥 ID" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /private_key/{id} [delete]

func (*Service) DeleteQuicklyCommand

func (s *Service) DeleteQuicklyCommand(c *Context)

DeleteQuicklyCommand @Summary 删除快捷命令 @Description 删除快捷命令 @Param id path int true "快捷命令 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /quick_command/{id} [delete]

func (*Service) DeleteTag

func (s *Service) DeleteTag(c *Context)

DeleteTag @Summary 删除标签 @Description 删除标签 @Param id path int true "标签 ID" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tag/{id} [delete]

func (*Service) DeleteTunnel

func (s *Service) DeleteTunnel(c *Context)

DeleteTunnel @Summary 删除隧道 @Description 删除隧道 @Param id path int true "隧道 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tunnel/{id} [delete]

func (*Service) DownLoadFile

func (s *Service) DownLoadFile(c *Context)

DownLoadFile @Summary 下载文件 @Description 下载文件 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce application/octet-stream @Success 200 @Failure 400 {object} payload.Response @Router /tools/download [get]

func (*Service) DownloadFile

func (s *Service) DownloadFile(hostId int, path string) *sftp.File

func (*Service) DownloadInstanceLog

func (s *Service) DownloadInstanceLog(c *Context)

func (*Service) ExecJob

func (s *Service) ExecJob(c *Context)

ExecJob @Summary 单次执行任务 @Description 单次执行任务 @Param id formData integer true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/exec [post]

func (*Service) FilePreview

func (s *Service) FilePreview(c *Context)

FilePreview @Summary 文件预览 @Description 文件预览 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/preview [get]

func (*Service) FileUploadCancel

func (s *Service) FileUploadCancel(c *Context)

FileUploadCancel @Summary 取消文件上传任务 @Description 取消文件上传任务 @Param addr formData string true "地址和端口" @Param file formData string true "文件名" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/upload/cancel [post]

func (*Service) FileUploadV2

func (s *Service) FileUploadV2(c *Context)

FileUploadV2 @Summary 上传文件到主机 @Description 上传文件到主机 @Param X-Files header string true "预处理文件列表" example({"filename base64": "file.size"}) @Param id formData integer true "执行者 ID" @Param type formData string true "执行者类型" example(host,group,tag) @Param remote formData string true "远端文件夹" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/upload [post]

func (*Service) GetCommandHistory

func (s *Service) GetCommandHistory(c *Context)

GetCommandHistory @Summary 模糊查询历史命令 @Description 模糊查询历史命令 @Param keyword query string true "关键词" @Param limit query integer false "limit" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]string} @Failure 400 {object} payload.Response @Router /command/history [get]

func (*Service) GetGroups

func (s *Service) GetGroups(c *Context)

GetGroups @Summary 获取所有组 @Description 获取所有组 @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Group} @Failure 400 {object} payload.Response @Router /group [get]

func (*Service) GetHosts

func (s *Service) GetHosts(c *Context)

GetHosts @Summary 获取所有主机 @Description 获取所有主机 @Param page_num query int false "页码数" @Param page_size query int false "分页尺寸" default(20) @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Host} @Failure 400 {object} payload.Response @Router /host [get]

func (*Service) GetIndexPage

func (s *Service) GetIndexPage(c *gin.Context)

func (*Service) GetInstanceLog

func (s *Service) GetInstanceLog(c *Context)

GetInstanceLog @Summary 获取任务执行日志 @Description 获取任务执行日志 @Param id query integer true "执行记录 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /task/instance/log/get [get]

func (*Service) GetInstances

func (s *Service) GetInstances(c *Context)

GetInstances @Summary 获取所有任务执行结果 @Description 获取所有任务执行结果 @Param job_id query int false "任务 ID" @Param page_num query int false "页码数" @Param page_size query int false "分页尺寸" default(20) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.TaskInstance} @Failure 400 {object} payload.Response @Router /task/instance [get]

func (*Service) GetJobs

func (s *Service) GetJobs(c *Context)

GetJobs @Summary 获取所有任务 @Description 获取所有任务 @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Job} @Failure 400 {object} payload.Response @Router /job [get]

func (*Service) GetOneGroup

func (s *Service) GetOneGroup(c *Context)

GetOneGroup @Summary 获取单个组 @Description 获取单个组 @Param id path int true "组 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group/{id} [get]

func (*Service) GetOneHost

func (s *Service) GetOneHost(c *Context)

GetOneHost @Summary 获取单个主机 @Description 获取单个主机 @Param id path int true "主机 ID" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host/{id} [get]

func (*Service) GetOneJob

func (s *Service) GetOneJob(c *Context)

GetOneJob @Summary 获取单个任务 @Description 获取单个任务 @Param id path int true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/{id} [get]

func (*Service) GetOnePlayBook

func (s *Service) GetOnePlayBook(c *Context)

GetOnePlayBook @Summary 获取单个剧本 @Description 获取单个剧本 @Param id path int true "剧本 ID" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player/{id} [get]

func (*Service) GetOnePrivateKey

func (s *Service) GetOnePrivateKey(c *Context)

GetOnePrivateKey @Summary 获取单个密钥 @Description 获取单个密钥 @Param id path int true "密钥 ID" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key/{id} [get]

func (*Service) GetOneQuicklyCommand

func (s *Service) GetOneQuicklyCommand(c *Context)

GetOneQuicklyCommand @Summary 获取单个快捷命令 @Description 获取单个快捷命令 @Param id path int true "快捷命令 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command/{id} [get]

func (*Service) GetOneTag

func (s *Service) GetOneTag(c *Context)

GetOneTag @Summary 获取单个标签 @Description 获取单个标签 @Param id path int true "标签 ID" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag/{id} [get]

func (*Service) GetOneTunnel

func (s *Service) GetOneTunnel(c *Context)

GetOneTunnel @Summary 获取单个隧道 @Description 获取单个隧道 @Param id path int true "隧道 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel/{id} [get]

func (*Service) GetPathInfo

func (s *Service) GetPathInfo(c *Context)

GetPathInfo @Summary 目录列表 @Description 目录列表 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=FilePath} @Failure 400 {object} payload.Response @Router /tools/browse [get]

func (*Service) GetPathInfoExec

func (s *Service) GetPathInfoExec(hostId int, p string) (*FilePath, error)

func (*Service) GetPlayBooks

func (s *Service) GetPlayBooks(c *Context)

GetPlayBooks @Summary 获取所有剧本 @Description 获取所有剧本 @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.PlayBook} @Failure 400 {object} payload.Response @Router /player [get]

func (*Service) GetPluginSchema

func (s *Service) GetPluginSchema(c *Context)

GetPluginSchema @Summary 获取所有插件Schema @Description 获取所有插件Schema @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]ssh.Schema} @Failure 400 {object} payload.Response @Router /schema [get]

func (*Service) GetPrivateKeys

func (s *Service) GetPrivateKeys(c *Context)

GetPrivateKeys @Summary 获取所有密钥 @Description 获取所有密钥 @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [get]

func (*Service) GetQuicklyCommand

func (s *Service) GetQuicklyCommand(c *Context)

GetQuicklyCommand @Summary 获取所有快捷命令 @Description 获取所有快捷命令 @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [get]

func (*Service) GetRWFile

func (s *Service) GetRWFile(hostId int, path string) *sftp.File

GetRWFile 获取可读写的 sftp.File

func (*Service) GetSSHManager

func (s *Service) GetSSHManager() *ssh.Manager

func (*Service) GetTags

func (s *Service) GetTags(c *Context)

GetTags @Summary 获取所有标签 @Description 获取所有标签 @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Tag} @Failure 400 {object} payload.Response @Router /tag [get]

func (*Service) GetTunnels

func (s *Service) GetTunnels(c *Context)

GetTunnels @Summary 获取所有隧道 @Description 获取所有隧道 @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [get]

func (*Service) GetVersion

func (s *Service) GetVersion(c *Context)

GetVersion @Summary 获取当前版本 @Description 获取当前版本 @Tags system @Accept x-www-form-urlencoded @Success 200 {object} string @Router /version [get]

func (*Service) GetWebsocketIndex

func (s *Service) GetWebsocketIndex(c *gin.Context)

GetWebsocketIndex default websocket router

func (*Service) GetWebsocketSSH

func (s *Service) GetWebsocketSSH(c *gin.Context)

GetWebsocketSSH func websocket ssh

func (*Service) GetWebsocketVNC

func (s *Service) GetWebsocketVNC(c *gin.Context)

GetWebsocketVNC func websocket vnc proxy https://github.com/novnc/websockify-other

func (*Service) MakeDir

func (s *Service) MakeDir(hostId int, p, dir string) error

func (*Service) MakeDirRemote

func (s *Service) MakeDirRemote(c *Context)

MakeDirRemote @Summary 创建文件夹 @Description 创建文件夹 @Param id formData string true "远端文件路径" @Param host_id formData integer true "主机 ID" @Param dir formData string true "远端目录地址" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/mkdir [post]

func (*Service) ModifyFile

func (s *Service) ModifyFile(c *Context)

ModifyFile

@Summary		文件修改
@Description	文件修改
@Param			id		query	string	true	"远端文件路径"
@Param			host_id	query	integer	true	"主机 ID"
@Tags			tool
@Accept			x-www-form-urlencoded
@Produce		json
@Success		200	{object}	payload.Response
@Failure		400	{object}	payload.Response
@Router			/tools/modify [post]

func (*Service) PlayerExport

func (s *Service) PlayerExport(c *Context)

PlayerExport @Summary 导出剧本 @Description 导出剧本 @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 @Failure 400 {object} payload.Response @Router /player/export [get]

func (*Service) PlayerImport

func (s *Service) PlayerImport(c *Context)

PlayerImport @Summary 导入剧本 @Description 导入剧本 @Param files formData file true "剧本导出文件(zip)" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /player/import [post]

func (*Service) PluginUpload

func (s *Service) PluginUpload(c *Context)

PluginUpload @Summary 上传插件 @Description 上传插件 @Param files formData file true "插件文件(zip or tar.gz)" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /plugin/upload [post]

func (*Service) PostGroup

func (s *Service) PostGroup(c *Context)

PostGroup @Summary 创建组 @Description 创建组 @Param name formData string true "组名称" @Param params formData string false "组参数" @Param mode formData int true "组类型" example(0:主机模式,1:匹配模式) @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group [post]

func (*Service) PostHost

func (s *Service) PostHost(c *Context)

PostHost @Summary 创建主机 @Description 创建主机 @Param hostname formData string true "主机名称" @Param user formData string true "用户名" @Param addr formData string true "地址" @Param port formData integer true "SSH端口" @Param password formData string false "SSH密码" @Param group formData integer false "组ID" @Param private_key_id formData integer false "密钥ID" @Param tags formData string false "标签ID列表序列化字符串" @Param vnc_port formData integer false "VNC端口" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host [post]

func (*Service) PostJob

func (s *Service) PostJob(c *Context)

PostJob @Summary 创建任务 @Description 创建任务 @Param name formData string true "任务名称" @Param type formData string true "任务类型" example(cron,local) @Param spec formData string false "Cron表达式" @Param cmd formData string false "任务命令" @Param cmd_id formData integer false "剧本ID" @Param cmd_type formData string true "任务命令类型" example(cmd,player) @Param execute_id formData integer true "执行者 ID" @Param execute_type formData string true "执行者类型" example(host,group,tag) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job [post]

func (*Service) PostPlayBook

func (s *Service) PostPlayBook(c *Context)

PostPlayBook @Summary 创建剧本 @Description 创建剧本 @Param name formData string true "剧本名称" @Param steps formData string true "剧本步骤序列化字符串" example([{"seq":0,"type":"cmd","name":"执行ls","caches":"null","params":"{\"cmd\":\"ls\"}"}]) @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player [post]

func (*Service) PostPrivateKey

func (s *Service) PostPrivateKey(c *Context)

PostPrivateKey @Summary 创建密钥 @Description 创建密钥 @Param name formData string true "密钥名称" @Param passphrase formData string false "密钥密码" @Param key_file formData file true "密钥文件" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [post]

func (*Service) PostQuicklyCommand

func (s *Service) PostQuicklyCommand(c *Context)

PostQuicklyCommand @Summary 创建快捷命令 @Description 创建快捷命令 @Param name formData string true "快捷命令名称" @Param cmd formData string true "快捷命令文本" @Param append_cr formData bool false "是否追加CR" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [post]

func (*Service) PostTag

func (s *Service) PostTag(c *Context)

PostTag @Summary 创建标签 @Description 创建标签 @Param name formData string true "标签名称" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag [post]

func (*Service) PostTunnel

func (s *Service) PostTunnel(c *Context)

PostTunnel @Summary 创建隧道 @Description 创建隧道 @Param mode formData string true "隧道模式" example(local,remote) @Param source formData string true "源地址" @Param destination formData int true "目的地址" @Param host_id formData int true "主机 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [post]

func (*Service) PutGroup

func (s *Service) PutGroup(c *Context)

PutGroup @Summary 更新组 @Description 更新组 @Param id formData integer true "组 ID" @Param name formData string false "组名称" @Param params formData string false "组参数" @Param mode formData int false "组类型" example(0:主机模式,1:匹配模式) @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group [put]

func (*Service) PutHost

func (s *Service) PutHost(c *Context)

PutHost @Summary 更新主机 @Description 更新主机 @Param id formData integer true "主机 ID" @Param hostname formData string false "主机名称" @Param user formData string false "用户名" @Param addr formData string false "地址" @Param port formData integer false "SSH端口" @Param password formData string false "SSH密码" @Param group formData integer false "组ID" @Param private_key_id formData integer false "密钥ID" @Param tags formData string false "标签ID列表序列化字符串" @Param vnc_port formData integer false "VNC端口" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host [put]

func (*Service) PutJob

func (s *Service) PutJob(c *Context)

PutJob @Summary 更新任务 @Description 更新任务 @Param id formData integer true "任务 ID" @Param name formData string false "任务名称" @Param type formData string false "任务类型" example(cron,local) @Param spec formData string false "Cron表达式" @Param cmd formData string false "任务命令" @Param cmd_id formData integer false "剧本ID" @Param cmd_type formData string false "任务命令类型" example(cmd,player) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job [put]

func (*Service) PutPlayBook

func (s *Service) PutPlayBook(c *Context)

PutPlayBook @Summary 更新剧本 @Description 更新剧本 @Param id formData integer true "剧本 ID" @Param name formData string false "剧本名称" @Param steps formData string false "剧本步骤序列化字符串" example([{"seq":0,"type":"cmd","name":"执行ls","caches":"null","params":"{\"cmd\":\"ls\"}"}]) @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player [put]

func (*Service) PutPrivateKey

func (s *Service) PutPrivateKey(c *Context)

PutPrivateKey @Summary 更新密钥 @Description 更新密钥 @Param id formData integer true "密钥 ID" @Param name formData string false "密钥名称" @Param passphrase formData string false "密钥密码" @Param key_file formData file false "密钥文件" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [put]

func (*Service) PutQuicklyCommand

func (s *Service) PutQuicklyCommand(c *Context)

PutQuicklyCommand @Summary 更新快捷命令 @Description 更新快捷命令 @Param id formData integer true "快捷命令 ID" @Param name formData string false "快捷命令名称" @Param cmd formData string false "快捷命令文本" @Param append_cr formData bool false "是否追加CR" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [put]

func (*Service) PutTag

func (s *Service) PutTag(c *Context)

PutTag @Summary 更新标签 @Description 更新标签 @Param id formData integer true "标签 ID" @Param name formData string false "标签名称" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag [put]

func (*Service) PutTunnel

func (s *Service) PutTunnel(c *Context)

PutTunnel @Summary 更新隧道 @Description 更新隧道 @Param id formData integer true "隧道 ID" @Param mode formData string false "隧道模式" example(local,remote) @Param source formData string false "源地址" @Param destination formData int false "目的地址" @Param host_id formData int false "主机 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [put]

func (*Service) RunCmd

func (s *Service) RunCmd(c *Context)

RunCmd @Summary 执行一条命令 @Description 执行一条命令 @Param id query integer true "执行者 ID" @Param type query string true "执行者类型" example(host,group,tag) @Param cmd query string true "命令" @Param sudo query bool false "是否sudo执行" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]ssh.Result} @Failure 400 {object} payload.Response @Router /tools/cmd [get]

func (*Service) RunCmdExec

func (s *Service) RunCmdExec(hosts []*models.Host, cmd string, sudo bool) []*ssh.Result

RunCmdExec 用于http接口

func (*Service) RunCmdOneAsync

func (s *Service) RunCmdOneAsync(host *models.Host, cmd string, sudo bool, ch chan *ssh.Result, wg *sync.WaitGroup)

RunCmdOneAsync 搭配RunCmd使用

func (*Service) RunCmdWithContext

func (s *Service) RunCmdWithContext(host *models.Host, cmd ssh.Command, ch chan *ssh.Result)

RunCmdWithContext 使用在websocket接口上

func (*Service) StartJob

func (s *Service) StartJob(c *Context)

StartJob @Summary 启动任务调度 @Description 启动任务调度 @Param id formData integer true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/start [post]

func (*Service) StopJob

func (s *Service) StopJob(c *Context)

StopJob @Summary 停止任务调度 @Description 停止任务调度 @Param id formData integer true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/stop [post]

func (*Service) UploadFileStream

func (s *Service) UploadFileStream(hosts []*models.Host, tmp *ssh.TempFile, remotePath string, ctx context.Context)

Jump to

Keyboard shortcuts

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