diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 82a7250c4..9d7daec6e 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -78,7 +78,7 @@ class ControlClient: return try: telemetry = {"monkey_guid": GUID, "log": json.dumps(log)} - HTTPIslandAPIClient.send_log(self.server_address, json.dumps(telemetry)) + self._island_api_client.send_log(json.dumps(telemetry)) except Exception as exc: logger.warning(f"Error connecting to control server {self.server_address}: {exc}") diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index ceddc7de2..98bca7562 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -38,12 +38,13 @@ class HTTPIslandAPIClient(IIslandAPIClient): timeout=MEDIUM_REQUEST_TIMEOUT, ) - @staticmethod + self._island_server = island_server + @handle_island_errors - def send_log(server_address: str, data: str): + def send_log(self, log_contents: str): requests.post( # noqa: DUO123 - "https://%s/api/log" % (server_address,), - json=data, + f"https://{self._island_server}/api/log", + json=log_contents, verify=False, timeout=MEDIUM_REQUEST_TIMEOUT, )