1.4.5.2
This commit is contained in:
15
EdgeCommon/pkg/reporterconfigs/global_setting.go
Normal file
15
EdgeCommon/pkg/reporterconfigs/global_setting.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package reporterconfigs
|
||||
|
||||
// GlobalSetting 全局设置
|
||||
type GlobalSetting struct {
|
||||
MinNotifyConnectivity float64 `json:"minNotifyConnectivity"` // 需要通知的最小连通值
|
||||
NotifyWebHookURL string `json:"notifyWebHookURL"` // WebHook通知地址
|
||||
}
|
||||
|
||||
func DefaultGlobalSetting() *GlobalSetting {
|
||||
return &GlobalSetting{
|
||||
MinNotifyConnectivity: 100,
|
||||
}
|
||||
}
|
||||
23
EdgeCommon/pkg/reporterconfigs/messages.go
Normal file
23
EdgeCommon/pkg/reporterconfigs/messages.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package reporterconfigs
|
||||
|
||||
type MessageCode = string
|
||||
|
||||
// 节点相关消息
|
||||
const (
|
||||
MessageCodeConnectedAPINode MessageCode = "connectedAPINode" // 节点连接API节点成功
|
||||
MessageCodeCheckSystemdService MessageCode = "checkSystemdService" // 检查Systemd服务
|
||||
MessageCodeNewNodeTask MessageCode = "newNodeTask" // 有新的节点任务产生
|
||||
)
|
||||
|
||||
// ConnectedAPINodeMessage 连接API节点成功
|
||||
type ConnectedAPINodeMessage struct {
|
||||
APINodeId int64 `json:"apiNodeId"`
|
||||
}
|
||||
|
||||
// CheckSystemdServiceMessage Systemd服务
|
||||
type CheckSystemdServiceMessage struct {
|
||||
}
|
||||
|
||||
// NewNodeTaskMessage 有新的节点任务
|
||||
type NewNodeTaskMessage struct {
|
||||
}
|
||||
11
EdgeCommon/pkg/reporterconfigs/node_config.go
Normal file
11
EdgeCommon/pkg/reporterconfigs/node_config.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package reporterconfigs
|
||||
|
||||
type NodeConfig struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
func (this *NodeConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
46
EdgeCommon/pkg/reporterconfigs/report_levels.go
Normal file
46
EdgeCommon/pkg/reporterconfigs/report_levels.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package reporterconfigs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
)
|
||||
|
||||
type ReportLevel = string
|
||||
|
||||
const (
|
||||
ReportLevelGood ReportLevel = "good"
|
||||
ReportLevelNormal ReportLevel = "normal"
|
||||
ReportLevelBad ReportLevel = "bad"
|
||||
ReportLevelBroken ReportLevel = "broken"
|
||||
)
|
||||
|
||||
func FindAllReportLevels() []*shared.Definition {
|
||||
return []*shared.Definition{
|
||||
{
|
||||
Name: "良好",
|
||||
Code: ReportLevelGood,
|
||||
},
|
||||
{
|
||||
Name: "正常",
|
||||
Code: ReportLevelNormal,
|
||||
},
|
||||
{
|
||||
Name: "不良",
|
||||
Code: ReportLevelBad,
|
||||
},
|
||||
{
|
||||
Name: "错误",
|
||||
Code: ReportLevelBroken,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func FindReportLevelName(level ReportLevel) string {
|
||||
for _, def := range FindAllReportLevels() {
|
||||
if def.Code == level {
|
||||
return def.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
16
EdgeCommon/pkg/reporterconfigs/status.go
Normal file
16
EdgeCommon/pkg/reporterconfigs/status.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package reporterconfigs
|
||||
|
||||
type Status struct {
|
||||
IP string `json:"ip"`
|
||||
OS string `json:"os"`
|
||||
OSName string `json:"osName"`
|
||||
Username string `json:"username"`
|
||||
BuildVersion string `json:"buildVersion"` // 编译版本
|
||||
BuildVersionCode uint32 `json:"buildVersionCode"` // 版本数字
|
||||
UpdatedAt int64 `json:"updatedAt"` // 更新时间
|
||||
|
||||
Location string `json:"location"` // 从IP查询到的Location
|
||||
ISP string `json:"isp"` // 从IP查询到的ISP
|
||||
}
|
||||
23
EdgeCommon/pkg/reporterconfigs/tasks.go
Normal file
23
EdgeCommon/pkg/reporterconfigs/tasks.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package reporterconfigs
|
||||
|
||||
type TaskType = string
|
||||
|
||||
const (
|
||||
TaskTypeIPAddr TaskType = "ipAddr"
|
||||
)
|
||||
|
||||
type IPTask struct {
|
||||
AddrId int64 `json:"addrId"`
|
||||
IP string `json:"ip"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
func FindTaskTypeName(taskType TaskType) string {
|
||||
switch taskType {
|
||||
case TaskTypeIPAddr:
|
||||
return "IP地址"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user