mirror of
https://github.com/veops/oneterm.git
synced 2025-10-11 02:00:17 +08:00
feat: file manager
This commit is contained in:
@@ -1,31 +1,78 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
FILE_ACTION_LS = iota + 1
|
||||
FILE_ACTION_MKDIR
|
||||
FILE_ACTION_UPLOAD
|
||||
FILE_ACTION_DOWNLOAD
|
||||
SESSIONTYPE_WEB = iota + 1
|
||||
SESSIONTYPE_CLIENT
|
||||
)
|
||||
|
||||
type FileHistory struct {
|
||||
Id int `json:"id" gorm:"column:id;primarykey"`
|
||||
Uid int `json:"uid" gorm:"column:uid"`
|
||||
UserName string `json:"user_name" gorm:"column:user_name"`
|
||||
AssetId int `json:"asset_id" gorm:"column:asset_id"`
|
||||
AccountId int `json:"account_id" gorm:"column:account_id"`
|
||||
ClientIp string `json:"client_ip" gorm:"column:client_ip"`
|
||||
Action int `json:"action" gorm:"column:action"`
|
||||
Dir string `json:"dir" gorm:"column:dir"`
|
||||
Filename string `json:"filename" gorm:"column:filename"`
|
||||
const (
|
||||
SESSIONSTATUS_ONLINE = iota + 1
|
||||
SESSIONSTATUS_OFFLINE
|
||||
)
|
||||
|
||||
const (
|
||||
SESSIONACTION_NEW = iota + 1
|
||||
SESSIONACTION_MONITOR
|
||||
SESSIONACTION_CLOSE
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
Id int `json:"id" gorm:"column:id;primarykey"`
|
||||
SessionType int `json:"session_type" gorm:"column:session_type"`
|
||||
SessionId string `json:"session_id" gorm:"column:session_id"`
|
||||
Uid int `json:"uid" gorm:"column:uid"`
|
||||
UserName string `json:"user_name" gorm:"column:user_name"`
|
||||
AssetId int `json:"asset_id" gorm:"column:asset_id"`
|
||||
AssetInfo string `json:"asset_info" gorm:"column:asset_info"`
|
||||
AccountId int `json:"account_id" gorm:"column:account_id"`
|
||||
AccountInfo string `json:"account_info" gorm:"column:account_info"`
|
||||
GatewayId int `json:"gateway_id" gorm:"column:gateway_id"`
|
||||
GatewayInfo string `json:"gateway_info" gorm:"column:gateway_info"`
|
||||
ClientIp string `json:"client_ip" gorm:"column:client_ip"`
|
||||
Protocol string `json:"protocol" gorm:"column:protocol"`
|
||||
Status int `json:"status" gorm:"column:status"`
|
||||
Duration int64 `json:"duration" gorm:"-"`
|
||||
ClosedAt *time.Time `json:"closed_at" gorm:"column:closed_at"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
|
||||
|
||||
CmdCount int64 `json:"cmd_count" gorm:"-"`
|
||||
}
|
||||
|
||||
func (m *FileHistory) TableName() string {
|
||||
func (m *Session) TableName() string {
|
||||
return "session"
|
||||
}
|
||||
|
||||
type SessionCmd struct {
|
||||
Id int `json:"id" gorm:"column:id;primarykey"`
|
||||
SessionId string `json:"session_id" gorm:"column:session_id"`
|
||||
Cmd string `json:"cmd" gorm:"column:cmd"`
|
||||
Result string `json:"result" gorm:"column:result"`
|
||||
Level int `json:"level" gorm:"column:level"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
func (m *SessionCmd) TableName() string {
|
||||
return "session_cmd"
|
||||
}
|
||||
|
||||
func (m *Session) IsSsh() bool {
|
||||
return strings.HasPrefix(m.Protocol, "ssh")
|
||||
}
|
||||
|
||||
type CmdCount struct {
|
||||
SessionId string `gorm:"column:session_id"`
|
||||
Count int64 `gorm:"column:count"`
|
||||
}
|
||||
|
||||
type SessionOptionAsset struct {
|
||||
Id int `json:"id" gorm:"column:id;primarykey"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user