model

package
v0.0.0-...-272034d Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeAlwaysTrigger  = 0
	ModeOnetimeTrigger = 1
)
View Source
const (
	EntityTopic = iota + 1
	EntityComment
)

EntityType

View Source
const (
	CtxKeyAuthorizedUser = "ckau"
	CtxKeyRealIPStr      = "ckri"
)
View Source
const (
	ConfigUsePeerIP = "NZ::Use-Peer-IP"
	ConfigCoverAll  = iota
	ConfigCoverIgnoreAll
)
View Source
const (
	CronCoverIgnoreAll = iota
	CronCoverAll
	CronCoverAlertTrigger
	CronTypeCronTask    = 0
	CronTypeTriggerTask = 1
)
View Source
const (
	ProviderDummy        = "dummy"
	ProviderWebHook      = "webhook"
	ProviderCloudflare   = "cloudflare"
	ProviderTencentCloud = "tencentcloud"
)
View Source
const (
	StatusUnread   = iota // 消息未读
	StatusHaveRead        // 消息已读
)

消息状态

View Source
const (
	TypeTopicComment   = iota // 收到话题评论
	TypeCommentReply          // 收到他人回复
	TypeTopicLike             // 收到点赞
	TypeTopicFavorite         // 话题被收藏
	TypeTopicRecommend        // 话题被设为推荐
	TypeTopicDelete           // 话题被删除
	TypeArticleComment        // 收到文章评论
)
View Source
const (
	NotificationRequestTypeJSON
	NotificationRequestTypeForm
)
View Source
const (
	NotificationRequestMethodGET
	NotificationRequestMethodPOST
)
View Source
const (
	RuleCoverAll = iota
	RuleCoverIgnoreAll
)
View Source
const (
	TaskTypeHTTPGet
	TaskTypeICMPPing
	TaskTypeTCPPing
	TaskTypeCommand
	TaskTypeTerminal
	TaskTypeUpgrade
	TaskTypeKeepalive
	TaskTypeTerminalGRPC
	TaskTypeNAT
	TaskTypeReportHostInfoDeprecated
	TaskTypeFM
	TaskTypeReportConfig
	TaskTypeApplyConfig
)
View Source
const (
	ServiceCoverAll = iota
	ServiceCoverIgnoreAll
)
View Source
const (
	StatusOk      = iota // 正常
	StatusDeleted        // 删除
	StatusReview         // 待审核
)
View Source
const (
	RoleAdmin uint8 = iota
	RoleMember
)
View Source
const (
	WAFBlockReasonTypeLoginFail uint8
	WAFBlockReasonTypeBruteForceToken
	WAFBlockReasonTypeAgentAuthFail
	WAFBlockReasonTypeManual
	WAFBlockReasonTypeBruteForceOauth2
)
View Source
const (
	BlockIDgRPC = -127 + iota
	BlockIDToken
	BlockIDUnknownUser
	BlockIDManual
)
View Source
const (
	ApiErrorUnauthorized = 10001
)
View Source
const (
	CacheKeyOauth2State = "cko2s::"
)
View Source
const (
	MTReportHostState
)

Variables

Functions

func BatchUnblockIP

func BatchUnblockIP(db *gorm.DB, ip []string) error

func BlockIP

func BlockIP(db *gorm.DB, ip string, reason uint8, uid int64) error

func CheckIP

func CheckIP(db *gorm.DB, ip string) error

func FindByUserID

func FindByUserID[S ~[]E, E CommonInterface](s S, uid uint64) []uint64

func InitServer

func InitServer(s *Server)

func IsServiceSentinelNeeded

func IsServiceSentinelNeeded(t uint64) bool

IsServiceSentinelNeeded 判断该任务类型是否需要进行服务监控 需要则返回true

func SearchByIDCtx

func SearchByIDCtx[S ~[]E, E CommonInterface](c *gin.Context, x S) S

func SplitList

func SplitList(x []*Server) ([]*Server, []*Server)

Split a sorted server list into two separate lists: The first list contains servers with a priority set (DisplayIndex != 0). The second list contains servers without a priority set (DisplayIndex == 0). The original slice is not modified. If no server without a priority is found, it returns nil.

func UnblockIP

func UnblockIP(db *gorm.DB, ip string, uid int64) error

Types

type AlertRule

type AlertRule struct {
	Common
	Name                   string   `json:"name"`
	RulesRaw               string   `json:"-"`
	Enable                 *bool    `json:"enable,omitempty"`
	TriggerMode            uint8    `gorm:"default:0" json:"trigger_mode"` // 触发模式: 0-始终触发(默认) 1-单次触发
	NotificationGroupID    uint64   `json:"notification_group_id"`         // 该报警规则所在的通知组
	FailTriggerTasksRaw    string   `gorm:"default:'[]'" json:"-"`
	RecoverTriggerTasksRaw string   `gorm:"default:'[]'" json:"-"`
	Rules                  []*Rule  `gorm:"-" json:"rules"`
	FailTriggerTasks       []uint64 `gorm:"-" json:"fail_trigger_tasks"`    // 失败时执行的触发任务id
	RecoverTriggerTasks    []uint64 `gorm:"-" json:"recover_trigger_tasks"` // 恢复时执行的触发任务id
}

func (*AlertRule) AfterFind

func (r *AlertRule) AfterFind(tx *gorm.DB) error

func (*AlertRule) BeforeSave

func (r *AlertRule) BeforeSave(tx *gorm.DB) error

func (*AlertRule) Check

func (r *AlertRule) Check(points [][]bool) (int, bool)

Check 传入包含当前报警规则下所有type检查结果 返回报警持续时间与是否通过报警检查(通过则返回true)

func (*AlertRule) Enabled

func (r *AlertRule) Enabled() bool

func (*AlertRule) Snapshot

func (r *AlertRule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB) []bool

Snapshot 对传入的Server进行该报警规则下所有type的检查 返回每项检查结果

type AlertRuleForm

type AlertRuleForm struct {
	Name                string   `json:"name" minLength:"1"`
	Rules               []*Rule  `json:"rules"`
	FailTriggerTasks    []uint64 `json:"fail_trigger_tasks"`    // 失败时触发的任务id
	RecoverTriggerTasks []uint64 `json:"recover_trigger_tasks"` // 恢复时触发的任务id
	NotificationGroupID uint64   `json:"notification_group_id"`
	TriggerMode         uint8    `json:"trigger_mode" default:"0"`
	Enable              bool     `json:"enable" validate:"optional"`
}

type Comment

type Comment struct {
	Common

	EntityType   int      `json:"entityType"`   // 被评论实体类型
	EntityId     int64    `json:"entityId"`     // 被评论实体编号
	Content      string   `json:"content"`      // 内容
	ImageList    string   `json:"imageList"`    // 图片
	ContentType  string   `json:"contentType"`  // 内容类型:markdown、html
	QuoteId      int64    `json:"quoteId"`      // 引用的评论编号
	LikeCount    int64    `json:"likeCount"`    // 点赞数量
	CommentCount int64    `json:"commentCount"` // 评论数量
	Status       int      `json:"status"`       // 状态:0:待审核、1:审核通过、2:审核失败、3:已发布
	Images       []Upload `gorm:"-" json:"images"`
	Liked        bool     `gorm:"-" json:"liked"`
	Favorited    bool     `gorm:"-" json:"favorited"`
}

func (*Comment) AfterFind

func (m *Comment) AfterFind(tx *gorm.DB) error

func (*Comment) BeforeSave

func (m *Comment) BeforeSave(tx *gorm.DB) error

type CommentForm

type CommentForm struct {
	EntityType   int      `json:"entityType,omitempty" validate:"optional"`   // 被评论实体类型
	EntityId     int64    `json:"entityId,omitempty" validate:"optional"`     // 被评论实体编号
	Content      string   `json:"content,omitempty" validate:"optional"`      // 内容
	ImageList    string   `json:"imageList,omitempty" validate:"optional"`    // 图片
	ContentType  string   `json:"contentType,omitempty" validate:"optional"`  // 内容类型:markdown、html
	QuoteId      int64    `json:"quoteId,omitempty" validate:"optional"`      // 引用的评论编号
	LikeCount    int64    `json:"likeCount,omitempty" validate:"optional"`    // 点赞数量
	CommentCount int64    `json:"commentCount,omitempty" validate:"optional"` // 评论数量
	Status       int      `json:"status,omitempty" validate:"optional"`       // 状态:0:待审核、1:审核通过、2:审核失败、3:已发布
	Images       []Upload `gorm:"-" json:"images,omitempty" validate:"optional"`
}

type Common

type Common struct {
	ID        uint64    `gorm:"primaryKey" json:"id,omitempty"`
	CreatedAt time.Time `gorm:"index;<-:create" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"`

	UserID uint64 `gorm:"index;default:0" json:"-"`
}

func (*Common) GetID

func (c *Common) GetID() uint64

func (*Common) GetUserID

func (c *Common) GetUserID() uint64

func (*Common) HasPermission

func (c *Common) HasPermission(ctx *gin.Context) bool

type CommonInterface

type CommonInterface interface {
	GetID() uint64
	GetUserID() uint64
	HasPermission(*gin.Context) bool
}

type CommonResponse

type CommonResponse[T any] struct {
	Success bool   `json:"success,omitempty"`
	Data    T      `json:"data,omitempty"`
	Error   string `json:"error,omitempty"`
}

type Config

type Config struct {
	ConfigForGuests
	ConfigDashboard

	AvgPingCount int `koanf:"avg_ping_count" json:"avg_ping_count,omitempty"`

	Debug          bool   `koanf:"debug" json:"debug,omitempty"`           // debug模式开关
	Location       string `koanf:"location" json:"location,omitempty"`     // 时区,默认为 Asia/Shanghai
	ForceAuth      bool   `koanf:"force_auth" json:"force_auth,omitempty"` // 强制要求认证
	AgentSecretKey string `koanf:"agent_secret_key" json:"agent_secret_key,omitempty"`
	JWTTimeout     int    `koanf:"jwt_timeout" json:"jwt_timeout,omitempty"` // JWT token过期时间(小时)

	JWTSecretKey string `koanf:"jwt_secret_key" json:"jwt_secret_key,omitempty"`
	ListenPort   uint16 `koanf:"listen_port" json:"listen_port,omitempty"`
	ListenHost   string `koanf:"listen_host" json:"listen_host,omitempty"`

	// oauth2 配置
	Oauth2 map[string]*Oauth2Config `koanf:"oauth2" json:"oauth2,omitempty"`

	// HTTPS 配置
	HTTPS HTTPSConf `koanf:"https" json:"https"`

	OssType   string `koanf:"oss_type" json:"oss_type,omitempty"`
	LocalPath string `koanf:"local_path" json:"local_path,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Read

func (c *Config) Read(path string, frontendTemplates []FrontendTemplate) error

Read 读取配置文件并应用

func (*Config) Save

func (c *Config) Save() error

Save 保存配置文件

type ConfigDashboard

type ConfigDashboard struct {
	RealIPHeader  string `koanf:"real_ip_header" json:"real_ip_header,omitempty"` // 真实IP
	UserTemplate  string `koanf:"user_template" json:"user_template,omitempty"`
	AdminTemplate string `koanf:"admin_template" json:"admin_template,omitempty"`

	EnablePlainIPInNotification bool `koanf:"enable_plain_ip_in_notification" json:"enable_plain_ip_in_notification,omitempty"` // 通知信息IP不打码

	// IP变更提醒
	EnableIPChangeNotification  bool   `koanf:"enable_ip_change_notification" json:"enable_ip_change_notification,omitempty"`
	IPChangeNotificationGroupID uint64 `koanf:"ip_change_notification_group_id" json:"ip_change_notification_group_id"`
	Cover                       uint8  `koanf:"cover" json:"cover"`                                               // 覆盖范围(0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;)
	IgnoredIPNotification       string `koanf:"ignored_ip_notification" json:"ignored_ip_notification,omitempty"` // 特定服务器IP(多个服务器用逗号分隔)

	DNSServers string `koanf:"dns_servers" json:"dns_servers,omitempty"`
}

type ConfigForGuests

type ConfigForGuests struct {
	Language            string `koanf:"language" json:"language"` // 系统语言,默认 zh_CN
	SiteName            string `koanf:"site_name" json:"site_name"`
	CustomCode          string `koanf:"custom_code" json:"custom_code,omitempty"`
	CustomCodeDashboard string `koanf:"custom_code_dashboard" json:"custom_code_dashboard,omitempty"`

	InstallHost string `koanf:"install_host" json:"install_host,omitempty"`
	AgentTLS    bool   `koanf:"tls" json:"tls,omitempty"` // 用于前端判断生成的安装命令是否启用 TLS
}

type CreateFMResponse

type CreateFMResponse struct {
	SessionID string `json:"session_id,omitempty"`
}

type CreateTerminalResponse

type CreateTerminalResponse struct {
	SessionID  string `json:"session_id,omitempty"`
	ServerID   uint64 `json:"server_id,omitempty"`
	ServerName string `json:"server_name,omitempty"`
}

type Cron

type Cron struct {
	Common
	Name                string    `json:"name"`
	TaskType            uint8     `gorm:"default:0" json:"task_type"` // 0:计划任务 1:触发任务
	Scheduler           string    `json:"scheduler"`                  // 分钟 小时 天 月 星期
	Command             string    `json:"command,omitempty"`
	Servers             []uint64  `gorm:"-" json:"servers"`
	PushSuccessful      bool      `json:"push_successful,omitempty"`  // 推送成功的通知
	NotificationGroupID uint64    `json:"notification_group_id"`      // 指定通知方式的分组
	LastExecutedAt      time.Time `json:"last_executed_at,omitempty"` // 最后一次执行时间
	LastResult          bool      `json:"last_result,omitempty"`      // 最后一次执行结果
	Cover               uint8     `json:"cover"`                      // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器 2:由触发该计划任务的服务器执行)

	CronJobID  cron.EntryID `gorm:"-" json:"cron_job_id,omitempty"`
	ServersRaw string       `json:"-"`
}

func (*Cron) AfterFind

func (c *Cron) AfterFind(tx *gorm.DB) error

func (*Cron) BeforeSave

func (c *Cron) BeforeSave(tx *gorm.DB) error

type CronForm

type CronForm struct {
	TaskType            uint8    `json:"task_type,omitempty" default:"0"` // 0:计划任务 1:触发任务
	Name                string   `json:"name,omitempty" minLength:"1"`
	Scheduler           string   `json:"scheduler,omitempty"`
	Command             string   `json:"command,omitempty" validate:"optional"`
	Servers             []uint64 `json:"servers,omitempty"`
	Cover               uint8    `json:"cover,omitempty" default:"0"`
	PushSuccessful      bool     `json:"push_successful,omitempty" validate:"optional"`
	NotificationGroupID uint64   `json:"notification_group_id,omitempty"`
}

type CtxKeyConnectingIP

type CtxKeyConnectingIP struct{}

type CtxKeyRealIP

type CtxKeyRealIP struct{}

type CycleTransferStats

type CycleTransferStats struct {
	Name       string               `json:"name"`
	From       time.Time            `json:"from"`
	To         time.Time            `json:"to"`
	Max        uint64               `json:"max"`
	Min        uint64               `json:"min"`
	ServerName map[uint64]string    `json:"server_name,omitempty"`
	Transfer   map[uint64]uint64    `json:"transfer,omitempty"`
	NextUpdate map[uint64]time.Time `json:"next_update,omitempty"`
}

type DDNSForm

type DDNSForm struct {
	MaxRetries         uint64   `json:"max_retries,omitempty" default:"3"`
	EnableIPv4         bool     `json:"enable_ipv4,omitempty" validate:"optional"`
	EnableIPv6         bool     `json:"enable_ipv6,omitempty" validate:"optional"`
	Name               string   `json:"name,omitempty" minLength:"1"`
	Provider           string   `json:"provider,omitempty"`
	Domains            []string `json:"domains,omitempty"`
	AccessID           string   `json:"access_id,omitempty" validate:"optional"`
	AccessSecret       string   `json:"access_secret,omitempty" validate:"optional"`
	WebhookURL         string   `json:"webhook_url,omitempty" validate:"optional"`
	WebhookMethod      uint8    `json:"webhook_method,omitempty" validate:"optional" default:"1"`
	WebhookRequestType uint8    `json:"webhook_request_type,omitempty" validate:"optional" default:"1"`
	WebhookRequestBody string   `json:"webhook_request_body,omitempty" validate:"optional"`
	WebhookHeaders     string   `json:"webhook_headers,omitempty" validate:"optional"`
}

type DDNSProfile

type DDNSProfile struct {
	Common
	EnableIPv4         *bool    `json:"enable_ipv4,omitempty"`
	EnableIPv6         *bool    `json:"enable_ipv6,omitempty"`
	MaxRetries         uint64   `json:"max_retries"`
	Name               string   `json:"name"`
	Provider           string   `json:"provider"`
	AccessID           string   `json:"access_id,omitempty"`
	AccessSecret       string   `json:"access_secret,omitempty"`
	WebhookURL         string   `json:"webhook_url,omitempty"`
	WebhookMethod      uint8    `json:"webhook_method,omitempty"`
	WebhookRequestType uint8    `json:"webhook_request_type,omitempty"`
	WebhookRequestBody string   `json:"webhook_request_body,omitempty"`
	WebhookHeaders     string   `json:"webhook_headers,omitempty"`
	Domains            []string `json:"domains" gorm:"-"`
	DomainsRaw         string   `json:"-"`
}

func (*DDNSProfile) AfterFind

func (d *DDNSProfile) AfterFind(tx *gorm.DB) error

func (*DDNSProfile) BeforeSave

func (d *DDNSProfile) BeforeSave(tx *gorm.DB) error

func (DDNSProfile) TableName

func (d DDNSProfile) TableName() string

type Favorite

type Favorite struct {
	Common

	EntityType int    `json:"entityType"` // 收藏实体类型
	EntityId   uint64 `json:"entityId"`   // 收藏实体编号
}

type FrontendTemplate

type FrontendTemplate struct {
	Path       string `json:"path,omitempty"`
	Name       string `json:"name,omitempty"`
	Repository string `json:"repository,omitempty"`
	Author     string `json:"author,omitempty"`
	Version    string `json:"version,omitempty"`
	IsAdmin    bool   `json:"is_admin,omitempty"`
	IsOfficial bool   `json:"is_official,omitempty"`
}

type GeoIP

type GeoIP struct {
	IP          IP     `json:"ip,omitempty"`
	CountryCode string `json:"country_code,omitempty"`
}

func PB2GeoIP

func PB2GeoIP(p *pb.GeoIP) GeoIP

type GetLikeIdsForm

type GetLikeIdsForm struct {
	EntityIds  []uint64 `json:"entityIds"`  // 实体编号
	EntityType int      `json:"entityType"` // 实体类型 	// 创建时间
}

type HTTPSConf

type HTTPSConf struct {
	InsecureTLS bool   `koanf:"insecure_tls" json:"insecure_tls,omitempty"`
	ListenPort  uint16 `koanf:"listen_port" json:"listen_port,omitempty"`
	TLSCertPath string `koanf:"tls_cert_path" json:"tls_cert_path,omitempty"`
	TLSKeyPath  string `koanf:"tls_key_path" json:"tls_key_path,omitempty"`
}

type Host

type Host struct {
	Platform        string   `json:"platform,omitempty"`
	PlatformVersion string   `json:"platform_version,omitempty"`
	CPU             []string `json:"cpu,omitempty"`
	MemTotal        uint64   `json:"mem_total,omitempty"`
	DiskTotal       uint64   `json:"disk_total,omitempty"`
	SwapTotal       uint64   `json:"swap_total,omitempty"`
	Arch            string   `json:"arch,omitempty"`
	Virtualization  string   `json:"virtualization,omitempty"`
	BootTime        uint64   `json:"boot_time,omitempty"`
	Version         string   `json:"version,omitempty"`
	GPU             []string `json:"gpu,omitempty"`
}

func PB2Host

func PB2Host(h *pb.Host) Host

func (*Host) Filter

func (h *Host) Filter() *Host

Filter returns a new instance of Host with some fields redacted.

func (*Host) PB

func (h *Host) PB() *pb.Host

type HostState

type HostState struct {
	CPU            float64             `json:"cpu,omitempty"`
	MemUsed        uint64              `json:"mem_used,omitempty"`
	SwapUsed       uint64              `json:"swap_used,omitempty"`
	DiskUsed       uint64              `json:"disk_used,omitempty"`
	NetInTransfer  uint64              `json:"net_in_transfer,omitempty"`
	NetOutTransfer uint64              `json:"net_out_transfer,omitempty"`
	NetInSpeed     uint64              `json:"net_in_speed,omitempty"`
	NetOutSpeed    uint64              `json:"net_out_speed,omitempty"`
	Uptime         uint64              `json:"uptime,omitempty"`
	Load1          float64             `json:"load_1,omitempty"`
	Load5          float64             `json:"load_5,omitempty"`
	Load15         float64             `json:"load_15,omitempty"`
	TcpConnCount   uint64              `json:"tcp_conn_count,omitempty"`
	UdpConnCount   uint64              `json:"udp_conn_count,omitempty"`
	ProcessCount   uint64              `json:"process_count,omitempty"`
	Temperatures   []SensorTemperature `json:"temperatures,omitempty"`
	GPU            []float64           `json:"gpu,omitempty"`
}

func PB2State

func PB2State(s *pb.State) HostState

func (*HostState) PB

func (s *HostState) PB() *pb.State

type IP

type IP struct {
	IPv4Addr string `json:"ipv4_addr,omitempty"`
	IPv6Addr string `json:"ipv6_addr,omitempty"`
}

func (*IP) Join

func (p *IP) Join() string

type LoginRequest

type LoginRequest struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type LoginResponse

type LoginResponse struct {
	Token  string `json:"token,omitempty"`
	Expire string `json:"expire,omitempty"`
}

type Message

type Message struct {
	Common

	FromId       int64  `json:"fromId"`       // 消息发送人
	UserId       int64  `json:"userId"`       // 用户编号(消息接收人)
	Title        string `json:"title"`        // 消息标题
	Content      string `json:"content"`      // 消息内容
	QuoteContent string `json:"quoteContent"` // 引用内容
	Type         int    `json:"type"`         // 消息类型
	Status       int    `json:"status"`       // 状态:0:未读、1:已读
}

type NAT

type NAT struct {
	Common
	Enabled  bool   `json:"enabled"`
	Name     string `json:"name"`
	ServerID uint64 `json:"server_id"`
	Host     string `json:"host"`
	Domain   string `json:"domain" gorm:"unique"`
}

type NATForm

type NATForm struct {
	Name     string `json:"name,omitempty" minLength:"1"`
	Enabled  bool   `json:"enabled,omitempty"`
	ServerID uint64 `json:"server_id,omitempty"`
	Host     string `json:"host,omitempty"`
	Domain   string `json:"domain,omitempty"`
}

type NResult

type NResult struct {
	N uint64
}

type Notification

type Notification struct {
	Common
	Name          string `json:"name"`
	URL           string `json:"url"`
	RequestMethod uint8  `json:"request_method"`
	RequestType   uint8  `json:"request_type"`
	RequestHeader string `json:"request_header" gorm:"type:longtext"`
	RequestBody   string `json:"request_body" gorm:"type:longtext"`
	VerifyTLS     *bool  `json:"verify_tls,omitempty"`
}

type NotificationForm

type NotificationForm struct {
	Name          string `json:"name,omitempty" minLength:"1"`
	URL           string `json:"url,omitempty"`
	RequestMethod uint8  `json:"request_method,omitempty"`
	RequestType   uint8  `json:"request_type,omitempty"`
	RequestHeader string `json:"request_header,omitempty"`
	RequestBody   string `json:"request_body,omitempty"`
	VerifyTLS     bool   `json:"verify_tls,omitempty" validate:"optional"`
	SkipCheck     bool   `json:"skip_check,omitempty" validate:"optional"`
}

type NotificationGroup

type NotificationGroup struct {
	Common
	Name string `json:"name"`
}

type NotificationGroupForm

type NotificationGroupForm struct {
	Name          string   `json:"name" minLength:"1"`
	Notifications []uint64 `json:"notifications"`
}

type NotificationGroupNotification

type NotificationGroupNotification struct {
	Common
	NotificationGroupID uint64 `json:"notification_group_id" gorm:"uniqueIndex:idx_notification_group_notification"`
	NotificationID      uint64 `json:"notification_id" gorm:"uniqueIndex:idx_notification_group_notification"`
}

type NotificationGroupResponseItem

type NotificationGroupResponseItem struct {
	Group         NotificationGroup `json:"group"`
	Notifications []uint64          `json:"notifications"`
}

type NotificationServerBundle

type NotificationServerBundle struct {
	Notification *Notification
	Server       *Server
	Loc          *time.Location
}

func (*NotificationServerBundle) Send

func (ns *NotificationServerBundle) Send(message string) error

type Oauth2Bind

type Oauth2Bind struct {
	Common

	UserID   uint64 `gorm:"uniqueIndex:u_p_o" json:"user_id,omitempty"`
	Provider string `gorm:"uniqueIndex:u_p_o" json:"provider,omitempty"`
	OpenID   string `gorm:"uniqueIndex:u_p_o" json:"open_id,omitempty"`
}

type Oauth2Callback

type Oauth2Callback struct {
	State string `json:"state,omitempty"`
	Code  string `json:"code,omitempty"`
}

type Oauth2Config

type Oauth2Config struct {
	ClientID     string         `koanf:"client_id" json:"client_id,omitempty"`
	ClientSecret string         `koanf:"client_secret" json:"client_secret,omitempty"`
	Endpoint     Oauth2Endpoint `koanf:"endpoint" json:"endpoint,omitempty"`
	Scopes       []string       `koanf:"scopes" json:"scopes,omitempty"`

	UserInfoURL string `koanf:"user_info_url" json:"user_info_url,omitempty"`
	UserIDPath  string `koanf:"user_id_path" json:"user_id_path,omitempty"`
}

func (*Oauth2Config) Setup

func (c *Oauth2Config) Setup(redirectURL string) *oauth2.Config

type Oauth2Endpoint

type Oauth2Endpoint struct {
	AuthURL  string `koanf:"auth_url" json:"auth_url,omitempty"`
	TokenURL string `koanf:"token_url" json:"token_url,omitempty"`
}

type Oauth2LoginResponse

type Oauth2LoginResponse struct {
	Redirect string `json:"redirect,omitempty"`
}

type Oauth2LoginType

type Oauth2LoginType uint8
const (
	RTypeLogin Oauth2LoginType
	RTypeBind
)

type Oauth2State

type Oauth2State struct {
	Action      Oauth2LoginType
	Provider    string
	State       string
	RedirectURL string
}

type OnlineUser

type OnlineUser struct {
	UserID      uint64    `json:"user_id,omitempty"`
	ConnectedAt time.Time `json:"connected_at,omitempty"`
	IP          string    `json:"ip,omitempty"`

	Conn *websocket.Conn `json:"-"`
}

type PaginatedResponse

type PaginatedResponse[S ~[]E, E any] struct {
	Success bool      `json:"success,omitempty"`
	Data    *Value[S] `json:"data,omitempty"`
	Error   string    `json:"error,omitempty"`
}

type Pagination

type Pagination struct {
	Offset int   `json:"offset,omitempty"`
	Limit  int   `json:"limit,omitempty"`
	Total  int64 `json:"total,omitempty"`
}

type Profile

type Profile struct {
	User
	LoginIP    string            `json:"login_ip,omitempty"`
	Oauth2Bind map[string]string `json:"oauth2_bind,omitempty"`
}

type ProfileForm

type ProfileForm struct {
	OriginalPassword string `json:"original_password,omitempty"`
	NewUsername      string `json:"new_username,omitempty"`
	NewPassword      string `json:"new_password,omitempty"`
	RejectPassword   bool   `json:"reject_password,omitempty" validate:"optional"`
}

type Rule

type Rule struct {
	// 指标类型,cpu、memory、swap、disk、net_in_speed、net_out_speed
	// net_all_speed、transfer_in、transfer_out、transfer_all、offline
	// transfer_in_cycle、transfer_out_cycle、transfer_all_cycle
	Type          string          `json:"type"`
	Min           float64         `json:"min,omitempty" validate:"optional"`                                                        // 最小阈值 (百分比、字节 kb ÷ 1024)
	Max           float64         `json:"max,omitempty" validate:"optional"`                                                        // 最大阈值 (百分比、字节 kb ÷ 1024)
	CycleStart    *time.Time      `json:"cycle_start,omitempty" validate:"optional"`                                                // 流量统计的开始时间
	CycleInterval uint64          `json:"cycle_interval,omitempty" validate:"optional"`                                             // 流量统计周期
	CycleUnit     string          `json:"cycle_unit,omitempty" enums:"hour,day,week,month,year" validate:"optional" default:"hour"` // 流量统计周期单位,默认hour,可选(hour, day, week, month, year)
	Duration      uint64          `json:"duration,omitempty" validate:"optional"`                                                   // 持续时间 (秒)
	Cover         uint64          `json:"cover"`                                                                                    // 覆盖范围 RuleCoverAll/IgnoreAll
	Ignore        map[uint64]bool `json:"ignore,omitempty" validate:"optional"`                                                     // 覆盖范围的排除

	// 只作为缓存使用,记录下次该检测的时间
	NextTransferAt  map[uint64]time.Time `json:"-"`
	LastCycleStatus map[uint64]bool      `json:"-"`
}

func (*Rule) GetTransferDurationEnd

func (u *Rule) GetTransferDurationEnd() time.Time

GetTransferDurationEnd 获取周期流量结束时间

func (*Rule) GetTransferDurationStart

func (u *Rule) GetTransferDurationStart() time.Time

GetTransferDurationStart 获取周期流量的起始时间

func (*Rule) IsOfflineRule

func (u *Rule) IsOfflineRule() bool

func (*Rule) IsTransferDurationRule

func (u *Rule) IsTransferDurationRule() bool

IsTransferDurationRule 判断该规则是否属于周期流量规则 属于则返回true

func (*Rule) Snapshot

func (u *Rule) Snapshot(cycleTransferStats *CycleTransferStats, server *Server, db *gorm.DB) bool

Snapshot 未通过规则返回 false, 通过返回 true

type SensorTemperature

type SensorTemperature struct {
	Name        string
	Temperature float64
}

type Server

type Server struct {
	Common

	Name                   string `json:"name"`
	UUID                   string `json:"uuid,omitempty" gorm:"unique"`
	Note                   string `json:"note,omitempty"`           // 管理员可见备注
	PublicNote             string `json:"public_note,omitempty"`    // 公开备注
	DisplayIndex           int    `json:"display_index"`            // 展示排序,越大越靠前
	HideForGuest           bool   `json:"hide_for_guest,omitempty"` // 对游客隐藏
	EnableDDNS             bool   `json:"enable_ddns,omitempty"`    // 启用DDNS
	DDNSProfilesRaw        string `gorm:"default:'[]';column:ddns_profiles_raw" json:"-"`
	OverrideDDNSDomainsRaw string `gorm:"default:'{}';column:override_ddns_domains_raw" json:"-"`

	DDNSProfiles        []uint64            `gorm:"-" json:"ddns_profiles,omitempty" validate:"optional"` // DDNS配置
	OverrideDDNSDomains map[uint64][]string `gorm:"-" json:"override_ddns_domains,omitempty" validate:"optional"`

	Host       *Host      `gorm:"-" json:"host,omitempty"`
	State      *HostState `gorm:"-" json:"state,omitempty"`
	GeoIP      *GeoIP     `gorm:"-" json:"geoip,omitempty"`
	LastActive time.Time  `gorm:"-" json:"last_active,omitempty"`

	TaskStream  pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"`
	ConfigCache chan any                          `gorm:"-" json:"-"`

	PrevTransferInSnapshot  int64 `gorm:"-" json:"-"` // 上次数据点时的入站使用量
	PrevTransferOutSnapshot int64 `gorm:"-" json:"-"` // 上次数据点时的出站使用量
}

func (*Server) AfterFind

func (s *Server) AfterFind(tx *gorm.DB) error

func (*Server) CopyFromRunningServer

func (s *Server) CopyFromRunningServer(old *Server)

type ServerConfigForm

type ServerConfigForm struct {
	Servers []uint64 `json:"servers,omitempty"`
	Config  string   `json:"config,omitempty"`
}

type ServerForm

type ServerForm struct {
	Name                string              `json:"name,omitempty"`
	Note                string              `json:"note,omitempty" validate:"optional"`           // 管理员可见备注
	PublicNote          string              `json:"public_note,omitempty" validate:"optional"`    // 公开备注
	DisplayIndex        int                 `json:"display_index,omitempty" default:"0"`          // 展示排序,越大越靠前
	HideForGuest        bool                `json:"hide_for_guest,omitempty" validate:"optional"` // 对游客隐藏
	EnableDDNS          bool                `json:"enable_ddns,omitempty" validate:"optional"`    // 启用DDNS
	DDNSProfiles        []uint64            `json:"ddns_profiles,omitempty" validate:"optional"`  // DDNS配置
	OverrideDDNSDomains map[uint64][]string `json:"override_ddns_domains,omitempty" validate:"optional"`
}

type ServerGroup

type ServerGroup struct {
	Common

	Name string `json:"name"`
}

type ServerGroupForm

type ServerGroupForm struct {
	Name    string   `json:"name" minLength:"1"`
	Servers []uint64 `json:"servers"`
}

type ServerGroupResponseItem

type ServerGroupResponseItem struct {
	Group   ServerGroup `json:"group"`
	Servers []uint64    `json:"servers"`
}

type ServerGroupServer

type ServerGroupServer struct {
	Common
	ServerGroupId uint64 `json:"server_group_id" gorm:"uniqueIndex:idx_server_group_server"`
	ServerId      uint64 `json:"server_id" gorm:"uniqueIndex:idx_server_group_server"`
}

type ServerTaskResponse

type ServerTaskResponse struct {
	Success []uint64 `json:"success,omitempty" validate:"optional"`
	Failure []uint64 `json:"failure,omitempty" validate:"optional"`
	Offline []uint64 `json:"offline,omitempty" validate:"optional"`
}

type Service

type Service struct {
	Common
	Name                string `json:"name"`
	Type                uint8  `json:"type"`
	Target              string `json:"target"`
	SkipServersRaw      string `json:"-"`
	Duration            uint64 `json:"duration"`
	Notify              bool   `json:"notify,omitempty"`
	NotificationGroupID uint64 `json:"notification_group_id"` // 当前服务监控所属的通知组 ID
	Cover               uint8  `json:"cover"`

	EnableTriggerTask      bool   `gorm:"default: false" json:"enable_trigger_task,omitempty"`
	EnableShowInService    bool   `gorm:"default: false" json:"enable_show_in_service,omitempty"`
	FailTriggerTasksRaw    string `gorm:"default:'[]'" json:"-"`
	RecoverTriggerTasksRaw string `gorm:"default:'[]'" json:"-"`

	FailTriggerTasks    []uint64 `gorm:"-" json:"fail_trigger_tasks"`    // 失败时执行的触发任务id
	RecoverTriggerTasks []uint64 `gorm:"-" json:"recover_trigger_tasks"` // 恢复时执行的触发任务id

	MinLatency    float32 `json:"min_latency"`
	MaxLatency    float32 `json:"max_latency"`
	LatencyNotify bool    `json:"latency_notify,omitempty"`

	SkipServers map[uint64]bool `gorm:"-" json:"skip_servers"`
	CronJobID   cron.EntryID    `gorm:"-" json:"-"`
}

func (*Service) AfterFind

func (m *Service) AfterFind(tx *gorm.DB) error

func (*Service) BeforeSave

func (m *Service) BeforeSave(tx *gorm.DB) error

func (*Service) CronSpec

func (m *Service) CronSpec() string

CronSpec 返回服务监控请求间隔对应的 cron 表达式

func (*Service) PB

func (m *Service) PB() *pb.Task

type ServiceForm

type ServiceForm struct {
	Name                string          `json:"name,omitempty" minLength:"1"`
	Target              string          `json:"target,omitempty"`
	Type                uint8           `json:"type,omitempty"`
	Cover               uint8           `json:"cover,omitempty"`
	Notify              bool            `json:"notify,omitempty" validate:"optional"`
	Duration            uint64          `json:"duration,omitempty"`
	MinLatency          float32         `json:"min_latency,omitempty" default:"0.0"`
	MaxLatency          float32         `json:"max_latency,omitempty" default:"0.0"`
	LatencyNotify       bool            `json:"latency_notify,omitempty" validate:"optional"`
	EnableTriggerTask   bool            `json:"enable_trigger_task,omitempty" validate:"optional"`
	EnableShowInService bool            `json:"enable_show_in_service,omitempty" validate:"optional"`
	FailTriggerTasks    []uint64        `json:"fail_trigger_tasks,omitempty"`
	RecoverTriggerTasks []uint64        `json:"recover_trigger_tasks,omitempty"`
	SkipServers         map[uint64]bool `json:"skip_servers,omitempty"`
	NotificationGroupID uint64          `json:"notification_group_id,omitempty"`
}

type ServiceHistory

type ServiceHistory struct {
	ID        uint64    `gorm:"primaryKey" json:"id,omitempty"`
	CreatedAt time.Time `gorm:"index;<-:create;index:idx_server_id_created_at_service_id_avg_delay" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
	ServiceID uint64    `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"service_id,omitempty"`
	ServerID  uint64    `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"server_id,omitempty"`
	AvgDelay  float32   `gorm:"index:idx_server_id_created_at_service_id_avg_delay" json:"avg_delay,omitempty"` // 平均延迟,毫秒
	Up        uint64    `json:"up,omitempty"`                                                                   // 检查状态良好计数
	Down      uint64    `json:"down,omitempty"`                                                                 // 检查状态异常计数
	Data      string    `json:"data,omitempty"`
}

type ServiceInfos

type ServiceInfos struct {
	ServiceID   uint64    `json:"monitor_id"`
	ServerID    uint64    `json:"server_id"`
	ServiceName string    `json:"monitor_name"`
	ServerName  string    `json:"server_name"`
	CreatedAt   []int64   `json:"created_at"`
	AvgDelay    []float32 `json:"avg_delay"`
}

type ServiceResponse

type ServiceResponse struct {
	Services           map[uint64]ServiceResponseItem `json:"services,omitempty"`
	CycleTransferStats map[uint64]CycleTransferStats  `json:"cycle_transfer_stats,omitempty"`
}

type ServiceResponseItem

type ServiceResponseItem struct {
	ServiceName string       `json:"service_name,omitempty"`
	CurrentUp   uint64       `json:"current_up"`
	CurrentDown uint64       `json:"current_down"`
	TotalUp     uint64       `json:"total_up"`
	TotalDown   uint64       `json:"total_down"`
	Delay       *[30]float32 `json:"delay,omitempty"`
	Up          *[30]uint64  `json:"up,omitempty"`
	Down        *[30]uint64  `json:"down,omitempty"`
}

func (ServiceResponseItem) TotalUptime

func (r ServiceResponseItem) TotalUptime() float32

type Setting

type Setting struct {
	ConfigForGuests
	ConfigDashboard

	IgnoredIPNotificationServerIDs map[uint64]bool `json:"ignored_ip_notification_server_ids,omitempty"`
	Oauth2Providers                []string        `json:"oauth2_providers,omitempty"`
}

type SettingForm

type SettingForm struct {
	DNSServers                  string `json:"dns_servers,omitempty" validate:"optional"`
	IgnoredIPNotification       string `json:"ignored_ip_notification,omitempty" validate:"optional"`
	IPChangeNotificationGroupID uint64 `json:"ip_change_notification_group_id,omitempty"` // IP变更提醒的通知组
	Cover                       uint8  `json:"cover,omitempty"`
	SiteName                    string `json:"site_name,omitempty" minLength:"1"`
	Language                    string `json:"language,omitempty" minLength:"2"`
	InstallHost                 string `json:"install_host,omitempty" validate:"optional"`
	CustomCode                  string `json:"custom_code,omitempty" validate:"optional"`
	CustomCodeDashboard         string `json:"custom_code_dashboard,omitempty" validate:"optional"`
	RealIPHeader                string `json:"real_ip_header,omitempty" validate:"optional"` // 真实IP
	UserTemplate                string `json:"user_template,omitempty" validate:"optional"`

	AgentTLS                    bool `json:"tls,omitempty" validate:"optional"`
	EnableIPChangeNotification  bool `json:"enable_ip_change_notification,omitempty" validate:"optional"`
	EnablePlainIPInNotification bool `json:"enable_plain_ip_in_notification,omitempty" validate:"optional"`
}

type SettingResponse

type SettingResponse struct {
	Config Setting `json:"config"`

	Version           string             `json:"version,omitempty"`
	FrontendTemplates []FrontendTemplate `json:"frontend_templates,omitempty"`
}

type StreamServer

type StreamServer struct {
	ID           uint64 `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	PublicNote   string `json:"public_note,omitempty"`   // 公开备注,只第一个数据包有值
	DisplayIndex int    `json:"display_index,omitempty"` // 展示排序,越大越靠前

	Host        *Host      `json:"host,omitempty"`
	State       *HostState `json:"state,omitempty"`
	CountryCode string     `json:"country_code,omitempty"`
	LastActive  time.Time  `json:"last_active,omitempty"`
}

type StreamServerData

type StreamServerData struct {
	Now     int64          `json:"now,omitempty"`
	Online  int            `json:"online,omitempty"`
	Servers []StreamServer `json:"servers,omitempty"`
}

type TaskFM

type TaskFM struct {
	StreamID string
}

type TaskNAT

type TaskNAT struct {
	StreamID string
	Host     string
}

type TerminalForm

type TerminalForm struct {
	Protocol string `json:"protocol,omitempty"`
	ServerID uint64 `json:"server_id,omitempty"`
}

type TerminalTask

type TerminalTask struct {
	StreamID string
}

type Tool

type Tool struct {
	Common

	Name        string   `json:"name"`
	Summary     string   `json:"summary"`
	Description string   `json:"description"`
	Downloads   int      `json:"downloads"`
	Enabled     bool     `json:"enabled"`
	FileIdsRaw  string   `gorm:"default:'[]'" json:"-"`
	Files       []Upload `gorm:"-" json:"files"`
}

func (*Tool) AfterFind

func (m *Tool) AfterFind(tx *gorm.DB) error

func (*Tool) BeforeSave

func (m *Tool) BeforeSave(tx *gorm.DB) error

type ToolForm

type ToolForm struct {
	Name        string   `json:"name,omitempty" minLength:"1"`
	Summary     string   `json:"summary,omitempty"`
	Description string   `json:"description,omitempty"`
	Enabled     bool     `json:"enabled,omitempty" validate:"optional"`
	Files       []Upload `json:"files,omitempty"`
}

type ToolGroup

type ToolGroup struct {
	Common

	Name string `json:"name"`
}

type ToolGroupForm

type ToolGroupForm struct {
	Name  string   `json:"name" minLength:"1"`
	Tools []uint64 `json:"tools"`
}

type ToolGroupResponseItem

type ToolGroupResponseItem struct {
	Group ToolGroup `json:"group"`
	Tools []uint64  `json:"tools"`
}

type ToolGroupTool

type ToolGroupTool struct {
	Common
	ToolGroupId uint64 `json:"tool_group_id" gorm:"uniqueIndex:idx_tool_group_tool"`
	ToolId      uint64 `json:"tool_id" gorm:"uniqueIndex:idx_tool_group_tool"`
}

type Topic

type Topic struct {
	Common
	// 用户
	Title             string       `json:"title" form:"title"`                                          // 标题
	Content           string       `gorm:"type:longtext" json:"content" form:"content"`                 // 内容
	AffixList         string       `gorm:"type:longtext" json:"affixList" form:"affixList"`             // 图片 	// 回复可见内容
	Recommend         bool         `json:"recommend" form:"recommend"`                                  // 是否推荐
	RecommendTime     sql.NullTime `json:"recommendTime" swaggertype:"string" form:"recommendTime"`     // 推荐时间
	Sticky            bool         `json:"sticky" form:"sticky"`                                        // 置顶
	StickyTime        sql.NullTime `json:"stickyTime" swaggertype:"string" form:"stickyTime"`           // 置顶时间
	ViewCount         int64        `json:"viewCount" form:"viewCount"`                                  // 查看数量
	CommentCount      int64        `json:"commentCount" form:"commentCount"`                            // 跟帖数量
	LikeCount         int64        `json:"likeCount" form:"likeCount"`                                  // 点赞数量
	Status            int          `json:"status" form:"status"`                                        // 状态:0:正常、1:删除
	LastCommentTime   sql.NullTime `json:"lastCommentTime" swaggertype:"string" form:"lastCommentTime"` // 最后回复时间
	LastCommentUserId uint64       `json:"lastCommentUserId" form:"lastCommentUserId"`                  // 最后回复用户 	// 扩展数据
	Affixes           []Upload     `gorm:"-" json:"affixes"`
	Liked             bool         `gorm:"-" json:"liked"`
	Favorited         bool         `gorm:"-" json:"favorited"`
	UserName          string       `gorm:"-" json:"userName"`
}

func (*Topic) AfterFind

func (m *Topic) AfterFind(tx *gorm.DB) error

func (*Topic) BeforeSave

func (m *Topic) BeforeSave(tx *gorm.DB) error

type TopicForm

type TopicForm struct {
	Title     string `json:"title,omitempty"`                         // 标题
	Content   string `json:"content,omitempty"`                       // 内容 	// 图片 	// 回复可见内容
	Recommend bool   `json:"recommend,omitempty" validate:"optional"` // 是否推荐
	//RecommendTime     time.Time `json:"recommendTime,omitempty" validate:"optional"`     // 推荐时间
	Sticky bool `json:"sticky,omitempty" validate:"optional"` // 置顶
	//StickyTime        time.Time `json:"stickyTime,omitempty" validate:"optional"`        // 置顶时间
	ViewCount    int64 `json:"viewCount,omitempty" validate:"optional"`    // 查看数量
	CommentCount int64 `json:"commentCount,omitempty" validate:"optional"` // 跟帖数量
	LikeCount    int64 `json:"likeCount,omitempty" validate:"optional"`    // 点赞数量
	Status       int   `json:"status,omitempty" validate:"optional"`       // 状态:0:正常、1:删除
	//LastCommentTime   time.Time `json:"lastCommentTime,omitempty" validate:"optional"`   // 最后回复时间
	LastCommentUserId uint64   `json:"lastCommentUserId,omitempty" validate:"optional"` // 最后回复用户 	// 扩展数据
	Affixes           []Upload `json:"affixes,omitempty" validate:"optional"`
	TopicGroup        uint64   `json:"topicGroup,omitempty" validate:"optional"`
}

type TopicGroup

type TopicGroup struct {
	Common

	Name string `json:"name"`
}

type TopicGroupForm

type TopicGroupForm struct {
	Name   string   `json:"name" minLength:"1"`
	Topics []uint64 `json:"topics"`
}

type TopicGroupResponseItem

type TopicGroupResponseItem struct {
	Group  TopicGroup `json:"group"`
	Topics []uint64   `json:"topics"`
}

type TopicGroupTopic

type TopicGroupTopic struct {
	Common
	TopicGroupId uint64 `json:"topic_group_id" gorm:"uniqueIndex:idx_topic_group_topic"`
	TopicId      uint64 `json:"topic_id" gorm:"uniqueIndex:idx_topic_group_topic"`
}

type Transfer

type Transfer struct {
	Common
	ServerID uint64 `json:"server_id"`
	In       uint64 `json:"in"`
	Out      uint64 `json:"out"`
}

type Upload

type Upload struct {
	Common

	Name string `json:"name"` // 文件名
	Url  string `json:"url"`  // 文件地址
	Tag  string `json:"tag"`  // 文件标签
	Key  string `json:"key"`  // 编号
	Size int64  `json:"size"`
}

type User

type User struct {
	Common
	Username       string `json:"username,omitempty" gorm:"uniqueIndex"`
	Password       string `json:"password,omitempty" gorm:"type:char(72)"`
	Role           uint8  `json:"role,omitempty"`
	AgentSecret    string `json:"agent_secret,omitempty" gorm:"type:char(32)"`
	RejectPassword bool   `json:"reject_password,omitempty"`
}

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) error

type UserAdditionalForm

type UserAdditionalForm struct {
	Avatar      string `json:"avatar,omitempty"`
	Description string `json:"description,omitempty"`
}

type UserAdditionalInfo

type UserAdditionalInfo struct {
	Common
	Avatar       string `gorm:"type:text" json:"avatar,omitempty"`
	Description  string `gorm:"type:text" json:"description,omitempty"` // 个人描述
	Status       int    `json:"status"`                                 // 状态
	TopicCount   int    `json:"topicCount"`                             // 帖子数量
	CommentCount int    `json:"commentCount"`                           // 跟帖数量
	FollowCount  int    `json:"followCount"`                            // 关注数量
	FansCount    int    `json:"fansCount"`                              // 粉丝数量
}

type UserFavoriteForm

type UserFavoriteForm struct {
	EntityId   uint64 `json:"entityId"`   // 实体编号
	EntityType int    `json:"entityType"` // 实体类型 	// 创建时间
}

type UserForm

type UserForm struct {
	Role     uint8  `json:"role,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty" gorm:"type:char(72)"`
}

type UserInfo

type UserInfo struct {
	Role        uint8
	AgentSecret string
}

type UserLike

type UserLike struct {
	Common
	EntityId   uint64 `json:"topicId"`    // 实体编号
	EntityType int    `json:"entityType"` // 实体类型 	// 创建时间
}

用户点赞

type UserLikeForm

type UserLikeForm struct {
	EntityId   uint64 `json:"entityId"`   // 实体编号
	EntityType int    `json:"entityType"` // 实体类型 	// 创建时间
}

用户点赞

type Value

type Value[T any] struct {
	Value      T          `json:"value,omitempty"`
	Pagination Pagination `json:"pagination,omitempty"`
}

type WAF

type WAF struct {
	IP              []byte `gorm:"type:binary(16);primaryKey" json:"ip,omitempty"`
	BlockIdentifier int64  `gorm:"primaryKey" json:"block_identifier,omitempty"`
	BlockReason     uint8  `json:"block_reason,omitempty"`
	BlockTimestamp  uint64 `gorm:"index" json:"block_timestamp,omitempty"`
	Count           uint64 `json:"count,omitempty"`
}

func (*WAF) TableName

func (w *WAF) TableName() string

type WAFApiMock

type WAFApiMock struct {
	IP              string `json:"ip,omitempty"`
	BlockIdentifier int64  `json:"block_identifier,omitempty"`
	BlockReason     uint8  `json:"block_reason,omitempty"`
	BlockTimestamp  uint64 `json:"block_timestamp,omitempty"`
	Count           uint64 `json:"count,omitempty"`
}

Jump to

Keyboard shortcuts

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