mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-12-02 18:13:15 +00:00
add conn log
This commit is contained in:
56
http/controller/api/audit.go
Normal file
56
http/controller/api/audit.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
request "Gwen/http/request/api"
|
||||
"Gwen/http/response"
|
||||
"Gwen/model"
|
||||
"Gwen/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Audit struct {
|
||||
}
|
||||
|
||||
// AuditConn
|
||||
// @Tags 审计
|
||||
// @Summary 审计连接
|
||||
// @Description 审计连接
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body request.AuditConnForm true "审计连接"
|
||||
// @Success 200 {string} string ""
|
||||
// @Failure 500 {object} response.Response
|
||||
// @Router /audit/conn [post]
|
||||
func (a *Audit) AuditConn(c *gin.Context) {
|
||||
af := &request.AuditConnForm{}
|
||||
err := c.ShouldBindBodyWith(af, binding.JSON)
|
||||
if err != nil {
|
||||
response.Error(c, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||
return
|
||||
}
|
||||
//fmt.Println(af)
|
||||
ac := af.ToAuditConn()
|
||||
if af.Action == model.AuditActionNew {
|
||||
service.AllService.AuditService.CreateAuditConn(ac)
|
||||
} else if af.Action == model.AuditActionClose {
|
||||
ex := service.AllService.AuditService.InfoByPeerIdAndConnId(af.Id, af.ConnId)
|
||||
if ex.Id != 0 {
|
||||
ex.CloseTime = time.Now().Unix()
|
||||
service.AllService.AuditService.UpdateAuditConn(ex)
|
||||
}
|
||||
} else if af.Action == "" {
|
||||
ex := service.AllService.AuditService.InfoByPeerIdAndConnId(af.Id, af.ConnId)
|
||||
if ex.Id != 0 {
|
||||
up := &model.AuditConn{
|
||||
IdModel: model.IdModel{Id: ex.Id},
|
||||
FromPeer: ac.FromPeer,
|
||||
FromName: ac.FromName,
|
||||
SessionId: ac.SessionId,
|
||||
}
|
||||
service.AllService.AuditService.UpdateAuditConn(up)
|
||||
}
|
||||
}
|
||||
response.Success(c, "")
|
||||
}
|
||||
Reference in New Issue
Block a user