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:
2025-10-09 09:36:48 -04:00
parent 6e4e35fa34
commit b74f77a9db
16 changed files with 503 additions and 332 deletions
+18 -7
View File
@@ -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