handler

package
v0.0.0-...-5893fcd Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DockerRunTaskMap = NewDockerRunTaskMap()

DockerRunTaskMap docker运行任务map

View Source
var LoginIP sync.Map
View Source
var PageId = utils.IDMd5()

TaskMap 任务 Map

Functions

func APIOutPut

func APIOutPut(c *gin.Context, code int64, count int, data interface{}, msg string)

APIOutPut 统一接口输出方法

func BroadcastNotice

func BroadcastNotice(data []byte)

BroadcastNotice 广播 通知 数据

func CacheDelete

func CacheDelete(c *gin.Context)

CacheDelete

func CacheList

func CacheList(c *gin.Context)

CacheList

func CacheSize

func CacheSize(c *gin.Context)

CacheSize

func Delete

func Delete(ipStr string)

Delete delete conn

func DeployedInstallDocker

func DeployedInstallDocker(c *gin.Context)

DeployedInstallDocker 安装docker

func DeployedInstallNginx

func DeployedInstallNginx(c *gin.Context)

DeployedInstallNginx 安装nginx

func DeployedRemoveDocker

func DeployedRemoveDocker(c *gin.Context)

DeployedRemoveDocker 卸载docker

func DeployedRemoveNginx

func DeployedRemoveNginx(c *gin.Context)

DeployedRemoveNginx 卸载nginx

func DockerImages

func DockerImages(c *gin.Context)

DockerImages

func DockerImagesDeploy

func DockerImagesDeploy(c *gin.Context)

DockerImagesDeploy 运行指定镜像

func DockerInfo

func DockerInfo(c *gin.Context)

DockerInfo

func DockerPS

func DockerPS(c *gin.Context)

DockerPS

func DockerPause

func DockerPause(c *gin.Context)

DockerPause

func DockerPull

func DockerPull(c *gin.Context)

DockerPull docker pull

func DockerReName

func DockerReName(c *gin.Context)

DockerReName

func DockerRestart

func DockerRestart(c *gin.Context)

DockerRestart

func DockerRm

func DockerRm(c *gin.Context)

DockerRm docker rm

func DockerRmi

func DockerRmi(c *gin.Context)

DockerRmi

func DockerRun

func DockerRun(c *gin.Context)

DockerRun

func DockerState

func DockerState(c *gin.Context)

DockerState

func DockerStates

func DockerStates(c *gin.Context)

DockerStates

func DockerStop

func DockerStop(c *gin.Context)

DockerStop docker stop

func DockerTop

func DockerTop(c *gin.Context)

DockerTop

func ExecutableConfFile

func ExecutableConfFile(c *gin.Context)

ExecutableConfFile 打开配置文件

func ExecutableConfUpdate

func ExecutableConfUpdate(c *gin.Context)

ExecutableConfUpdate 修改配置文件

func ExecutableDelete

func ExecutableDelete(c *gin.Context)

ExecutableDelete 删除可执行文件

func ExecutableDeploy

func ExecutableDeploy(c *gin.Context)

ExecutableDeploy 部署可执行文件

func ExecutableDir

func ExecutableDir(c *gin.Context)

ExecutableDir 查看可执行文件的目录

func ExecutableDownload

func ExecutableDownload(c *gin.Context)

ExecutableDownload 下载可执行文件

func ExecutableKill

func ExecutableKill(c *gin.Context)

ExecutableKill 停止已經執行的可執行文件

func ExecutableList

func ExecutableList(c *gin.Context)

ExecutableList 可执行文件列表

func ExecutableRunList

func ExecutableRunList(c *gin.Context)

ExecutableRunList 已經執行的可執行文件

func ExecutableRunLog

func ExecutableRunLog(c *gin.Context)

ExecutableRunLog test case 查看已經執行的可執行文件的日誌

func ExecutableRunState

func ExecutableRunState(c *gin.Context)

ExecutableRunState 查看可執行文件任務的狀態 查看是否在運行

func ExecutableTaskDelete

func ExecutableTaskDelete(c *gin.Context)

ExecutableTaskDelete 刪除已經執行的可执行文件任務 如果正在執行無法刪除

func ExecutableTaskLog

func ExecutableTaskLog(c *gin.Context)

TODO ExecutableTaskLog 查看可执行文件运行输出的终端打印日志

func ExecutableTaskPIDInfo

func ExecutableTaskPIDInfo(c *gin.Context)

ExecutableTaskPIDInfo 查看进程详情 没有执行则无法查看

func ExecutableTaskRestart

func ExecutableTaskRestart(c *gin.Context)

ExecutableTaskRestart 重啓已經執行的可执行文件進程

func ExecutableTaskRun

func ExecutableTaskRun(c *gin.Context)

ExecutableTaskRun 启动可执行文件任务 如果已经启动无法再次启动

func ExecutableUpload

func ExecutableUpload(c *gin.Context)

ExecutableUpload 上传可执行文件

func ForwardTCPCreate

func ForwardTCPCreate(c *gin.Context)

ForwardTCPCreate 创建TCP转发

func ForwardTCPCutoff

func ForwardTCPCutoff(c *gin.Context)

ForwardTCPCutoff 切断TCP转发

func ForwardTCPList

func ForwardTCPList(c *gin.Context)

ForwardTCPList 获取TCP转发列表

func ForwardTCPRemove

func ForwardTCPRemove(c *gin.Context)

ForwardTCPRemove 删除TCP转发

func ForwardTCPRenew

func ForwardTCPRenew(c *gin.Context)

ForwardTCPRenew 恢复TCP转发

func ForwardTCPSwitch

func ForwardTCPSwitch(c *gin.Context)

ForwardTCPSwitch 切换TCP转发目标

func ForwardUDPCreate

func ForwardUDPCreate(c *gin.Context)

TODO ForwardUDPCreate 创建UDP转发

func ForwardUDPCutoff

func ForwardUDPCutoff(c *gin.Context)

TODO ForwardUDPCutoff 切断UDP转发

func ForwardUDPList

func ForwardUDPList(c *gin.Context)

TODO ForwardUDPList 获取UDP转发列表

func ForwardUDPRemove

func ForwardUDPRemove(c *gin.Context)

TODO ForwardUDPRemove 删除UDP转发

func ForwardUDPRenew

func ForwardUDPRenew(c *gin.Context)

TODO ForwardUDPRenew 恢复UDP转发

func ForwardUDPSwitch

func ForwardUDPSwitch(c *gin.Context)

TODO ForwardUDPSwitch 切换UDP转发目标

func GatewayDelete

func GatewayDelete(c *gin.Context)

GatewayDelete 删除一个网关

func GatewayList

func GatewayList(c *gin.Context)

GatewayList

func GatewayNew

func GatewayNew(c *gin.Context)

GatewayNew 新建网关

func GatewayRun

func GatewayRun(c *gin.Context)

GatewayRun 运行网关

func GatewayUpdatePort

func GatewayUpdatePort(c *gin.Context)

TODO GatewayUpdatePort 修改网关端口映射

func GetIP

func GetIP(r *http.Request) (ip string)

GetIP 获取ip - X-Real-IP:只包含客户端机器的一个IP,如果为空,某些代理服务器(如Nginx)会填充此header。 - X-Forwarded-For:一系列的IP地址列表,以,分隔,每个经过的代理服务器都会添加一个IP。 - RemoteAddr:包含客户端的真实IP地址。 这是Web服务器从其接收连接并将响应发送到的实际物理IP地址。 但是,如果客户端通过代理连接,它将提供代理的IP地址。

RemoteAddr是最可靠的,但是如果客户端位于代理之后或使用负载平衡器或反向代理服务器时,它将永远不会提供正确的IP地址,因此顺序是先是X-REAL-IP, 然后是X-FORWARDED-FOR,然后是 RemoteAddr。 请注意,恶意用户可以创建伪造的X-REAL-IP和X-FORWARDED-FOR标头。

func GetTaskState

func GetTaskState(c *gin.Context)

GetTaskState

func HaveDocker

func HaveDocker(c *gin.Context)

HaveDocker

func Login

func Login(c *gin.Context)

Login 保证安全方案 1. 定期更新账号密码 TODO 2. 记录操作 TODO 3. 记录请求 TODO 4. 白名单 TODO 5. 暴力登录检验,一个ip只有五次试错机会,超过拉黑ip master 与 slave 安全方案 1. 非对称加密 TODO

func LoginIPLoad

func LoginIPLoad(ipStr string) int

LoginIPLoad Load get ws context

func LoginIPStore

func LoginIPStore(ipStr string, times int)

LoginIPStore Store save deviceId and conn

func MonitorAlarmDel

func MonitorAlarmDel(c *gin.Context)

MonitorAlarmDel

func MonitorAlarmList

func MonitorAlarmList(c *gin.Context)

MonitorAlarmList

func MonitorData

func MonitorData(c *gin.Context)

MonitorData

func MonitorRuleCreate

func MonitorRuleCreate(c *gin.Context)

MonitorRuleCreate 新增监控标准

func MonitorRuleList

func MonitorRuleList(c *gin.Context)

MonitorRuleList 监控标准列表

func MonitorSlave

func MonitorSlave(c *gin.Context)

MonitorSlave

func NewDockerPullTaskMap

func NewDockerPullTaskMap() *dockerPullTaskMap

func NewDockerRunTaskMap

func NewDockerRunTaskMap() *dockerRunTaskMap

func NewSshClient

func NewSshClient() (*ssh.Client, error)

func NewTerminal

func NewTerminal(user string, pass string, addr string)

NewTerminal

func OperateDelete

func OperateDelete(c *gin.Context)

OperateDelete

func OperateList

func OperateList(c *gin.Context)

OperateList

func PGCache

func PGCache(c *gin.Context)

PGCache

func PGContainerLog

func PGContainerLog(c *gin.Context)

PGContainerLog

func PGContainerMonitor

func PGContainerMonitor(c *gin.Context)

PGContainerMonitor

func PGDir

func PGDir(c *gin.Context)

PGDir 目录&文件 功能: 文件上传 下载 删除 新建目录

func PGDockerManage

func PGDockerManage(c *gin.Context)

PGDockerManage

func PGEnvDeployed

func PGEnvDeployed(c *gin.Context)

PGEnvDeployed 环境部署

func PGExecutableDir

func PGExecutableDir(c *gin.Context)

PGExecutableDir 查看可执行文件的目录结构

func PGExecutableLog

func PGExecutableLog(c *gin.Context)

PGExecutableLog

func PGExecutableManage

func PGExecutableManage(c *gin.Context)

PGExecutableManage

func PGForward

func PGForward(c *gin.Context)

PGForward 网络转发管理

func PGGateway

func PGGateway(c *gin.Context)

PGGateway

func PGIndex

func PGIndex(c *gin.Context)

PGIndex

func PGLogin

func PGLogin(c *gin.Context)

PGLogin

func PGMonitor

func PGMonitor(c *gin.Context)

PGMonitor

func PGNginx

func PGNginx(c *gin.Context)

PGNginx Nginx管理

func PGProjectContainer

func PGProjectContainer(c *gin.Context)

PGProjectContainer

func PGProjectExecutable

func PGProjectExecutable(c *gin.Context)

PGProjectExecutable

func PGProjectManage

func PGProjectManage(c *gin.Context)

PGProjectManage

func PGSSH

func PGSSH(c *gin.Context)

PGSSH ssh

func PGSlave

func PGSlave(c *gin.Context)

PGSlave

func PGSlaveEnv

func PGSlaveEnv(c *gin.Context)

PGSlaveEnv

func PGSlavePort

func PGSlavePort(c *gin.Context)

PGSlavePort

func PGSlaveProcess

func PGSlaveProcess(c *gin.Context)

PGSlaveProcess

func PGSlaveSelect

func PGSlaveSelect(c *gin.Context)

PGSlaveSelect

func PGTaskPage

func PGTaskPage(c *gin.Context)

PGTaskPage

func ProjectDockerContainer

func ProjectDockerContainer(c *gin.Context)

ProjectDockerContainer

func ProjectDockerContainerIps

func ProjectDockerContainerIps(c *gin.Context)

ProjectDockerContainerIps

func ProjectDockerCreate

func ProjectDockerCreate(c *gin.Context)

ProjectDockerCreate

func ProjectDockerList

func ProjectDockerList(c *gin.Context)

ProjectDockerList

func ProjectDockerRun

func ProjectDockerRun(c *gin.Context)

ProjectDockerRun

func ProjectDockerUpdate

func ProjectDockerUpdate(c *gin.Context)

TODO ProjectDockerUpdate 更新数据

func ProjectDockerUpdateDuplicate

func ProjectDockerUpdateDuplicate(c *gin.Context)

ProjectDockerUpdateDuplicate 更新副本数量

func ProjectDockerUpdateImage

func ProjectDockerUpdateImage(c *gin.Context)

ProjectDockerUpdateImage 更新项目镜像 并重启

func ProjectExecutableCreate

func ProjectExecutableCreate(c *gin.Context)

ProjectExecutableCreate 项目管理 - 二进制物理机部署项目 是可执行文件的扩展,是以项目为单位,可以理解为是以目录为单位 将可执行文件改为压缩的目录, 新增执行命令, 端口守护等 可执行多个副本,均摊部署在不同的salve上 可执行项目 1. 可执行文件 2. 其他文件,如配置,数据等文件 3. 执行命令 4. 环境变量 5. 占用端口

func ProjectExecutableDownload

func ProjectExecutableDownload(c *gin.Context)

ProjectExecutableDownload

func ProjectExecutableList

func ProjectExecutableList(c *gin.Context)

ProjectExecutableList

func ProjectExecutableRun

func ProjectExecutableRun(c *gin.Context)

ProjectExecutableRun

func ProjectExecutableTaskList

func ProjectExecutableTaskList(c *gin.Context)

ProjectExecutableTaskList

func ProxyHttpContinue

func ProxyHttpContinue(c *gin.Context)

ProxyHttpContinue 获取http/s代理继续

func ProxyHttpCreate

func ProxyHttpCreate(c *gin.Context)

ProxyHttpCreate 创建http/s代理

func ProxyHttpList

func ProxyHttpList(c *gin.Context)

ProxyHttpList 获取http/s代理列表

func ProxyHttpRemove

func ProxyHttpRemove(c *gin.Context)

ProxyHttpRemove 删除http/s代理

func ProxyHttpStop

func ProxyHttpStop(c *gin.Context)

ProxyHttpStop 获取http/s代理暂停

func ProxySSHCreate

func ProxySSHCreate(c *gin.Context)

TODO ProxySSHCreate 创建ssh代理

func ProxySSHList

func ProxySSHList(c *gin.Context)

TODO ProxySSHList 获取ssh代理列表

func ProxySSHRemove

func ProxySSHRemove(c *gin.Context)

TODO ProxySSHRemove 删除ssh代理

func ProxySocket5Continue

func ProxySocket5Continue(c *gin.Context)

ProxySocket5Continue 获取http/s代理继续

func ProxySocket5Create

func ProxySocket5Create(c *gin.Context)

ProxySocket5Create 创建socket5代理

func ProxySocket5List

func ProxySocket5List(c *gin.Context)

ProxySocket5List 获取socket5代理列表

func ProxySocket5Remove

func ProxySocket5Remove(c *gin.Context)

删除socket5代理

func ProxySocket5Stop

func ProxySocket5Stop(c *gin.Context)

ProxySocket5Stop 获取socket5代理暂停

func Register

func Register(c *gin.Context)

Register

func SSH2

func SSH2(c *gin.Context)

func SSHClient

func SSHClient(user string, pass string, addr string) (*ssh.Client, error)

SSHClient 连接ssh addr : 主机地址, 如: 127.0.0.1:22 user : 用户 pass : 密码 返回 ssh连接

func SlaveDir

func SlaveDir(c *gin.Context)

SlaveDir slave 目录与文件

func SlaveDiskInfo

func SlaveDiskInfo(c *gin.Context)

SlaveDiskInfo

func SlaveENVList

func SlaveENVList(c *gin.Context)

SlaveENVList

func SlaveHosts

func SlaveHosts(c *gin.Context)

SlaveHosts 读取 hosts 文件

func SlaveHostsUpdate

func SlaveHostsUpdate(c *gin.Context)

SlaveHostsUpdate 更新 hosts文件

func SlaveInfo

func SlaveInfo(c *gin.Context)

SlaveInfo

func SlaveList

func SlaveList(c *gin.Context)

SlaveList

func SlavePathInfo

func SlavePathInfo(c *gin.Context)

SlavePathInfo

func SlavePortInfo

func SlavePortInfo(c *gin.Context)

SlavePortInfo slave 端口使用情況

func SlaveProcessInfo

func SlaveProcessInfo(c *gin.Context)

SlaveProcessInfo 查看进程信息

func SlaveProcessKill

func SlaveProcessKill(c *gin.Context)

SlaveProcessKill

func SlaveProcessList

func SlaveProcessList(c *gin.Context)

SlaveProcessList

func TaskDelete

func TaskDelete(c *gin.Context)

TaskDelete

func TaskList

func TaskList(c *gin.Context)

TaskList

func TestDockerState

func TestDockerState(c *gin.Context)

TestDockerState

func TestNotice

func TestNotice(c *gin.Context)

TestNotice

func UDPSend

func UDPSend(slave string, cmd protocol.CommandCode, data []byte) (string, error)

UDPSend

func UDPSendOutHttp

func UDPSendOutHttp(c *gin.Context, slave string, cmd protocol.CommandCode, data []byte)

UDPSendOutHttp

func WebSocketContainerLog

func WebSocketContainerLog(c *gin.Context)

WebSocketContainerLog

func WebSocketExecutableLog

func WebSocketExecutableLog(c *gin.Context)

WebSocketExecutableLog 查看可執行文件運行日誌 方案二

func WebSocketExecutableLog1

func WebSocketExecutableLog1(c *gin.Context)

WebSocketExecutableLog1 查看可執行文件運行日誌 方案一

func WebSocketNotice

func WebSocketNotice(c *gin.Context)

WebSocketNotice

func WebSocketTerminal

func WebSocketTerminal(c *gin.Context)

WebSocketTerminal

Types

type Body

type Body struct {
	Count int         `json:"count"`
	Data  interface{} `json:"data"`
}

Body 具体数据模型

type DockerPullTask

type DockerPullTask struct {
	IP     string
	Result interface{}
	State  int // 0: 预留, 1: 进行中, 2: 完成, 3: 中断
}

DockerPullTask

func (*DockerPullTask) GetResult

func (d *DockerPullTask) GetResult() *DockerPullTask

GetResult

type DockerRunParam

type DockerRunParam struct {
	Image         string `json:"image"`
	ImageUser     string `json:"image_user"`
	ImagePass     string `json:"image_pass"`
	ContainerEnv  string `json:"container_env"`
	ContainerName string `json:"container_name"`
	ContainerPort string `json:"container_port"`
	IsAlways      bool   `json:"is_always"`
}

DockerRunParam

type DockerRunTask

type DockerRunTask struct {
	IP     string
	Result string
	State  int // 0: 预留, 1: 进行中, 2: 完成, 3: 中断
}

func (*DockerRunTask) GetResult

func (d *DockerRunTask) GetResult() *DockerRunTask

type ExecutableConfUpdateParam

type ExecutableConfUpdateParam struct {
	Name     string `json:"name"`
	ConfName string `json:"conf_name"`
	NewConf  string `json:"new_conf"`
}

ExecutableConfUpdateParam 更新可执行文件配置文件实体

type ExecutableFileStructure

type ExecutableFileStructure struct {
	FileName string
	IsDir    bool
	IsConf   bool
}

ExecutableFileStructure 可执行文件的目录文件结构输出实体

type ExecutableListOut

type ExecutableListOut struct {
	List []*entity.ExecutableFile
	Keys []string
}

ExecutableListOut 可执行文件列表输出

type ImagesDeployParam

type ImagesDeployParam struct {
	Slave         string `json:"slave"`
	ImageId       string `json:"image_id"`
	ContainerEnv  string `json:"container_env"`
	ContainerName string `json:"container_name"`
	ContainerPort string `json:"container_port"`
	IsAlways      bool   `json:"is_always"`
}

ImagesDeployParam

type LogicSshWsSession

type LogicSshWsSession struct {
	IsFlagged bool `comment:"当前session是否包含禁止命令"`
	// contains filtered or unexported fields
}

func NewLogicSshWsSession

func NewLogicSshWsSession(cols, rows int, isAdmin bool, sshClient *ssh.Client, wsConn *websocket.Conn) (*LogicSshWsSession, error)

func (*LogicSshWsSession) Close

func (sws *LogicSshWsSession) Close()

Close 关闭

func (*LogicSshWsSession) LogString

func (sws *LogicSshWsSession) LogString() string

func (*LogicSshWsSession) Start

func (sws *LogicSshWsSession) Start(quitChan chan bool)

func (*LogicSshWsSession) Wait

func (sws *LogicSshWsSession) Wait(quitChan chan bool)

type OutMonitorData

type OutMonitorData struct {
	Date     string
	CPU      float32
	MEM      int
	Tx       float32
	Rx       float32
	MEMUsage int64
	MEMLimit int64
	Connect  int
}

OutMonitorData 输出监控采集的数据

type OutSlaveList

type OutSlaveList struct {
	Slave       string `json:"slave"`
	Online      string `json:"online"`
	OnlineValue string `json:"online_value"`
}

OutSlaveList 输出slave列表

type ResponseJson

type ResponseJson struct {
	Code      int64       `json:"code"`
	Msg       string      `json:"msg"`
	Body      interface{} `json:"body"`
	TimeStamp int64       `json:"timeStamp"`
}

ResponseJson 统一接口输出

type SlaveHostsUpdateParam

type SlaveHostsUpdateParam struct {
	Slave     string `json:"slave"`
	HostsData string `json:"hosts_data"`
}

SlaveHostsUpdateParam

type SshConn

type SshConn struct {
	// calling Write() to write data into ssh server
	StdinPipe io.WriteCloser
	// Write() be called to receive data from ssh server
	ComboOutput *wsBufferWriter
	Session     *ssh.Session
}

connect to ssh server using ssh session.

func NewSshConn

func NewSshConn(cols, rows int, sshClient *ssh.Client) (*SshConn, error)

func (*SshConn) Close

func (s *SshConn) Close()

func (*SshConn) ReceiveWsMsg

func (ssConn *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool)

ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin

func (*SshConn) SendComboOutput

func (ssConn *SshConn) SendComboOutput(wsConn *websocket.Conn, exitCh chan bool)

func (*SshConn) SessionWait

func (ssConn *SshConn) SessionWait(quitChan chan bool)

type WsContext

type WsContext struct {
	Key  string
	Conn *websocket.Conn
}

WsContext websocket context

Jump to

Keyboard shortcuts

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