Prevent database locking by not updating latest checkin in database and instead storing it only in memory
This commit is contained in:
@@ -30,6 +30,7 @@ proc agentList*(cq: Conquest, listener: string) =
|
||||
# If no argument is passed via -n, list all agents, otherwise only display agents connected to a specific listener
|
||||
if listener == "":
|
||||
cq.drawTable(cq.dbGetAllAgents())
|
||||
|
||||
else:
|
||||
# Check if listener exists
|
||||
if not cq.dbListenerExists(listener.toUpperAscii):
|
||||
@@ -38,6 +39,7 @@ proc agentList*(cq: Conquest, listener: string) =
|
||||
|
||||
cq.drawTable(cq.dbGetAllAgentsByListener(listener.toUpperAscii))
|
||||
|
||||
|
||||
# Display agent properties and details
|
||||
proc agentInfo*(cq: Conquest, name: string) =
|
||||
# Check if agent supplied via -n parameter exists in database
|
||||
@@ -202,8 +204,8 @@ proc getTasks*(listener, agent: string): JsonNode =
|
||||
|
||||
# Update the last check-in date for the accessed agent
|
||||
cq.agents[agent.toUpperAscii].latestCheckin = now()
|
||||
if not cq.dbUpdateCheckin(agent.toUpperAscii, now().format("dd-MM-yyyy HH:mm:ss")):
|
||||
return nil
|
||||
# if not cq.dbUpdateCheckin(agent.toUpperAscii, now().format("dd-MM-yyyy HH:mm:ss")):
|
||||
# return nil
|
||||
|
||||
# Return tasks in JSON format
|
||||
return %cq.agents[agent.toUpperAscii].tasks.filterIt(it.status != Completed)
|
||||
|
||||
@@ -4,9 +4,13 @@ import ../../db/database
|
||||
|
||||
proc taskExecuteSleep*(cq: Conquest, delay: int) =
|
||||
|
||||
if delay < 0:
|
||||
cq.writeLine(fgRed, styleBright, "[-] Invalid sleep delay value.")
|
||||
return
|
||||
|
||||
# Update 'sleep' value in database
|
||||
if not cq.dbUpdateSleep(cq.interactAgent.name, delay):
|
||||
return
|
||||
return
|
||||
|
||||
# Create a new task
|
||||
let
|
||||
|
||||
Reference in New Issue
Block a user