Fixed issue with generating multiple OTP - now prints a nice list for Copy/Paste. Began splitting client / server functionality. Demoted selector and setup to util from service. Fixed some typos.
This commit is contained in:
+18
-7
@@ -15,6 +15,8 @@
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import ClassVar, Optional
|
||||
from models.policy import Policy
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -23,7 +25,7 @@ class Agent:
|
||||
clientversion: str
|
||||
domain: str
|
||||
freespace: int
|
||||
groupid: int
|
||||
groupid: str # Changed to str to match UUID-style IDs
|
||||
hostname: str
|
||||
ip: str
|
||||
localip: str
|
||||
@@ -36,14 +38,23 @@ class Agent:
|
||||
status_text: Optional[str] = field(default=None)
|
||||
|
||||
# Class-level status map
|
||||
status_map: ClassVar[dict] = {0: "Offline", 1: "Online", 2: "Hidden", 3: "Safemode"}
|
||||
|
||||
def enrich(self, groupid_to_name: dict):
|
||||
"""Enrich the agent with groupname and human-readable status."""
|
||||
self.groupname = groupid_to_name.get(self.groupid, None)
|
||||
self.status_text = self.status_map.get(self.status, "Unknown")
|
||||
status_map: ClassVar[dict] = {
|
||||
0: "Offline",
|
||||
1: "Online",
|
||||
2: "Hidden",
|
||||
3: "Safemode"
|
||||
}
|
||||
|
||||
|
||||
def enrich_with_policies(self, policies: List[Policy]):
|
||||
"""Enrich the agent with groupname and human-readable status."""
|
||||
self.status_text = self.status_map.get(self.status, "Unknown")
|
||||
for policy in policies:
|
||||
if policy.groupid == self.groupid:
|
||||
self.groupname = policy.name
|
||||
break
|
||||
if not self.groupname:
|
||||
self.groupname = "Unknown"
|
||||
"""
|
||||
|
||||
from models.agent import Agent
|
||||
|
||||
Reference in New Issue
Block a user