Documentation
¶
Index ¶
- Constants
- type AccountService
- func (s *AccountService) GetAuthConfig() *AuthConfig
- func (s *AccountService) GetGitHubAuthURL() (*GitHubAuthURL, error)
- func (s *AccountService) GetOIDCAuthURL() (*OIDCAuthURL, error)
- func (s *AccountService) Login(ctx context.Context, username, password string) (*LoginResponse, error)
- func (s *AccountService) LoginWithGitHub(ctx context.Context, code, state string) (*LoginResponse, error)
- func (s *AccountService) LoginWithOIDC(ctx context.Context, code, state string) (*LoginResponse, error)
- func (s *AccountService) Logout(ctx context.Context, userID string) error
- func (s *AccountService) ValidateToken(tokenString string) (*JWTClaims, error)
- type AgentService
- func (s *AgentService) BatchUpdateTags(ctx context.Context, agentIDs []string, tags []string, operation string) error
- func (s *AgentService) BatchUpdateVisibility(ctx context.Context, agentIDs []string, visibility string) error
- func (s *AgentService) DeleteAgent(ctx context.Context, agentID string) error
- func (s *AgentService) GetAgent(ctx context.Context, agentID string) (*models.Agent, error)
- func (s *AgentService) GetAgentByAuth(ctx context.Context, id string, isAuthenticated bool) (*models.Agent, error)
- func (s *AgentService) GetAllTags(ctx context.Context) ([]string, error)
- func (s *AgentService) GetAuditResult(ctx context.Context, agentID string) (*protocol.VPSAuditResult, error)
- func (s *AgentService) GetStatistics(ctx context.Context) (map[string]interface{}, error)
- func (s *AgentService) HandleCommandResponse(ctx context.Context, agentID string, resp *protocol.CommandResponse) error
- func (s *AgentService) InitStatus(ctx context.Context) error
- func (s *AgentService) IsAgentByIP(ctx context.Context, ip string) (bool, error)
- func (s *AgentService) ListAgents(ctx context.Context) ([]models.Agent, error)
- func (s *AgentService) ListAuditResults(ctx context.Context, agentID string) ([]map[string]interface{}, error)
- func (s *AgentService) ListByAuth(ctx context.Context, isAuthenticated bool) ([]models.Agent, error)
- func (s *AgentService) ListOnlineAgents(ctx context.Context) ([]models.Agent, error)
- func (s *AgentService) RegisterAgent(ctx context.Context, ip string, info *protocol.AgentInfo, apiKey string) (*models.Agent, error)
- func (s *AgentService) SaveAuditResult(ctx context.Context, agentID string, result *protocol.VPSAuditResult) error
- func (s *AgentService) UpdateAgentStatus(ctx context.Context, agentID string, status int) error
- func (s *AgentService) UpdatePublicIP(ctx context.Context, agentID string, ipv4 string, ipv6 string) error
- type AlertService
- func (s *AlertService) CheckAgentExpireAlerts(ctx context.Context) error
- func (s *AlertService) CheckMetrics(ctx context.Context, agentID string, cpu, memory, disk, networkSpeed float64) error
- func (s *AlertService) CheckMonitorAlerts(ctx context.Context) error
- func (s *AlertService) Clear(ctx context.Context) error
- func (s *AlertService) Shutdown()
- type AlertTypeMetadata
- type ApiKeyService
- func (s *ApiKeyService) DeleteApiKey(ctx context.Context, id string) error
- func (s *ApiKeyService) DisableApiKey(ctx context.Context, id string) error
- func (s *ApiKeyService) EnableApiKey(ctx context.Context, id string) error
- func (s *ApiKeyService) FillLegacyApiKeyType(ctx context.Context) error
- func (s *ApiKeyService) GenerateApiKey(ctx context.Context, name, userID, keyType string) (*models.ApiKey, error)
- func (s *ApiKeyService) GetApiKey(ctx context.Context, id string) (*models.ApiKey, error)
- func (s *ApiKeyService) ListApiKeys(ctx context.Context, page, pageSize int) ([]models.ApiKey, int64, error)
- func (s *ApiKeyService) ListUserApiKeys(ctx context.Context, userID string, page, pageSize int) ([]models.ApiKey, int64, error)
- func (s *ApiKeyService) UpdateApiKeyName(ctx context.Context, id, name string) error
- func (s *ApiKeyService) ValidateApiKey(ctx context.Context, key string, keyType string) (*models.ApiKey, error)
- type AuthConfig
- type DDNSService
- func (s *DDNSService) CreateConfig(ctx context.Context, config *models.DDNSConfig) error
- func (s *DDNSService) DeleteConfig(ctx context.Context, id string) error
- func (s *DDNSService) GetConfig(ctx context.Context, id string) (*models.DDNSConfig, error)
- func (s *DDNSService) GetConfigByAgentID(ctx context.Context, agentID string) (*models.DDNSConfig, error)
- func (s *DDNSService) GetDDNSConfig(config *models.DDNSConfig) (*protocol.DDNSConfigData, error)
- func (s *DDNSService) HandleIPReport(ctx context.Context, agentID string, ipData *protocol.DDNSIPReportData) error
- func (s *DDNSService) ListConfigsByAgentID(ctx context.Context, agentID string) ([]models.DDNSConfig, error)
- func (s *DDNSService) ListRecords(ctx context.Context, configID string, limit int) ([]models.DDNSRecord, error)
- func (s *DDNSService) ListRecordsByAgentID(ctx context.Context, agentID string, limit int) ([]models.DDNSRecord, error)
- func (s *DDNSService) Run(ctx context.Context)
- func (s *DDNSService) TriggerUpdate(ctx context.Context, configID string) error
- func (s *DDNSService) UpdateConfig(ctx context.Context, config *models.DDNSConfig) error
- func (s *DDNSService) UpdateEnabled(ctx context.Context, id string, enabled bool) error
- type GeoIPService
- type GitHubAccessTokenResponse
- type GitHubAuthURL
- type GitHubOAuthService
- type GitHubUserInfo
- type JWTClaims
- type LoginResponse
- type MetricService
- func (s *MetricService) CleanAgentFromMonitorCache(agentID string)
- func (s *MetricService) CleanAgentMetrics(ctx context.Context, agentID string) error
- func (s *MetricService) CleanMonitorCache(ctx context.Context, monitorID string) error
- func (s *MetricService) CleanOrphanedAgentMetrics(ctx context.Context) error
- func (s *MetricService) DeleteAgentLatestMetricsCache(agentID string)
- func (s *MetricService) DeleteAgentMetrics(ctx context.Context, agentID string) error
- func (s *MetricService) DeleteMonitorMetrics(ctx context.Context, monitorID string) error
- func (s *MetricService) GetAvailableNetworkInterfaces(ctx context.Context, agentID string) ([]string, error)
- func (s *MetricService) GetLatestMetrics(agentID string) (*metric.LatestMetrics, bool)
- func (s *MetricService) GetMetrics(ctx context.Context, agentID, metricType string, start, end int64, ...) (*metric.GetMetricsResponse, error)
- func (s *MetricService) GetMonitorAgentStats(ctx context.Context, monitorID string) []protocol.MonitorData
- func (s *MetricService) GetMonitorHistory(ctx context.Context, monitorID string, start, end int64, aggregation string) (*metric.GetMetricsResponse, error)
- func (s *MetricService) GetMonitorStats(ctx context.Context, monitorID string) *metric.MonitorStatsResult
- func (s *MetricService) HandleMetricData(ctx context.Context, agentID string, metricType string, data json.RawMessage, ...) error
- type MonitorScheduler
- type MonitorService
- func (s *MonitorService) CreateMonitor(ctx context.Context, req *MonitorTaskRequest) (*models.MonitorTask, error)
- func (s *MonitorService) DeleteMonitor(ctx context.Context, id string) error
- func (s *MonitorService) GetAllLatestMonitorMetrics(ctx context.Context) ([]protocol.MonitorData, error)
- func (s *MonitorService) GetLatestMonitorMetricsByType(ctx context.Context, monitorType string) ([]protocol.MonitorData, error)
- func (s *MonitorService) GetMonitorByAuth(ctx context.Context, id string, isAuthenticated bool) (*models.MonitorTask, error)
- func (s *MonitorService) GetMonitorStatsByID(ctx context.Context, monitorID string) (*metric.PublicMonitorOverview, error)
- func (s *MonitorService) ListByAuth(ctx context.Context, isAuthenticated bool) ([]metric.PublicMonitorOverview, error)
- func (s *MonitorService) SendMonitorTaskToAgents(ctx context.Context, monitor models.MonitorTask) error
- func (s *MonitorService) SetScheduler(scheduler MonitorScheduler)
- func (s *MonitorService) UpdateMonitor(ctx context.Context, id string, req *MonitorTaskRequest) (*models.MonitorTask, error)
- type MonitorTaskRequest
- type NotificationQueue
- type NotificationService
- type NotificationTask
- type Notifier
- func (n *Notifier) SendDingTalkByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendEmailByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendFeishuByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendNotificationByConfig(ctx context.Context, channelConfig *models.NotificationChannelConfig, ...) error
- func (n *Notifier) SendNotificationByConfigs(ctx context.Context, channelConfigs []models.NotificationChannelConfig, ...) error
- func (n *Notifier) SendTelegramByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendTestNotification(ctx context.Context, channelType string, config map[string]interface{}, ...) error
- func (n *Notifier) SendWeComAppByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendWeComByConfig(ctx context.Context, config map[string]interface{}, message string) error
- func (n *Notifier) SendWebhookByConfig(ctx context.Context, config map[string]interface{}, message string) error
- type OIDCAuthURL
- type OIDCService
- type PropertyService
- func (s *PropertyService) DeleteDNSProvider(ctx context.Context, providerType string) error
- func (s *PropertyService) Get(ctx context.Context, id string) (*models.Property, error)
- func (s *PropertyService) GetAgentInstallConfig(ctx context.Context) (*models.AgentInstallConfig, error)
- func (s *PropertyService) GetAlertConfig(ctx context.Context) (*models.AlertConfig, error)
- func (s *PropertyService) GetDNSProviderByType(ctx context.Context, providerType string) (*models.DNSProviderConfig, error)
- func (s *PropertyService) GetDNSProviderConfigs(ctx context.Context) ([]models.DNSProviderConfig, error)
- func (s *PropertyService) GetNotificationChannelConfigs(ctx context.Context) ([]models.NotificationChannelConfig, error)
- func (s *PropertyService) GetPublicIPConfig(ctx context.Context) (*models.PublicIPConfig, error)
- func (s *PropertyService) GetSystemConfig(ctx context.Context) (*models.SystemConfig, error)
- func (s *PropertyService) GetSystemVersion(ctx context.Context) (string, error)
- func (s *PropertyService) GetValue(ctx context.Context, id string, target interface{}) error
- func (s *PropertyService) InitializeDefaultConfigs(ctx context.Context) error
- func (s *PropertyService) Set(ctx context.Context, id string, name string, value interface{}) error
- func (s *PropertyService) SetAgentInstallConfig(ctx context.Context, config models.AgentInstallConfig) error
- func (s *PropertyService) SetAlertConfig(ctx context.Context, config models.AlertConfig) error
- func (s *PropertyService) SetDNSProviderConfigs(ctx context.Context, providers []models.DNSProviderConfig) error
- func (s *PropertyService) SetSystemVersion(ctx context.Context, systemVersion string) error
- func (s *PropertyService) UpsertDNSProvider(ctx context.Context, newProvider models.DNSProviderConfig) error
- type PublicIPService
- type SSHLoginService
- func (s *SSHLoginService) DeleteEventsByAgentID(ctx context.Context, agentID string) error
- func (s *SSHLoginService) GetConfig(ctx context.Context, agentID string) (*models.SSHLoginConfigData, error)
- func (s *SSHLoginService) HandleConfigResult(ctx context.Context, agentID string, result protocol.SSHLoginConfigResult) error
- func (s *SSHLoginService) HandleEvent(ctx context.Context, agentID string, eventData protocol.SSHLoginEvent) error
- func (s *SSHLoginService) UpdateConfig(ctx context.Context, agentID string, req *models.SSHLoginConfigData) error
- type TamperService
- func (s *TamperService) BuildInitialConfig(ctx context.Context, agentID string) (added, removed []string, err error)
- func (s *TamperService) CreateEvent(ctx context.Context, agentID string, eventData *protocol.TamperEventData) error
- func (s *TamperService) DeleteEventsByAgentID(ctx context.Context, id string) error
- func (s *TamperService) GetConfigByAgentID(ctx context.Context, agentID string) (*models.TamperProtectConfigData, error)
- func (s *TamperService) HandleConfigResult(ctx context.Context, agentID string, resp protocol.TamperProtectResponse) error
- func (s *TamperService) UpdateConfig(ctx context.Context, agentID string, req *models.TamperProtectConfigData) error
- func (s *TamperService) UpdateConfigByAgentID(ctx context.Context, agentID string, config *models.TamperProtectConfigData) error
- type TrafficAlerts
- type TrafficService
- func (s *TrafficService) CheckAndResetTraffic(ctx context.Context) error
- func (s *TrafficService) GetTrafficStats(ctx context.Context, agentID string) (*TrafficStats, error)
- func (s *TrafficService) ResetAgentTraffic(ctx context.Context, agentID string) error
- func (s *TrafficService) UpdateAgentTraffic(ctx context.Context, agentID string, currentRecvTotal, currentSentTotal uint64) error
- func (s *TrafficService) UpdateTrafficConfig(ctx context.Context, agentID string, enabled bool, trafficType string, ...) error
- type TrafficStats
- type UserInfo
- type UserService
- type WeComResult
Constants ¶
const ( NotificationTypeTraffic = "traffic" NotificationTypeSSHLogin = "ssh_login" NotificationTypeTamperEvt = "tamper" )
const ( // PropertyIDSystemVersion 系统版本的固定 ID PropertyIDSystemVersion = "version" // PropertyIDNotificationChannels 通知渠道配置的固定 ID PropertyIDNotificationChannels = "notification_channels" // PropertyIDSystemConfig 系统配置的固定 ID PropertyIDSystemConfig = "system_config" // PropertyIDPublicIPConfig 公网 IP 采集配置的固定 ID PropertyIDPublicIPConfig = "public_ip_config" // PropertyIDAlertConfig 告警配置的固定 ID PropertyIDAlertConfig = "alert_config" // PropertyIDDNSProviders DNS 服务商配置的固定 ID PropertyIDDNSProviders = "dns_providers" // PropertyIDAgentInstallConfig 探针安装配置的固定 ID PropertyIDAgentInstallConfig = "agent_install_config" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
func NewAccountService ¶
func NewAccountService(logger *zap.Logger, userService *UserService, oidcService *OIDCService, githubService *GitHubOAuthService, appConfig *config.AppConfig) *AccountService
func (*AccountService) GetAuthConfig ¶
func (s *AccountService) GetAuthConfig() *AuthConfig
GetAuthConfig 获取认证配置
func (*AccountService) GetGitHubAuthURL ¶
func (s *AccountService) GetGitHubAuthURL() (*GitHubAuthURL, error)
GetGitHubAuthURL 获取 GitHub 认证 URL
func (*AccountService) GetOIDCAuthURL ¶
func (s *AccountService) GetOIDCAuthURL() (*OIDCAuthURL, error)
GetOIDCAuthURL 获取 OIDC 认证 URL
func (*AccountService) Login ¶
func (s *AccountService) Login(ctx context.Context, username, password string) (*LoginResponse, error)
Login 用户登录(Basic Auth)
func (*AccountService) LoginWithGitHub ¶
func (s *AccountService) LoginWithGitHub(ctx context.Context, code, state string) (*LoginResponse, error)
LoginWithGitHub GitHub 登录
func (*AccountService) LoginWithOIDC ¶
func (s *AccountService) LoginWithOIDC(ctx context.Context, code, state string) (*LoginResponse, error)
LoginWithOIDC OIDC 登录
func (*AccountService) Logout ¶
func (s *AccountService) Logout(ctx context.Context, userID string) error
Logout 用户登出
func (*AccountService) ValidateToken ¶
func (s *AccountService) ValidateToken(tokenString string) (*JWTClaims, error)
ValidateToken 验证 JWT token
type AgentService ¶
type AgentService struct {
*orz.Service
AgentRepo *repo.AgentRepo
TamperEventRepo *repo.TamperEventRepo
SSHLoginEventRepo *repo.SSHLoginEventRepo
// contains filtered or unexported fields
}
func NewAgentService ¶
func NewAgentService(logger *zap.Logger, db *gorm.DB, apiKeyService *ApiKeyService, metricService *MetricService, geoipService *GeoIPService) *AgentService
func (*AgentService) BatchUpdateTags ¶
func (s *AgentService) BatchUpdateTags(ctx context.Context, agentIDs []string, tags []string, operation string) error
BatchUpdateTags 批量更新探针标签 operation: "add" 添加标签, "remove" 移除标签, "replace" 替换标签
func (*AgentService) BatchUpdateVisibility ¶ added in v0.1.3
func (s *AgentService) BatchUpdateVisibility(ctx context.Context, agentIDs []string, visibility string) error
BatchUpdateVisibility 批量更新探针可见性
func (*AgentService) DeleteAgent ¶
func (s *AgentService) DeleteAgent(ctx context.Context, agentID string) error
DeleteAgent 删除探针及其所有相关数据
func (*AgentService) GetAgentByAuth ¶
func (s *AgentService) GetAgentByAuth(ctx context.Context, id string, isAuthenticated bool) (*models.Agent, error)
GetAgentByAuth 根据认证状态获取探针(已登录返回全部,未登录返回公开可见) 支持完整UUID和短ID(前缀匹配)
func (*AgentService) GetAllTags ¶
func (s *AgentService) GetAllTags(ctx context.Context) ([]string, error)
GetAllTags 获取所有探针的标签
func (*AgentService) GetAuditResult ¶
func (s *AgentService) GetAuditResult(ctx context.Context, agentID string) (*protocol.VPSAuditResult, error)
GetAuditResult 获取最新的审计结果(原始数据)
func (*AgentService) GetStatistics ¶
func (s *AgentService) GetStatistics(ctx context.Context) (map[string]interface{}, error)
GetStatistics 获取探针统计数据
func (*AgentService) HandleCommandResponse ¶
func (s *AgentService) HandleCommandResponse(ctx context.Context, agentID string, resp *protocol.CommandResponse) error
HandleCommandResponse 处理指令响应
func (*AgentService) InitStatus ¶
func (s *AgentService) InitStatus(ctx context.Context) error
func (*AgentService) IsAgentByIP ¶ added in v0.1.2
IsAgentByIP 检查指定公网IP是否为探针
func (*AgentService) ListAgents ¶
ListAgents 列出所有探针
func (*AgentService) ListAuditResults ¶
func (s *AgentService) ListAuditResults(ctx context.Context, agentID string) ([]map[string]interface{}, error)
ListAuditResults 获取审计结果列表
func (*AgentService) ListByAuth ¶
func (s *AgentService) ListByAuth(ctx context.Context, isAuthenticated bool) ([]models.Agent, error)
ListByAuth 根据认证状态列出探针(已登录返回全部,未登录返回公开可见)
func (*AgentService) ListOnlineAgents ¶
ListOnlineAgents 列出所有在线探针
func (*AgentService) RegisterAgent ¶
func (s *AgentService) RegisterAgent(ctx context.Context, ip string, info *protocol.AgentInfo, apiKey string) (*models.Agent, error)
RegisterAgent 注册探针
func (*AgentService) SaveAuditResult ¶
func (s *AgentService) SaveAuditResult(ctx context.Context, agentID string, result *protocol.VPSAuditResult) error
SaveAuditResult 保存审计结果
func (*AgentService) UpdateAgentStatus ¶
UpdateAgentStatus 更新探针状态
func (*AgentService) UpdatePublicIP ¶ added in v0.1.2
func (s *AgentService) UpdatePublicIP(ctx context.Context, agentID string, ipv4 string, ipv6 string) error
UpdatePublicIP 更新探针的公网 IP 信息
type AlertService ¶
type AlertService struct {
Service *orz.Service
AlertRecordRepo *repo.AlertRecordRepo
AlertStateRepo *repo.AlertStateRepo
// contains filtered or unexported fields
}
AlertService 告警服务
func NewAlertService ¶
func NewAlertService(logger *zap.Logger, db *gorm.DB, propertyService *PropertyService, monitorService *MonitorService, notifier *Notifier) *AlertService
func (*AlertService) CheckAgentExpireAlerts ¶ added in v0.1.12
func (s *AlertService) CheckAgentExpireAlerts(ctx context.Context) error
CheckAgentExpireAlerts 检查机器到期提醒
func (*AlertService) CheckMetrics ¶
func (s *AlertService) CheckMetrics(ctx context.Context, agentID string, cpu, memory, disk, networkSpeed float64) error
CheckMetrics 检查指标并触发告警
func (*AlertService) CheckMonitorAlerts ¶
func (s *AlertService) CheckMonitorAlerts(ctx context.Context) error
CheckMonitorAlerts 检查监控相关告警(证书和服务下线)
type AlertTypeMetadata ¶ added in v0.0.17
type AlertTypeMetadata struct {
Name string // 中文名称
ThresholdUnit string // 阈值单位
ValueUnit string // 当前值单位
ShowThreshold bool // 是否显示阈值
ShowActual bool // 是否显示当前值
}
AlertTypeMetadata 告警类型元数据
type ApiKeyService ¶
type ApiKeyService struct {
ApiKeyRepo *repo.ApiKeyRepo
// contains filtered or unexported fields
}
func NewApiKeyService ¶
func NewApiKeyService(logger *zap.Logger, db *gorm.DB) *ApiKeyService
func (*ApiKeyService) DeleteApiKey ¶
func (s *ApiKeyService) DeleteApiKey(ctx context.Context, id string) error
DeleteApiKey 删除API密钥
func (*ApiKeyService) DisableApiKey ¶
func (s *ApiKeyService) DisableApiKey(ctx context.Context, id string) error
DisableApiKey 禁用API密钥
func (*ApiKeyService) EnableApiKey ¶
func (s *ApiKeyService) EnableApiKey(ctx context.Context, id string) error
EnableApiKey 启用API密钥
func (*ApiKeyService) FillLegacyApiKeyType ¶ added in v0.1.9
func (s *ApiKeyService) FillLegacyApiKeyType(ctx context.Context) error
FillLegacyApiKeyType 将旧版本未标记类型的密钥回填为通信密钥。
func (*ApiKeyService) GenerateApiKey ¶
func (s *ApiKeyService) GenerateApiKey(ctx context.Context, name, userID, keyType string) (*models.ApiKey, error)
GenerateApiKey 生成API密钥
func (*ApiKeyService) ListApiKeys ¶
func (s *ApiKeyService) ListApiKeys(ctx context.Context, page, pageSize int) ([]models.ApiKey, int64, error)
ListApiKeys 列出所有API密钥
func (*ApiKeyService) ListUserApiKeys ¶
func (s *ApiKeyService) ListUserApiKeys(ctx context.Context, userID string, page, pageSize int) ([]models.ApiKey, int64, error)
ListUserApiKeys 列出用户的API密钥
func (*ApiKeyService) UpdateApiKeyName ¶
func (s *ApiKeyService) UpdateApiKeyName(ctx context.Context, id, name string) error
UpdateApiKeyName 更新API密钥名称
func (*ApiKeyService) ValidateApiKey ¶
func (s *ApiKeyService) ValidateApiKey(ctx context.Context, key string, keyType string) (*models.ApiKey, error)
ValidateApiKey 验证API密钥
type AuthConfig ¶
type AuthConfig struct {
OIDCEnabled bool `json:"oidcEnabled"`
GitHubEnabled bool `json:"githubEnabled"`
PasswordEnabled bool `json:"passwordEnabled"`
}
AuthConfig 认证配置
type DDNSService ¶
type DDNSService struct {
ConfigRepo *repo.DDNSConfigRepo // 导出用于 handler 的 PageBuilder
// contains filtered or unexported fields
}
func NewDDNSService ¶
func NewDDNSService( logger *zap.Logger, db *gorm.DB, propertyService *PropertyService, wsManager *websocket.Manager, ) *DDNSService
func (*DDNSService) CreateConfig ¶
func (s *DDNSService) CreateConfig(ctx context.Context, config *models.DDNSConfig) error
CreateConfig 创建 DDNS 配置
func (*DDNSService) DeleteConfig ¶
func (s *DDNSService) DeleteConfig(ctx context.Context, id string) error
DeleteConfig 删除 DDNS 配置
func (*DDNSService) GetConfig ¶
func (s *DDNSService) GetConfig(ctx context.Context, id string) (*models.DDNSConfig, error)
GetConfig 获取 DDNS 配置
func (*DDNSService) GetConfigByAgentID ¶
func (s *DDNSService) GetConfigByAgentID(ctx context.Context, agentID string) (*models.DDNSConfig, error)
GetConfigByAgentID 获取探针的 DDNS 配置
func (*DDNSService) GetDDNSConfig ¶
func (s *DDNSService) GetDDNSConfig(config *models.DDNSConfig) (*protocol.DDNSConfigData, error)
GetDDNSConfig 将数据库配置转换为协议配置(下发给客户端)
func (*DDNSService) HandleIPReport ¶
func (s *DDNSService) HandleIPReport(ctx context.Context, agentID string, ipData *protocol.DDNSIPReportData) error
HandleIPReport 处理客户端上报的 IP 地址
func (*DDNSService) ListConfigsByAgentID ¶
func (s *DDNSService) ListConfigsByAgentID(ctx context.Context, agentID string) ([]models.DDNSConfig, error)
ListConfigsByAgentID 列出探针的所有 DDNS 配置
func (*DDNSService) ListRecords ¶
func (s *DDNSService) ListRecords(ctx context.Context, configID string, limit int) ([]models.DDNSRecord, error)
ListRecords 列出 DDNS 更新记录
func (*DDNSService) ListRecordsByAgentID ¶
func (s *DDNSService) ListRecordsByAgentID(ctx context.Context, agentID string, limit int) ([]models.DDNSRecord, error)
ListRecordsByAgentID 列出探针的 DDNS 更新记录
func (*DDNSService) TriggerUpdate ¶ added in v0.1.1
func (s *DDNSService) TriggerUpdate(ctx context.Context, configID string) error
TriggerUpdate 手动触发 DDNS 更新 向探针发送配置消息,触发探针立即获取并上报 IP 地址
func (*DDNSService) UpdateConfig ¶
func (s *DDNSService) UpdateConfig(ctx context.Context, config *models.DDNSConfig) error
UpdateConfig 更新 DDNS 配置
func (*DDNSService) UpdateEnabled ¶ added in v0.0.17
type GeoIPService ¶
type GeoIPService struct {
// contains filtered or unexported fields
}
func NewGeoIPService ¶
func (*GeoIPService) LookupIP ¶
func (s *GeoIPService) LookupIP(ip string) string
LookupIP 查询 IP 归属地
type GitHubAccessTokenResponse ¶
type GitHubAccessTokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
}
GitHubAccessTokenResponse GitHub Access Token 响应
type GitHubAuthURL ¶
GitHubAuthURL GitHub 认证 URL 响应
type GitHubOAuthService ¶
type GitHubOAuthService struct {
// contains filtered or unexported fields
}
GitHubOAuthService GitHub OAuth 认证服务
func NewGitHubOAuthService ¶
func NewGitHubOAuthService(logger *zap.Logger, appConfig *config.AppConfig) *GitHubOAuthService
NewGitHubOAuthService 创建 GitHub OAuth 服务
func (*GitHubOAuthService) ExchangeCode ¶
func (s *GitHubOAuthService) ExchangeCode(ctx context.Context, code, state string) (string, string, error)
ExchangeCode 交换授权码获取 access token 和用户信息
func (*GitHubOAuthService) GenerateAuthURL ¶
func (s *GitHubOAuthService) GenerateAuthURL() (string, string, error)
GenerateAuthURL 生成 GitHub 认证 URL
func (*GitHubOAuthService) IsEnabled ¶
func (s *GitHubOAuthService) IsEnabled() bool
IsEnabled 检查 GitHub OAuth 是否启用
type GitHubUserInfo ¶
type GitHubUserInfo struct {
Login string `json:"login"` // GitHub 用户名
Name string `json:"name"` // 显示名称
Email string `json:"email"` // 邮箱
AvatarURL string `json:"avatar_url"` // 头像
}
GitHubUserInfo GitHub 用户信息
type JWTClaims ¶
type JWTClaims struct {
UserID string `json:"userId"`
Username string `json:"username"`
jwt.RegisteredClaims
}
JWTClaims JWT 声明
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
ExpiresAt int64 `json:"expiresAt"`
User *UserInfo `json:"user"`
}
LoginResponse 登录响应
type MetricService ¶
type MetricService struct {
// contains filtered or unexported fields
}
MetricService 指标服务
func NewMetricService ¶
func NewMetricService(logger *zap.Logger, db *gorm.DB, propertyService *PropertyService, trafficService *TrafficService, vmClient *vmclient.VMClient) *MetricService
NewMetricService 创建指标服务
func (*MetricService) CleanAgentFromMonitorCache ¶ added in v0.1.8
func (s *MetricService) CleanAgentFromMonitorCache(agentID string)
CleanAgentFromMonitorCache 从所有监控缓存中移除指定探针的数据
func (*MetricService) CleanAgentMetrics ¶ added in v0.1.8
func (s *MetricService) CleanAgentMetrics(ctx context.Context, agentID string) error
CleanAgentMetrics 清理指定探针的所有指标数据
func (*MetricService) CleanMonitorCache ¶ added in v0.0.19
func (s *MetricService) CleanMonitorCache(ctx context.Context, monitorID string) error
CleanMonitorCache 清理监控任务缓存中不再关联的探针数据
func (*MetricService) CleanOrphanedAgentMetrics ¶ added in v0.1.8
func (s *MetricService) CleanOrphanedAgentMetrics(ctx context.Context) error
CleanOrphanedAgentMetrics 批量清理已删除探针的指标数据
func (*MetricService) DeleteAgentLatestMetricsCache ¶ added in v0.1.8
func (s *MetricService) DeleteAgentLatestMetricsCache(agentID string)
DeleteAgentLatestMetricsCache 删除探针在内存中的最新指标缓存
func (*MetricService) DeleteAgentMetrics ¶
func (s *MetricService) DeleteAgentMetrics(ctx context.Context, agentID string) error
DeleteAgentMetrics 删除探针在 VictoriaMetrics 中的历史指标
func (*MetricService) DeleteMonitorMetrics ¶ added in v0.1.7
func (s *MetricService) DeleteMonitorMetrics(ctx context.Context, monitorID string) error
DeleteMonitorMetrics 删除服务监控在 VictoriaMetrics 中的历史指标
func (*MetricService) GetAvailableNetworkInterfaces ¶
func (s *MetricService) GetAvailableNetworkInterfaces(ctx context.Context, agentID string) ([]string, error)
GetAvailableNetworkInterfaces 获取探针的可用网卡列表(从 VictoriaMetrics 查询)
func (*MetricService) GetLatestMetrics ¶
func (s *MetricService) GetLatestMetrics(agentID string) (*metric.LatestMetrics, bool)
GetLatestMetrics 获取最新指标的快照 返回值是缓存项的浅拷贝(无互斥量),调用方可以安全 marshal 或在副本上 sanitize 字段, 不会与上报路径产生 data race。
func (*MetricService) GetMetrics ¶
func (s *MetricService) GetMetrics(ctx context.Context, agentID, metricType string, start, end int64, interfaceName string, aggregation string) (*metric.GetMetricsResponse, error)
GetMetrics 获取聚合指标数据(从 VictoriaMetrics 查询) 返回统一的 GetMetricsResponse 格式
func (*MetricService) GetMonitorAgentStats ¶
func (s *MetricService) GetMonitorAgentStats(ctx context.Context, monitorID string) []protocol.MonitorData
GetMonitorAgentStats 获取监控任务各探针的统计数据(只从缓存读取)
func (*MetricService) GetMonitorHistory ¶
func (s *MetricService) GetMonitorHistory(ctx context.Context, monitorID string, start, end int64, aggregation string) (*metric.GetMetricsResponse, error)
GetMonitorHistory 获取监控任务的历史趋势数据
func (*MetricService) GetMonitorStats ¶
func (s *MetricService) GetMonitorStats(ctx context.Context, monitorID string) *metric.MonitorStatsResult
GetMonitorStats 获取监控任务的聚合统计数据(只从缓存读取)
func (*MetricService) HandleMetricData ¶
func (s *MetricService) HandleMetricData(ctx context.Context, agentID string, metricType string, data json.RawMessage, timestamp int64) error
HandleMetricData 处理指标数据
并发:每次调用都会刷新 latestCache 的 TTL(defer Set),且对 latestMetrics 字段的写入 走 Update 在写锁内 commit;读者侧 GetLatestMetrics 通过 Snapshot 取读锁拷贝,避免与 json.Marshal 之间的 data race。
时间戳:sample.Timestamp(agent 端 wall clock)只用于写入 VictoriaMetrics 的样本时间, LatestMetrics.Timestamp 改用服务端 time.Now()(单调推进),避免 agent NTP 倒拨导致 前端 useLiveBuffer 的去重逻辑永久冻结。
type MonitorScheduler ¶
type MonitorScheduler interface {
AddTask(monitorID string, interval int) error
UpdateTask(monitorID string, interval int) error
RemoveTask(monitorID string)
}
MonitorScheduler 调度器接口(避免循环依赖)
type MonitorService ¶
type MonitorService struct {
*repo.MonitorRepo
*orz.Service
// contains filtered or unexported fields
}
func NewMonitorService ¶
func NewMonitorService(logger *zap.Logger, db *gorm.DB, metricService *MetricService, wsManager *ws.Manager) *MonitorService
func (*MonitorService) CreateMonitor ¶
func (s *MonitorService) CreateMonitor(ctx context.Context, req *MonitorTaskRequest) (*models.MonitorTask, error)
func (*MonitorService) DeleteMonitor ¶
func (s *MonitorService) DeleteMonitor(ctx context.Context, id string) error
func (*MonitorService) GetAllLatestMonitorMetrics ¶
func (s *MonitorService) GetAllLatestMonitorMetrics(ctx context.Context) ([]protocol.MonitorData, error)
GetAllLatestMonitorMetrics 获取所有最新监控指标(用于告警检查)
func (*MonitorService) GetLatestMonitorMetricsByType ¶
func (s *MonitorService) GetLatestMonitorMetricsByType(ctx context.Context, monitorType string) ([]protocol.MonitorData, error)
GetLatestMonitorMetricsByType 获取指定类型的最新监控指标(用于告警检查)
func (*MonitorService) GetMonitorByAuth ¶
func (s *MonitorService) GetMonitorByAuth(ctx context.Context, id string, isAuthenticated bool) (*models.MonitorTask, error)
GetMonitorByAuth 根据认证状态获取监控任务(已登录返回全部,未登录返回公开可见)
func (*MonitorService) GetMonitorStatsByID ¶
func (s *MonitorService) GetMonitorStatsByID(ctx context.Context, monitorID string) (*metric.PublicMonitorOverview, error)
GetMonitorStatsByID 获取监控任务的统计数据(聚合后的单个监控详情)
func (*MonitorService) ListByAuth ¶
func (s *MonitorService) ListByAuth(ctx context.Context, isAuthenticated bool) ([]metric.PublicMonitorOverview, error)
ListByAuth 返回公开展示所需的监控配置和汇总统计
func (*MonitorService) SendMonitorTaskToAgents ¶
func (s *MonitorService) SendMonitorTaskToAgents(ctx context.Context, monitor models.MonitorTask) error
SendMonitorTaskToAgents 向指定探针发送单个监控任务(公开方法)
func (*MonitorService) SetScheduler ¶
func (s *MonitorService) SetScheduler(scheduler MonitorScheduler)
SetScheduler 设置调度器(由外部注入,避免循环依赖)
func (*MonitorService) UpdateMonitor ¶
func (s *MonitorService) UpdateMonitor(ctx context.Context, id string, req *MonitorTaskRequest) (*models.MonitorTask, error)
type MonitorTaskRequest ¶
type MonitorTaskRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Target string `json:"target"`
Description string `json:"description"`
Enabled bool `json:"enabled,omitempty"`
ShowTargetPublic bool `json:"showTargetPublic,omitempty"` // 在公开页面是否显示目标地址
Visibility string `json:"visibility,omitempty"` // 可见性: public-匿名可见, private-登录可见
Interval int `json:"interval"` // 检测频率(秒)
HTTPConfig protocol.HTTPMonitorConfig `json:"httpConfig,omitempty"`
TCPConfig protocol.TCPMonitorConfig `json:"tcpConfig,omitempty"`
ICMPConfig protocol.ICMPMonitorConfig `json:"icmpConfig,omitempty"`
AgentIds []string `json:"agentIds,omitempty"`
}
type NotificationQueue ¶ added in v0.1.8
type NotificationQueue struct {
// contains filtered or unexported fields
}
func NewNotificationQueue ¶ added in v0.1.8
func NewNotificationQueue(db *gorm.DB, alertService *AlertService, alertRecordRepo *repo.AlertRecordRepo, logger *zap.Logger) *NotificationQueue
func (*NotificationQueue) Enqueue ¶ added in v0.1.8
func (q *NotificationQueue) Enqueue(recordID int64, agent *models.Agent) error
func (*NotificationQueue) GetActiveWorkers ¶ added in v0.1.8
func (q *NotificationQueue) GetActiveWorkers() int
func (*NotificationQueue) GetQueueLength ¶ added in v0.1.8
func (q *NotificationQueue) GetQueueLength() int
func (*NotificationQueue) Shutdown ¶ added in v0.1.8
func (q *NotificationQueue) Shutdown()
func (*NotificationQueue) Start ¶ added in v0.1.8
func (q *NotificationQueue) Start()
type NotificationService ¶ added in v0.1.1
type NotificationService struct {
// contains filtered or unexported fields
}
NotificationService 统一通知发送入口
func NewNotificationService ¶ added in v0.1.1
func NewNotificationService(logger *zap.Logger, propertyService *PropertyService, notifier *Notifier) *NotificationService
func (*NotificationService) IsMaskIPEnabled ¶ added in v0.1.1
func (s *NotificationService) IsMaskIPEnabled(ctx context.Context) (bool, error)
func (*NotificationService) SendAlertNotification ¶ added in v0.1.1
func (s *NotificationService) SendAlertNotification(ctx context.Context, notificationType string, record *models.AlertRecord, agent *models.Agent) error
SendAlertNotification 根据配置发送通知
type NotificationTask ¶ added in v0.1.8
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier 告警通知服务
func NewNotifier ¶
func (*Notifier) SendDingTalkByConfig ¶
func (n *Notifier) SendDingTalkByConfig(ctx context.Context, config map[string]interface{}, message string) error
SendDingTalkByConfig 导出方法供外部调用
func (*Notifier) SendEmailByConfig ¶
func (n *Notifier) SendEmailByConfig(ctx context.Context, config map[string]interface{}, message string) error
SendEmailByConfig 导出方法供外部调用
func (*Notifier) SendFeishuByConfig ¶
func (n *Notifier) SendFeishuByConfig(ctx context.Context, config map[string]interface{}, message string) error
SendFeishuByConfig 导出方法供外部调用
func (*Notifier) SendNotificationByConfig ¶
func (n *Notifier) SendNotificationByConfig(ctx context.Context, channelConfig *models.NotificationChannelConfig, record *models.AlertRecord, agent *models.Agent, maskIP bool) error
SendNotificationByConfig 根据新的配置结构发送通知
func (*Notifier) SendNotificationByConfigs ¶
func (n *Notifier) SendNotificationByConfigs(ctx context.Context, channelConfigs []models.NotificationChannelConfig, record *models.AlertRecord, agent *models.Agent, maskIP bool) error
SendNotificationByConfigs 根据新的配置结构向多个渠道发送通知
func (*Notifier) SendTelegramByConfig ¶
func (n *Notifier) SendTelegramByConfig(ctx context.Context, config map[string]interface{}, message string) error
SendTelegramByConfig 导出方法供外部调用
func (*Notifier) SendTestNotification ¶
func (n *Notifier) SendTestNotification(ctx context.Context, channelType string, config map[string]interface{}, message string) error
SendTestNotification 发送测试通知(动态匹配通知渠道类型)
func (*Notifier) SendWeComAppByConfig ¶ added in v0.0.19
func (n *Notifier) SendWeComAppByConfig(ctx context.Context, config map[string]interface{}, message string) error
SendWeComAppByConfig 导出方法供外部调用
type OIDCAuthURL ¶
OIDCAuthURL OIDC 认证 URL 响应
type OIDCService ¶
type OIDCService struct {
// contains filtered or unexported fields
}
OIDCService OIDC 认证服务
func NewOIDCService ¶
func NewOIDCService(logger *zap.Logger, appConfig *config.AppConfig) *OIDCService
NewOIDCService 创建 OIDC 服务
func (*OIDCService) ExchangeCode ¶
ExchangeCode 交换授权码获取 token 和用户信息
func (*OIDCService) GenerateAuthURL ¶
func (s *OIDCService) GenerateAuthURL() (string, string, error)
GenerateAuthURL 生成认证 URL
type PropertyService ¶
type PropertyService struct {
// contains filtered or unexported fields
}
func NewPropertyService ¶
func NewPropertyService(logger *zap.Logger, db *gorm.DB) *PropertyService
func (*PropertyService) DeleteDNSProvider ¶
func (s *PropertyService) DeleteDNSProvider(ctx context.Context, providerType string) error
DeleteDNSProvider 删除指定类型的 DNS 服务商配置
func (*PropertyService) GetAgentInstallConfig ¶ added in v0.1.5
func (s *PropertyService) GetAgentInstallConfig(ctx context.Context) (*models.AgentInstallConfig, error)
GetAgentInstallConfig 获取探针安装配置
func (*PropertyService) GetAlertConfig ¶
func (s *PropertyService) GetAlertConfig(ctx context.Context) (*models.AlertConfig, error)
GetAlertConfig 获取告警配置
func (*PropertyService) GetDNSProviderByType ¶
func (s *PropertyService) GetDNSProviderByType(ctx context.Context, providerType string) (*models.DNSProviderConfig, error)
GetDNSProviderByType 根据 Provider 类型获取单个配置
func (*PropertyService) GetDNSProviderConfigs ¶
func (s *PropertyService) GetDNSProviderConfigs(ctx context.Context) ([]models.DNSProviderConfig, error)
GetDNSProviderConfigs 获取 DNS 服务商配置列表
func (*PropertyService) GetNotificationChannelConfigs ¶
func (s *PropertyService) GetNotificationChannelConfigs(ctx context.Context) ([]models.NotificationChannelConfig, error)
func (*PropertyService) GetPublicIPConfig ¶ added in v0.1.2
func (s *PropertyService) GetPublicIPConfig(ctx context.Context) (*models.PublicIPConfig, error)
GetPublicIPConfig 获取公网 IP 采集配置
func (*PropertyService) GetSystemConfig ¶
func (s *PropertyService) GetSystemConfig(ctx context.Context) (*models.SystemConfig, error)
func (*PropertyService) GetSystemVersion ¶ added in v0.1.1
func (s *PropertyService) GetSystemVersion(ctx context.Context) (string, error)
func (*PropertyService) GetValue ¶
func (s *PropertyService) GetValue(ctx context.Context, id string, target interface{}) error
GetValue 获取属性值并反序列化
func (*PropertyService) InitializeDefaultConfigs ¶
func (s *PropertyService) InitializeDefaultConfigs(ctx context.Context) error
InitializeDefaultConfigs 初始化默认配置(如果数据库中不存在)
func (*PropertyService) SetAgentInstallConfig ¶ added in v0.1.5
func (s *PropertyService) SetAgentInstallConfig(ctx context.Context, config models.AgentInstallConfig) error
SetAgentInstallConfig 设置探针安装配置
func (*PropertyService) SetAlertConfig ¶
func (s *PropertyService) SetAlertConfig(ctx context.Context, config models.AlertConfig) error
SetAlertConfig 设置告警配置
func (*PropertyService) SetDNSProviderConfigs ¶
func (s *PropertyService) SetDNSProviderConfigs(ctx context.Context, providers []models.DNSProviderConfig) error
SetDNSProviderConfigs 设置 DNS 服务商配置列表
func (*PropertyService) SetSystemVersion ¶ added in v0.1.1
func (s *PropertyService) SetSystemVersion(ctx context.Context, systemVersion string) error
func (*PropertyService) UpsertDNSProvider ¶
func (s *PropertyService) UpsertDNSProvider(ctx context.Context, newProvider models.DNSProviderConfig) error
UpsertDNSProvider 创建或更新单个 DNS 服务商配置(每种类型只允许一个)
type PublicIPService ¶ added in v0.1.2
type PublicIPService struct {
// contains filtered or unexported fields
}
func NewPublicIPService ¶ added in v0.1.2
func NewPublicIPService(logger *zap.Logger, propertyService *PropertyService, wsManager *websocket.Manager) *PublicIPService
func (*PublicIPService) Run ¶ added in v0.1.2
func (s *PublicIPService) Run(ctx context.Context)
Run 启动公网 IP 采集调度
type SSHLoginService ¶ added in v0.1.1
type SSHLoginService struct {
SSHLoginEventRepo *repo.SSHLoginEventRepo
// contains filtered or unexported fields
}
SSHLoginService SSH登录服务
func NewSSHLoginService ¶ added in v0.1.1
func NewSSHLoginService(logger *zap.Logger, db *gorm.DB, wsManager *websocket.Manager, geoIPSvc *GeoIPService, notificationSvc *NotificationService) *SSHLoginService
NewSSHLoginService 创建服务
func (*SSHLoginService) DeleteEventsByAgentID ¶ added in v0.1.1
func (s *SSHLoginService) DeleteEventsByAgentID(ctx context.Context, agentID string) error
DeleteEventsByAgentID 删除探针的所有事件
func (*SSHLoginService) GetConfig ¶ added in v0.1.1
func (s *SSHLoginService) GetConfig(ctx context.Context, agentID string) (*models.SSHLoginConfigData, error)
GetConfig 获取探针的配置
func (*SSHLoginService) HandleConfigResult ¶ added in v0.1.1
func (s *SSHLoginService) HandleConfigResult(ctx context.Context, agentID string, result protocol.SSHLoginConfigResult) error
HandleConfigResult 处理 Agent 上报的配置应用结果
func (*SSHLoginService) HandleEvent ¶ added in v0.1.1
func (s *SSHLoginService) HandleEvent(ctx context.Context, agentID string, eventData protocol.SSHLoginEvent) error
HandleEvent 处理 Agent 上报的事件
func (*SSHLoginService) UpdateConfig ¶ added in v0.1.1
func (s *SSHLoginService) UpdateConfig(ctx context.Context, agentID string, req *models.SSHLoginConfigData) error
UpdateConfig 更新配置并下发到 Agent 返回: config - 配置对象, error - 错误信息
type TamperService ¶
type TamperService struct {
TamperEventRepo *repo.TamperEventRepo
// contains filtered or unexported fields
}
func NewTamperService ¶
func NewTamperService(logger *zap.Logger, db *gorm.DB, wsManager *websocket.Manager, notificationSvc *NotificationService) *TamperService
func (*TamperService) BuildInitialConfig ¶ added in v0.1.1
func (s *TamperService) BuildInitialConfig(ctx context.Context, agentID string) (added, removed []string, err error)
BuildInitialConfig 构建探针初始化时的配置(用于探针连接时) 根据 enabled 状态决定发送的内容: - enabled=true: 发送所有配置的路径作为新增 - enabled=false: 发送空配置
func (*TamperService) CreateEvent ¶
func (s *TamperService) CreateEvent(ctx context.Context, agentID string, eventData *protocol.TamperEventData) error
CreateEvent 创建防篡改事件
func (*TamperService) DeleteEventsByAgentID ¶ added in v0.1.1
func (s *TamperService) DeleteEventsByAgentID(ctx context.Context, id string) error
func (*TamperService) GetConfigByAgentID ¶
func (s *TamperService) GetConfigByAgentID(ctx context.Context, agentID string) (*models.TamperProtectConfigData, error)
GetConfigByAgentID 获取探针的防篡改配置
func (*TamperService) HandleConfigResult ¶ added in v0.1.1
func (s *TamperService) HandleConfigResult(ctx context.Context, agentID string, resp protocol.TamperProtectResponse) error
func (*TamperService) UpdateConfig ¶
func (s *TamperService) UpdateConfig(ctx context.Context, agentID string, req *models.TamperProtectConfigData) error
UpdateConfig 更新探针的防篡改配置
func (*TamperService) UpdateConfigByAgentID ¶ added in v0.1.1
func (s *TamperService) UpdateConfigByAgentID(ctx context.Context, agentID string, config *models.TamperProtectConfigData) error
type TrafficAlerts ¶
type TrafficAlerts struct {
Sent80 bool `json:"sent80"`
Sent90 bool `json:"sent90"`
Sent100 bool `json:"sent100"`
}
TrafficAlerts 流量告警状态
type TrafficService ¶
type TrafficService struct {
// contains filtered or unexported fields
}
func NewTrafficService ¶
func NewTrafficService(logger *zap.Logger, db *gorm.DB, notificationService *NotificationService) *TrafficService
func (*TrafficService) CheckAndResetTraffic ¶ added in v0.1.1
func (s *TrafficService) CheckAndResetTraffic(ctx context.Context) error
CheckAndResetTraffic 检查并重置所有到期的探针流量(定时任务调用)
func (*TrafficService) GetTrafficStats ¶ added in v0.1.1
func (s *TrafficService) GetTrafficStats(ctx context.Context, agentID string) (*TrafficStats, error)
GetTrafficStats 获取流量统计信息
func (*TrafficService) ResetAgentTraffic ¶ added in v0.1.1
func (s *TrafficService) ResetAgentTraffic(ctx context.Context, agentID string) error
ResetAgentTraffic 重置探针流量
func (*TrafficService) UpdateAgentTraffic ¶
func (s *TrafficService) UpdateAgentTraffic(ctx context.Context, agentID string, currentRecvTotal, currentSentTotal uint64) error
UpdateAgentTraffic 更新探针流量统计(每次上报网络指标时调用)
type TrafficStats ¶
type TrafficStats struct {
Enabled bool `json:"enabled"`
Type string `json:"type"` // 统计类型: recv/send/both
Limit uint64 `json:"limit"`
Used uint64 `json:"used"`
UsedPercent float64 `json:"usedPercent"`
Remaining uint64 `json:"remaining"`
ResetDay int `json:"resetDay"`
PeriodStart int64 `json:"periodStart"`
PeriodEnd int64 `json:"periodEnd"`
DaysUntilReset int `json:"daysUntilReset"`
Alerts TrafficAlerts `json:"alerts"`
}
TrafficStats 流量统计信息
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService User 认证服务
func NewUserService ¶
func NewUserService(logger *zap.Logger, appConfig *config.AppConfig) *UserService
NewUserService 创建 User 服务
func (*UserService) GetUsername ¶
GetUsername 获取用户名(如果认证成功)
func (*UserService) ValidateCredentials ¶
func (s *UserService) ValidateCredentials(ctx context.Context, username, password string) error
ValidateCredentials 验证用户名和密码
Source Files
¶
- account_service.go
- agent_service.go
- alert_service.go
- api_key_service.go
- ddns_service.go
- geoip_service.go
- github_oauth_service.go
- metric_converter.go
- metric_service.go
- monitor_service.go
- notification_queue.go
- notification_service.go
- notifier.go
- oidc_service.go
- property_service.go
- public_ip_service.go
- ssh_login_service.go
- tamper_service.go
- traffic_service.go
- user_service.go