Documentation
¶
Index ¶
- Constants
- Variables
- func BatchUnblockIP(db *gorm.DB, ip []string) error
- func BlockIP(db *gorm.DB, ip string, reason uint8, uid int64) error
- func CheckIP(db *gorm.DB, ip string) error
- func FindByUserID[S ~[]E, E CommonInterface](s S, uid uint64) []uint64
- func InitServer(s *Server)
- func IsServiceSentinelNeeded(t uint64) bool
- func SearchByIDCtx[S ~[]E, E CommonInterface](c *gin.Context, x S) S
- func SplitList(x []*Server) ([]*Server, []*Server)
- func UnblockIP(db *gorm.DB, ip string, uid int64) error
- type AlertRule
- type AlertRuleForm
- type Comment
- type CommentForm
- type Common
- type CommonInterface
- type CommonResponse
- type Config
- type ConfigDashboard
- type ConfigForGuests
- type CreateFMResponse
- type CreateTerminalResponse
- type Cron
- type CronForm
- type CtxKeyConnectingIP
- type CtxKeyRealIP
- type CycleTransferStats
- type DDNSForm
- type DDNSProfile
- type Favorite
- type FrontendTemplate
- type GeoIP
- type GetLikeIdsForm
- type HTTPSConf
- type Host
- type HostState
- type IP
- type LoginRequest
- type LoginResponse
- type Message
- type NAT
- type NATForm
- type NResult
- type Notification
- type NotificationForm
- type NotificationGroup
- type NotificationGroupForm
- type NotificationGroupNotification
- type NotificationGroupResponseItem
- type NotificationServerBundle
- type Oauth2Bind
- type Oauth2Callback
- type Oauth2Config
- type Oauth2Endpoint
- type Oauth2LoginResponse
- type Oauth2LoginType
- type Oauth2State
- type OnlineUser
- type PaginatedResponse
- type Pagination
- type Profile
- type ProfileForm
- type Rule
- type SensorTemperature
- type Server
- type ServerConfigForm
- type ServerForm
- type ServerGroup
- type ServerGroupForm
- type ServerGroupResponseItem
- type ServerGroupServer
- type ServerTaskResponse
- type Service
- type ServiceForm
- type ServiceHistory
- type ServiceInfos
- type ServiceResponse
- type ServiceResponseItem
- type Setting
- type SettingForm
- type SettingResponse
- type StreamServer
- type StreamServerData
- type TaskFM
- type TaskNAT
- type TerminalForm
- type TerminalTask
- type Tool
- type ToolForm
- type ToolGroup
- type ToolGroupForm
- type ToolGroupResponseItem
- type ToolGroupTool
- type Topic
- type TopicForm
- type TopicGroup
- type TopicGroupForm
- type TopicGroupResponseItem
- type TopicGroupTopic
- type Transfer
- type Upload
- type User
- type UserAdditionalForm
- type UserAdditionalInfo
- type UserFavoriteForm
- type UserForm
- type UserInfo
- type UserLike
- type UserLikeForm
- type Value
- type WAF
- type WAFApiMock
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 (
)
View Source
const (
CacheKeyOauth2State = "cko2s::"
)
View Source
const (
MTReportHostState
)
Variables ¶
View Source
var ProviderList = []string{ ProviderDummy, ProviderWebHook, ProviderCloudflare, ProviderTencentCloud, }
Functions ¶
func FindByUserID ¶
func FindByUserID[S ~[]E, E CommonInterface](s S, uid uint64) []uint64
func InitServer ¶
func InitServer(s *Server)
func IsServiceSentinelNeeded ¶
IsServiceSentinelNeeded 判断该任务类型是否需要进行服务监控 需要则返回true
func SearchByIDCtx ¶
func SearchByIDCtx[S ~[]E, E CommonInterface](c *gin.Context, x S) S
func SplitList ¶
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.
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
}
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"`
}
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 CommonInterface ¶
type CommonResponse ¶
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
}
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 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:"-"`
}
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) BeforeSave ¶
func (d *DDNSProfile) BeforeSave(tx *gorm.DB) error
func (DDNSProfile) TableName ¶
func (d DDNSProfile) TableName() string
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 GetLikeIdsForm ¶
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"`
}
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"`
}
type IP ¶
type LoginRequest ¶
type LoginResponse ¶
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 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 NotificationGroupForm ¶
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 Oauth2Callback ¶
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"`
}
type Oauth2Endpoint ¶
type Oauth2LoginResponse ¶
type Oauth2LoginResponse struct {
Redirect string `json:"redirect,omitempty"`
}
type Oauth2State ¶
type Oauth2State struct {
Action Oauth2LoginType
Provider string
State string
RedirectURL string
}
type OnlineUser ¶
type PaginatedResponse ¶
type Pagination ¶
type ProfileForm ¶
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 ¶
GetTransferDurationEnd 获取周期流量结束时间
func (*Rule) GetTransferDurationStart ¶
GetTransferDurationStart 获取周期流量的起始时间
func (*Rule) IsOfflineRule ¶
func (*Rule) IsTransferDurationRule ¶
IsTransferDurationRule 判断该规则是否属于周期流量规则 属于则返回true
type SensorTemperature ¶
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) CopyFromRunningServer ¶
type ServerConfigForm ¶
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 ServerGroupForm ¶
type ServerGroupResponseItem ¶
type ServerGroupResponseItem struct {
Group ServerGroup `json:"group"`
Servers []uint64 `json:"servers"`
}
type ServerGroupServer ¶
type ServerTaskResponse ¶
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:"-"`
}
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 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 TerminalForm ¶
type TerminalTask ¶
type TerminalTask struct {
StreamID string
}
type Tool ¶
type ToolGroupForm ¶
type ToolGroupResponseItem ¶
type ToolGroupTool ¶
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"`
}
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 TopicGroupForm ¶
type TopicGroupResponseItem ¶
type TopicGroupResponseItem struct {
Group TopicGroup `json:"group"`
Topics []uint64 `json:"topics"`
}
type TopicGroupTopic ¶
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"`
}
type UserAdditionalForm ¶
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 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"`
}
Source Files
¶
- alertrule.go
- alertrule_api.go
- api.go
- comment.go
- comment_api.go
- common.go
- config.go
- cron.go
- cron_api.go
- ddns.go
- ddns_api.go
- favorite.go
- favorite_api.go
- fm_api.go
- host.go
- like.go
- like_api.go
- message.go
- nat.go
- nat_api.go
- notification.go
- notification_api.go
- notification_group.go
- notification_group_api.go
- notification_group_notification.go
- oauth2bind.go
- oauth2config.go
- rule.go
- server.go
- server_api.go
- server_group.go
- server_group_api.go
- server_group_server.go
- service.go
- service_api.go
- service_history.go
- service_history_api.go
- setting_api.go
- terminal_api.go
- tool.go
- tool_api.go
- tool_group.go
- tool_group_api.go
- tool_group_tool.go
- topic.go
- topic_api.go
- topic_group.go
- topic_group_api.go
- topic_group_topic.go
- transfer.go
- upload.go
- user.go
- user_additional_info.go
- user_api.go
- waf.go
Click to show internal directories.
Click to hide internal directories.