Agent: Close inbound tunnel if one was opened

This commit is contained in:
vakaris_zilius 2022-06-22 13:13:32 +00:00
parent 27bff7e41c
commit f0029a0d82
1 changed files with 3 additions and 1 deletions

View File

@ -99,6 +99,7 @@ class InfectionMonkey:
self._telemetry_messenger = LegacyTelemetryMessengerAdapter()
self._current_depth = self._opts.depth
self._master = None
self._inbound_tunnel_opened = False
@staticmethod
def _get_arguments(args):
@ -172,6 +173,7 @@ class InfectionMonkey:
self._control_client.server_address, GUID, self._control_client.proxies
).get_config()
if self._monkey_inbound_tunnel and should_propagate(config, self._current_depth):
self._inbound_tunnel_opened = True
self._monkey_inbound_tunnel.start()
StateTelem(is_done=False, version=get_version()).send()
@ -358,7 +360,7 @@ class InfectionMonkey:
reset_signal_handlers()
if self._monkey_inbound_tunnel:
if self._inbound_tunnel_opened:
self._monkey_inbound_tunnel.stop()
self._monkey_inbound_tunnel.join()