[docs]classTuoniListener:""" A class that provides data and functionality for a created listener. Attributes: listener_id (int): The unique identifier of the listener. name (str): The name of the listener. info (str): Information about the listener. status (str): The current status of the listener. plugin (str): The plugin associated with the listener. configuration (dict): The configuration settings for the listener. """def__init__(self,conf,c2):""" Constructor for the listener class. Args: conf (dict): Data from the server. c2 (TuoniC2): The related server object that manages communication. """self._load_conf(conf)self.c2=c2def_load_conf(self,conf):self.listener_id=conf["id"]self.name=conf["name"]self.info=conf["info"]self.status=conf["status"]self.plugin=conf["plugin"]self.configuration=conf["configuration"]
[docs]defstop(self):""" Stop the listener. """ifself.listener_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_put("/api/v1/listeners/%s/stop"%self.listener_id)self._load_conf(data)
[docs]defstart(self):""" Start the listener. """ifself.listener_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_put("/api/v1/listeners/%d/start"%self.listener_id)self._load_conf(data)
[docs]defdelete(self):""" Delete the listener. """ifself.listener_idisNone:raiseExceptionTuoniDeleted("")self.c2.request_delete("/api/v1/listeners/%d"%self.listener_id)self.listener_id=None