forked from p15670423/monkey
Agent: Fix bugs in control.py
Bugs happened because of incorrect indentation in the recent refactoring attempting to remove worm config dependency
This commit is contained in:
parent
f1bc5f4707
commit
e6e6587f46
|
@ -73,31 +73,28 @@ class ControlClient:
|
||||||
debug_message = "Trying to connect to server: %s" % self.server_address
|
debug_message = "Trying to connect to server: %s" % self.server_address
|
||||||
if self.proxies:
|
if self.proxies:
|
||||||
debug_message += " through proxies: %s" % self.proxies
|
debug_message += " through proxies: %s" % self.proxies
|
||||||
logger.debug(debug_message)
|
logger.debug(debug_message)
|
||||||
requests.get( # noqa: DUO123
|
requests.get( # noqa: DUO123
|
||||||
f"https://{self.server_address}/api?action=is-up",
|
f"https://{self.server_address}/api?action=is-up",
|
||||||
verify=False,
|
verify=False,
|
||||||
proxies=self.proxies,
|
proxies=self.proxies,
|
||||||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
timeout=MEDIUM_REQUEST_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
return True
|
||||||
except ConnectionError as exc:
|
except ConnectionError as exc:
|
||||||
self.server_address = ""
|
|
||||||
logger.warning("Error connecting to control server %s: %s", self.server_address, exc)
|
logger.warning("Error connecting to control server %s: %s", self.server_address, exc)
|
||||||
|
|
||||||
if self.server_address:
|
if self.proxies:
|
||||||
return True
|
return False
|
||||||
else:
|
else:
|
||||||
if self.proxies:
|
logger.info("Starting tunnel lookup...")
|
||||||
return False
|
proxy_find = tunnel.find_tunnel(default=default_tunnel)
|
||||||
|
if proxy_find:
|
||||||
|
self.set_proxies(proxy_find)
|
||||||
|
return self.find_server()
|
||||||
else:
|
else:
|
||||||
logger.info("Starting tunnel lookup...")
|
logger.info("No tunnel found")
|
||||||
proxy_find = tunnel.find_tunnel(default=default_tunnel)
|
return False
|
||||||
if proxy_find:
|
|
||||||
self.set_proxies(proxy_find)
|
|
||||||
return self.find_server()
|
|
||||||
else:
|
|
||||||
logger.info("No tunnel found")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_proxies(self, proxy_find):
|
def set_proxies(self, proxy_find):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue