Documentation
¶
Index ¶
- Constants
- Variables
- func AddOnlineUser(connId string, user *model.OnlineUser)
- func AlertSentinelStart()
- func BlockByIPs(ipList []string) error
- func CleanServiceHistory()
- func CronTrigger(cr *model.Cron, triggerServer ...uint64) func()
- func GetOnlineUserCount() int
- func GetOnlineUsers(limit, offset int) []*model.OnlineUser
- func GetStatusCode[T constraints.Float | constraints.Integer](percent T) uint8
- func IPDesensitize(ip string) string
- func InitConfigFromPath(path string) error
- func InitDBFromPath(path string)
- func InitFrontendTemplates()
- func InitTimezoneAndCache()
- func LoadSingleton()
- func ManualTrigger(cr *model.Cron)
- func OnDeleteAlert(id []uint64)
- func OnNameserverUpdate()
- func OnRefreshOrAddAlert(alert *model.AlertRule)
- func OnUpdateLang(lang string) error
- func OnUserDelete(id []uint64, errorFunc func(string, ...any) error) error
- func OnUserUpdate(u *model.User)
- func RecordTransferHourlyUsage()
- func RemoveOnlineUser(connId string)
- func StatusCodeToString(statusCode uint8) string
- type ConfigClass
- type CronClass
- func (c *CronClass) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool
- func (c *CronClass) Delete(idList []uint64)
- func (c *CronClass) Get(id K) (s V, ok bool)
- func (c *CronClass) GetList() map[K]V
- func (c *CronClass) GetSortedList() []V
- func (c *CronClass) Range(fn func(k K, v V) bool)
- func (c *CronClass) SendTriggerTasks(taskIDs []uint64, triggerServer uint64)
- func (c *CronClass) Update(cr *model.Cron)
- type DDNSClass
- func (c *DDNSClass) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool
- func (c *DDNSClass) Delete(idList []uint64)
- func (c *DDNSClass) Get(id K) (s V, ok bool)
- func (c *DDNSClass) GetDDNSProvidersFromProfiles(profileId []uint64, ip *model.IP) ([]*ddns2.Provider, error)
- func (c *DDNSClass) GetList() map[K]V
- func (c *DDNSClass) GetSortedList() []V
- func (c *DDNSClass) Range(fn func(k K, v V) bool)
- func (c *DDNSClass) Update(p *model.DDNSProfile)
- type NATClass
- func (c *NATClass) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool
- func (c *NATClass) Delete(idList []uint64)
- func (c *NATClass) Get(id K) (s V, ok bool)
- func (c *NATClass) GetDomain(id uint64) string
- func (c *NATClass) GetList() map[K]V
- func (c *NATClass) GetNATConfigByDomain(domain string) *model.NAT
- func (c *NATClass) GetSortedList() []V
- func (c *NATClass) Range(fn func(k K, v V) bool)
- func (c *NATClass) Update(n *model.NAT)
- type NotificationClass
- func (c *NotificationClass) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool
- func (c *NotificationClass) Delete(idList []uint64)
- func (c *NotificationClass) DeleteGroup(gids []uint64)
- func (c *NotificationClass) Get(id K) (s V, ok bool)
- func (c *NotificationClass) GetGroupName(gid uint64) string
- func (c *NotificationClass) GetList() map[K]V
- func (c *NotificationClass) GetSortedList() []V
- func (c *NotificationClass) Range(fn func(k K, v V) bool)
- func (c *NotificationClass) SendNotification(notificationGroupID uint64, desc string, muteLabel string, ...)
- func (c *NotificationClass) UnMuteNotification(notificationGroupID uint64, muteLabel string)
- func (c *NotificationClass) Update(n *model.Notification)
- func (c *NotificationClass) UpdateGroup(ng *model.NotificationGroup, ngn []uint64)
- type NotificationHistory
- type ReportData
- type ServerClass
- func (c *ServerClass) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool
- func (c *ServerClass) Delete(idList []uint64)
- func (c *ServerClass) Get(id K) (s V, ok bool)
- func (c *ServerClass) GetList() map[K]V
- func (c *ServerClass) GetSortedList() []V
- func (c *ServerClass) GetSortedListForGuest() []*model.Server
- func (c *ServerClass) Range(fn func(k K, v V) bool)
- func (c *ServerClass) UUIDToID(uuid string) (id uint64, ok bool)
- func (c *ServerClass) Update(s *model.Server, uuid string)
- type ServiceSentinel
- func (ss *ServiceSentinel) CheckPermission(c *gin.Context, idList iter.Seq[uint64]) bool
- func (ss *ServiceSentinel) CopyStats() map[uint64]model.ServiceResponseItem
- func (ss *ServiceSentinel) Delete(ids []uint64)
- func (ss *ServiceSentinel) Dispatch(r ReportData)
- func (ss *ServiceSentinel) Get(id uint64) (s *model.Service, ok bool)
- func (ss *ServiceSentinel) GetList() map[uint64]*model.Service
- func (ss *ServiceSentinel) GetSortedList() []*model.Service
- func (ss *ServiceSentinel) LoadStats() map[uint64]*serviceResponseItem
- func (ss *ServiceSentinel) Update(m *model.Service) error
- func (ss *ServiceSentinel) UpdateServiceList()
Constants ¶
View Source
const ( StatusNoData StatusGood StatusLowAvailability StatusDown )
Variables ¶
View Source
var ( AlertsLock sync.RWMutex Alerts []*model.AlertRule AlertsCycleTransferStatsStore map[uint64]*model.CycleTransferStats // [alert_id] -> 对应报警规则的周期流量统计 )
报警规则
View Source
var ( OnlineUserMap = make(map[string]*model.OnlineUser) OnlineUserMapLock sync.Mutex )
View Source
var ( Cache *cache.Cache DB *gorm.DB Loc *time.Location FrontendTemplates []model.FrontendTemplate DashboardBootTime = uint64(time.Now().Unix()) )
View Source
var ( UserInfoMap map[uint64]model.UserInfo AgentSecretToUserId map[string]uint64 UserLock sync.RWMutex )
View Source
var Localizer *i18n.Localizer
View Source
var NotificationMuteLabel _NotificationMuteLabel
View Source
var Version = "debug"
Functions ¶
func AddOnlineUser ¶ added in v1.4.0
func AddOnlineUser(connId string, user *model.OnlineUser)
func BlockByIPs ¶ added in v1.4.0
func CronTrigger ¶
func GetOnlineUserCount ¶ added in v1.4.0
func GetOnlineUserCount() int
func GetOnlineUsers ¶ added in v1.4.0
func GetOnlineUsers(limit, offset int) []*model.OnlineUser
func GetStatusCode ¶
func GetStatusCode[T constraints.Float | constraints.Integer](percent T) uint8
func IPDesensitize ¶
IPDesensitize 根据设置选择是否对IP进行打码处理 返回处理后的IP(关闭打码则返回原IP)
func InitConfigFromPath ¶
InitConfigFromPath 从给出的文件路径中加载配置
func InitFrontendTemplates ¶ added in v1.1.4
func InitFrontendTemplates()
InitFrontendTemplates 从内置文件中加载FrontendTemplates
func InitTimezoneAndCache ¶
func InitTimezoneAndCache()
func ManualTrigger ¶
func OnDeleteAlert ¶
func OnDeleteAlert(id []uint64)
func OnNameserverUpdate ¶
func OnNameserverUpdate()
func OnRefreshOrAddAlert ¶
func OnUpdateLang ¶
func OnUserDelete ¶ added in v1.4.0
func OnUserUpdate ¶ added in v1.4.0
func RecordTransferHourlyUsage ¶
func RecordTransferHourlyUsage()
RecordTransferHourlyUsage 对流量记录进行打点
func RemoveOnlineUser ¶ added in v1.4.0
func RemoveOnlineUser(connId string)
func StatusCodeToString ¶
Types ¶
type ConfigClass ¶ added in v1.9.4
type ConfigClass struct { *model.Config IgnoredIPNotificationServerIDs map[uint64]bool `json:"ignored_ip_notification_server_ids,omitempty"` Oauth2Providers []string `json:"oauth2_providers,omitempty"` }
var Conf *ConfigClass
func (*ConfigClass) Save ¶ added in v1.9.4
func (c *ConfigClass) Save() error
type CronClass ¶ added in v1.8.0
type CronClass struct { *cron.Cron // contains filtered or unexported fields }
func NewCronClass ¶ added in v1.8.0
func NewCronClass() *CronClass
func (*CronClass) CheckPermission ¶ added in v1.8.0
func (*CronClass) GetSortedList ¶ added in v1.8.0
func (c *CronClass) GetSortedList() []V
func (*CronClass) SendTriggerTasks ¶ added in v1.8.0
type DDNSClass ¶ added in v1.8.0
type DDNSClass struct {
// contains filtered or unexported fields
}
func NewDDNSClass ¶ added in v1.8.0
func NewDDNSClass() *DDNSClass
func (*DDNSClass) CheckPermission ¶ added in v1.8.0
func (*DDNSClass) GetDDNSProvidersFromProfiles ¶ added in v1.8.0
func (*DDNSClass) GetSortedList ¶ added in v1.8.0
func (c *DDNSClass) GetSortedList() []V
func (*DDNSClass) Update ¶ added in v1.8.0
func (c *DDNSClass) Update(p *model.DDNSProfile)
type NATClass ¶ added in v1.8.0
type NATClass struct {
// contains filtered or unexported fields
}
func NewNATClass ¶ added in v1.8.0
func NewNATClass() *NATClass
func (*NATClass) CheckPermission ¶ added in v1.8.0
func (*NATClass) GetNATConfigByDomain ¶ added in v1.8.0
func (*NATClass) GetSortedList ¶ added in v1.8.0
func (c *NATClass) GetSortedList() []V
type NotificationClass ¶ added in v1.8.0
type NotificationClass struct {
// contains filtered or unexported fields
}
func NewNotificationClass ¶ added in v1.8.0
func NewNotificationClass() *NotificationClass
func (*NotificationClass) CheckPermission ¶ added in v1.8.0
func (*NotificationClass) Delete ¶ added in v1.8.0
func (c *NotificationClass) Delete(idList []uint64)
func (*NotificationClass) DeleteGroup ¶ added in v1.8.0
func (c *NotificationClass) DeleteGroup(gids []uint64)
func (*NotificationClass) Get ¶ added in v1.8.0
func (c *NotificationClass) Get(id K) (s V, ok bool)
func (*NotificationClass) GetGroupName ¶ added in v1.8.0
func (c *NotificationClass) GetGroupName(gid uint64) string
func (*NotificationClass) GetSortedList ¶ added in v1.8.0
func (c *NotificationClass) GetSortedList() []V
func (*NotificationClass) Range ¶ added in v1.8.0
func (c *NotificationClass) Range(fn func(k K, v V) bool)
func (*NotificationClass) SendNotification ¶ added in v1.8.0
func (c *NotificationClass) SendNotification(notificationGroupID uint64, desc string, muteLabel string, ext ...*model.Server)
SendNotification 向指定的通知方式组的所有通知方式发送通知
func (*NotificationClass) UnMuteNotification ¶ added in v1.8.0
func (c *NotificationClass) UnMuteNotification(notificationGroupID uint64, muteLabel string)
func (*NotificationClass) Update ¶ added in v1.8.0
func (c *NotificationClass) Update(n *model.Notification)
func (*NotificationClass) UpdateGroup ¶ added in v1.8.0
func (c *NotificationClass) UpdateGroup(ng *model.NotificationGroup, ngn []uint64)
type NotificationHistory ¶
type ReportData ¶
type ReportData struct { Data *pb.TaskResult Reporter uint64 }
type ServerClass ¶ added in v1.8.0
type ServerClass struct {
// contains filtered or unexported fields
}
func NewServerClass ¶ added in v1.8.0
func NewServerClass() *ServerClass
func (*ServerClass) CheckPermission ¶ added in v1.8.0
func (*ServerClass) Delete ¶ added in v1.8.0
func (c *ServerClass) Delete(idList []uint64)
func (*ServerClass) GetSortedList ¶ added in v1.8.0
func (c *ServerClass) GetSortedList() []V
func (*ServerClass) GetSortedListForGuest ¶ added in v1.8.0
func (c *ServerClass) GetSortedListForGuest() []*model.Server
type ServiceSentinel ¶
type ServiceSentinel struct {
// contains filtered or unexported fields
}
使用缓存 channel,处理上报的 Service 请求结果,然后判断是否需要报警 需要记录上一次的状态信息
加锁顺序:serviceResponseDataStoreLock > monthlyStatusLock > servicesLock
func NewServiceSentinel ¶
func NewServiceSentinel(serviceSentinelDispatchBus chan<- *model.Service, sc *ServerClass, nc *NotificationClass, crc *CronClass) (*ServiceSentinel, error)
NewServiceSentinel 创建服务监控器
func (*ServiceSentinel) CheckPermission ¶ added in v1.8.0
func (*ServiceSentinel) CopyStats ¶ added in v1.0.22
func (ss *ServiceSentinel) CopyStats() map[uint64]model.ServiceResponseItem
func (*ServiceSentinel) Delete ¶ added in v1.8.0
func (ss *ServiceSentinel) Delete(ids []uint64)
func (*ServiceSentinel) Dispatch ¶
func (ss *ServiceSentinel) Dispatch(r ReportData)
Dispatch 将传入的 ReportData 传给 服务状态汇报管道
func (*ServiceSentinel) Get ¶ added in v1.8.0
func (ss *ServiceSentinel) Get(id uint64) (s *model.Service, ok bool)
func (*ServiceSentinel) GetList ¶ added in v1.8.0
func (ss *ServiceSentinel) GetList() map[uint64]*model.Service
func (*ServiceSentinel) GetSortedList ¶ added in v1.8.0
func (ss *ServiceSentinel) GetSortedList() []*model.Service
func (*ServiceSentinel) LoadStats ¶
func (ss *ServiceSentinel) LoadStats() map[uint64]*serviceResponseItem
func (*ServiceSentinel) Update ¶ added in v1.8.0
func (ss *ServiceSentinel) Update(m *model.Service) error
func (*ServiceSentinel) UpdateServiceList ¶ added in v1.0.22
func (ss *ServiceSentinel) UpdateServiceList()
Click to show internal directories.
Click to hide internal directories.