Agent: Reimplement HTTPIslandAPIClient.send_log() as member, not static

This commit is contained in:
Mike Salvatore 2022-09-19 19:44:16 -04:00
parent aba342b3f2
commit 92da3b78db
2 changed files with 6 additions and 5 deletions

View File

@ -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}")

View File

@ -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,
)