Implemented sleep command to update sleep delay on agent

This commit is contained in:
Jakob Friedl
2025-05-28 10:39:30 +02:00
parent c03592c7fd
commit 4397f728de
11 changed files with 80 additions and 36 deletions

View File

@@ -1,11 +1,12 @@
import base64
import base64, strutils
import ./types
import ./commands/commands
proc handleTask*(task: Task): Task =
proc handleTask*(task: Task, config: AgentConfig): Task =
# Handle task command
case task.command:
of ExecuteShell:
let (output, status) = taskShell(task.args)
@@ -20,6 +21,27 @@ proc handleTask*(task: Task): Task =
status: status
)
of Sleep:
# Parse arguments
let delay: int = parseInt(task.args[0])
# Execute task
let (output, status) = taskSleep(delay)
# Update sleep delay in agent config
if status == Completed:
config.sleep = delay
# Return result
return Task(
id: task.id,
agent: task.agent,
command: task.command,
args: task.args,
result: encode(output),
status: status
)
else:
echo "Not implemented"
return nil