Agent: Use `create_daemon_thread` in ExploitClassHTTPServer

This commit is contained in:
Ilija Lazoroski 2022-04-05 12:06:52 +02:00 committed by Mike Salvatore
parent 2aee4c0541
commit 943cb2fa7a
1 changed files with 6 additions and 6 deletions

View File

@ -3,6 +3,8 @@ import logging
import threading import threading
from typing import Type from typing import Type
from infection_monkey.utils.threading import create_daemon_thread
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
HTTP_TOO_MANY_REQUESTS_ERROR_CODE = 429 HTTP_TOO_MANY_REQUESTS_ERROR_CODE = 429
@ -32,12 +34,10 @@ class ExploitClassHTTPServer:
HTTPHandler = _get_new_http_handler_class(java_class, self._class_downloaded) HTTPHandler = _get_new_http_handler_class(java_class, self._class_downloaded)
self._server = http.server.HTTPServer((ip, port), HTTPHandler) self._server = http.server.HTTPServer((ip, port), HTTPHandler)
# Setting `daemon=True` to save ourselves some trouble when this is merged to the self._server_thread = create_daemon_thread(
# agent-refactor branch. target=self._server.serve_forever,
# TODO: Make a call to `create_daemon_thread()` instead of calling the `Thread()` name="ExploitClassHTTPServerThread",
# constructor directly after merging to the agent-refactor branch. args=(self._poll_interval,),
self._server_thread = threading.Thread(
target=self._server.serve_forever, args=(self._poll_interval,), daemon=True
) )
def run(self): def run(self):