[ Server ] [ Server ] - 增加服务器角色部分的内容
This commit is contained in:
@@ -67,9 +67,9 @@ func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
resultLog = append(resultLog, "↓↓↓ 命令 Error 如下 ↓↓↓", err.Error())
|
||||
}
|
||||
|
||||
// debug
|
||||
commandResult := fmt.Sprintf("Excution Comand are=> %v, Executor Result: %v", realCommand, resultLog)
|
||||
|
||||
log.Info(commandResult)
|
||||
log.Debug(commandResult)
|
||||
|
||||
return resultLog, err
|
||||
}
|
||||
@@ -119,12 +119,10 @@ func MultiLineCommandExecutor(multiLineCommandExecutor [][]string) ([]string, er
|
||||
for _, singleLineCommand := range multiLineCommandExecutor {
|
||||
singleLogs, err := AllOutputCommandExecutor(singleLineCommand)
|
||||
res = append(res, singleLogs...)
|
||||
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Execution error ! command is %v, error is %v", singleLineCommand, err))
|
||||
return res, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
user32DLL = syscall.NewLazyDLL("user32.dll")
|
||||
user32DLL = syscall.NewLazyDLL("user32.dll")
|
||||
|
||||
messageBox = user32DLL.NewProc("MessageBoxW")
|
||||
)
|
||||
|
||||
@@ -24,6 +25,8 @@ func FindPublicIpAddress() {
|
||||
|
||||
ip := strings.TrimSpace(string(output))
|
||||
fmt.Println("公网IP地址:", ip)
|
||||
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func CallAgent() {
|
||||
@@ -46,4 +49,5 @@ func CallAgent() {
|
||||
}
|
||||
|
||||
fmt.Println("MessageBox returned:", ret)
|
||||
|
||||
}
|
||||
|
||||
@@ -117,8 +117,10 @@ func agentOMHandler(octopusMessage *OctopusMessage) {
|
||||
|
||||
func executorOMHandler(octopusMessage *OctopusMessage) {
|
||||
|
||||
// 转换类型
|
||||
executionMsgString := octopusMessage.Content.(string)
|
||||
|
||||
// 解析 ExecutionMessage
|
||||
var executionMessage *executor.ExecutionMessage
|
||||
err := json.Unmarshal([]byte(executionMsgString), &executionMessage)
|
||||
if err != nil {
|
||||
@@ -126,7 +128,7 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
// 交给后端的实际处理器处理, 再次策略
|
||||
// 执行命令
|
||||
resultLog, err := executor.Execute(executionMessage)
|
||||
if err == nil {
|
||||
octopusMessage.ResultCode = "200"
|
||||
@@ -134,15 +136,15 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
||||
octopusMessage.ResultCode = "300"
|
||||
}
|
||||
|
||||
// 消息返回逻辑
|
||||
// 返回结果
|
||||
if executionMessage.NeedResultReplay {
|
||||
// send back the result log
|
||||
octopusMessage.Result = resultLog
|
||||
}
|
||||
|
||||
// 返回时间
|
||||
octopusMessage.ACTime = utils.ParseDateTimeTime()
|
||||
|
||||
// Send
|
||||
// 返回结果
|
||||
octopusMessage.SendToOctopusServer()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user