-
Notifications
You must be signed in to change notification settings - Fork 42
/
strings.go
130 lines (105 loc) · 4.17 KB
/
strings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package spec
import (
"fmt"
"strings"
"time"
)
var (
LocalTimeLocation *time.Location
)
func init() {
var err error
LocalTimeLocation, err = time.LoadLocation("Asia/Shanghai")
if err != nil {
//log.Infof("load localtime failed: %s", err)
}
}
type ServerPushKey string
const (
// 服务器的节点 ID 常量
ServerNodeId = "palm-server"
LogAgentNodeId = "log-agent"
// RPC Exchange 一定是 Direct
CommonRPCExchange = "palm-rpc"
// 服务器推送数据的交换机
CommonServerPushExchange = "palm-push"
CommonServerPushDefaultKey = "palm.nodebase.notification"
// 服务器推送数据到交换机的 Key
ServerPush_ScriptTask ServerPushKey = "script-task"
ScanPortExchange = "palm-scan-port-task"
ScanFingerprintExchange = ScanPortExchange
// scan port
CommonScanPortQueue = "palm-scan-port"
CommonScanPortTaskKey = "palm.stream.task.scan-port"
CommonScanPortResultKey = "palm.stream.result.scan-port"
CommonScanFingerprintQueue = "palm-scan-fingerprint"
CommonScanFingerprintTaskKey = "palm.stream.task.scan-fingerprint"
CommonScanFingerprintResultKey = "palm.stream.result.scan-fingerprint"
API_RegisterNode = "register-palm-node"
API_UnregisterNode = "unregister-palm-node"
BackendKey_HTTPFlow = "http-flow"
BackendKey_Scanner = "scanner"
BackendKey_ProcessInfo = "process"
BackendKey_ProcessEvent = "process-event"
BackendKey_ConnectionEvent = "connection-event"
BackendKey_NetConnectInfo = "netconnect"
BackendKey_Nginx = "nginx"
BackendKey_Apache = "apache"
BackendKey_FileChangeInfo = "filechange"
BackendKey_SystemMatrix = "heartbeat"
BackendKey_SSHInfo = "sshinfo"
BackendKey_RequestConfig = "request_config"
BackendKey_ReportHostUser = "report_host_user"
BackendKey_ReportAllUserLoginOk = "report_all_user_login_ok"
BackendKey_ReportAllUserLoginFail = "report_all_user_login_fail"
BackendKey_ReportAllUserLoginFailFileTooLarge = "report_all_user_login_fail_file_too_large"
BackendKey_Heartbeat = BackendKey_SystemMatrix
BackendKey_UserLoginAttempt = "user_login_attempt"
BackendKey_SoftwareVersion = "software_version"
BackendKey_BootSoftware = "boot_software"
BackendKey_Crontab = "crontab"
BackendKey_ReverseShell = "reverse_shell"
BackendKey_NodeLog = "node_log"
HIDS_API_Sleep = "hids-rpc-sleep"
)
var (
HIDS_APIs = []string{
HIDS_API_Sleep,
}
)
func GetScriptRuntimeMessageKey(nodeId, taskId string) string {
return fmt.Sprintf("palm.nodebase.script.%v.%v", nodeId, taskId)
}
func GetNodeBaseNotificationQueueByNodeId(id string) string {
return fmt.Sprintf("queue.notify-from-server.%v", id)
}
// 用于接收针对节点的服务器端通知
func GetNodeBaseNotificationRoutingKeyByNodeId(id string) string {
return fmt.Sprintf("palm.nodebase.notification.%v.#", id)
}
// 用于发送针对节点的服务器端通知
func GetServerPushKey(nodeId string, key ServerPushKey) string {
return GetNodeBaseNotificationPushRoutingKeyByNodeId(nodeId, string(key))
}
func ParseServerPushKey(r string) string {
rets := strings.Split(r, ".")
if len(rets) >= 5 {
return rets[4]
}
return ""
}
func GetNodeBaseNotificationPushRoutingKeyByNodeId(nodeId string, key string) string {
return fmt.Sprintf("palm.nodebase.notification.%v.%v", nodeId, key)
}
func GetScanPortQueueNameByNodeId(nodeId string) string {
return fmt.Sprintf("queue.scan-port-task.%v", nodeId)
}
func GetScanPortRoutingKeyByNodeId(nodeId string) string {
return fmt.Sprintf("palm.stream.task.scan-port.%v", nodeId)
}
func GetScanFingerprintQueueNameByNodeId(nodeId string) string {
return fmt.Sprintf("queue.scan-fingerprint-task.%v", nodeId)
}
func GetScanFingerprintRoutingKeyByNodeId(nodeId string) string {
return fmt.Sprintf("palm.stream.task.scan-fingerprint.%v", nodeId)
}