From 65e28e987bbbc54851ce9a55a3361cfa759cf612 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 15 Apr 2022 08:54:24 -0400 Subject: [PATCH] Agent: Use MEDIUM_REQUEST_TIMEOUT for contacting the island This will drop something like 30 seconds off of our tunneling test. Generally speaking, 5 seconds seems like enough time for a simple HTTP request to make a round trip within a local network. If we see issues in practice, we can make this value configurable at runtime. --- monkey/infection_monkey/control.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 52b8e0db8..54a65d04a 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -22,11 +22,6 @@ logger = logging.getLogger(__name__) PBA_FILE_DOWNLOAD = "https://%s/api/pba/download/%s" -# random number greater than 5, -# to prevent the monkey from just waiting forever to try and connect to an island before going -# elsewhere. -TIMEOUT_IN_SECONDS = 15 - class ControlClient(object): proxies = {} @@ -60,7 +55,7 @@ class ControlClient(object): headers={"content-type": "application/json"}, verify=False, proxies=ControlClient.proxies, - timeout=20, + timeout=MEDIUM_REQUEST_TIMEOUT, ) @staticmethod @@ -86,7 +81,7 @@ class ControlClient(object): f"https://{server}/api?action=is-up", verify=False, proxies=ControlClient.proxies, - timeout=TIMEOUT_IN_SECONDS, + timeout=MEDIUM_REQUEST_TIMEOUT, ) WormConfiguration.current_server = current_server break