forked from p15670423/monkey
Agent: Add control channel server property
This commit is contained in:
parent
65bc0efc5a
commit
56f07e0188
|
@ -14,14 +14,15 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ControlChannel(IControlChannel):
|
class ControlChannel(IControlChannel):
|
||||||
|
control_channel_server = WormConfiguration.current_server
|
||||||
|
|
||||||
def should_agent_stop(self) -> bool:
|
def should_agent_stop(self) -> bool:
|
||||||
server = WormConfiguration.current_server
|
if not self.control_channel_server:
|
||||||
if not server:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get( # noqa: DUO123
|
response = requests.get( # noqa: DUO123
|
||||||
f"{server}/api/monkey_control/{GUID}",
|
f"{self.control_channel_server}/api/monkey_control/{GUID}",
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=SHORT_REQUEST_TIMEOUT,
|
timeout=SHORT_REQUEST_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
@ -32,16 +33,16 @@ class ControlChannel(IControlChannel):
|
||||||
logger.error(f"An error occurred while trying to connect to server. {e}")
|
logger.error(f"An error occurred while trying to connect to server. {e}")
|
||||||
|
|
||||||
def get_config(self) -> dict:
|
def get_config(self) -> dict:
|
||||||
return ControlClient.load_control_config()
|
ControlClient.load_control_config()
|
||||||
|
return WormConfiguration.as_dict()
|
||||||
|
|
||||||
def get_credentials_for_propagation(self) -> dict:
|
def get_credentials_for_propagation(self) -> dict:
|
||||||
server = WormConfiguration.current_server
|
if not self.control_channel_server:
|
||||||
if not server:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get( # noqa: DUO123
|
response = requests.get( # noqa: DUO123
|
||||||
f"{server}/api/propagationCredentials",
|
f"{self.control_channel_server}/api/propagationCredentials",
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=SHORT_REQUEST_TIMEOUT,
|
timeout=SHORT_REQUEST_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,13 @@ import abc
|
||||||
|
|
||||||
|
|
||||||
class IControlChannel(metaclass=abc.ABCMeta):
|
class IControlChannel(metaclass=abc.ABCMeta):
|
||||||
|
@property
|
||||||
|
@abc.abstractmethod
|
||||||
|
def control_channel_server(self):
|
||||||
|
"""
|
||||||
|
:return: Worm configuration server
|
||||||
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def should_agent_stop(self) -> bool:
|
def should_agent_stop(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue