diff --git a/infection_monkey/control.py b/infection_monkey/control.py index 8d14766c6..12f0cb754 100644 --- a/infection_monkey/control.py +++ b/infection_monkey/control.py @@ -67,11 +67,9 @@ class ControlClient(object): if ControlClient.proxies: debug_message += " through proxies: %s" % ControlClient.proxies LOG.debug(debug_message) - # TODO: use different api call to check connectivity. - requests.get("https://%s/api/monkey" % (server,), + requests.get("https://%s/api?action=is-up" % (server,), verify=False, proxies=ControlClient.proxies) - break except Exception as exc: diff --git a/monkey_island/cc/resources/root.py b/monkey_island/cc/resources/root.py index 04129f257..865d99dce 100644 --- a/monkey_island/cc/resources/root.py +++ b/monkey_island/cc/resources/root.py @@ -15,7 +15,6 @@ __author__ = 'Barak' class Root(flask_restful.Resource): - @jwt_required() def get(self, action=None): if not action: action = request.args.get('action') @@ -26,21 +25,26 @@ class Root(flask_restful.Resource): return Root.reset_db() elif action == "killall": return Root.kill_all() + elif action == "is-up": + return {'is-up': True} else: return make_response(400, {'error': 'unknown action'}) @staticmethod + @jwt_required() def get_server_info(): return jsonify(ip_addresses=local_ip_addresses(), mongo=str(mongo.db), completed_steps=Root.get_completed_steps()) @staticmethod + @jwt_required() def reset_db(): [mongo.db[x].drop() for x in ['config', 'monkey', 'telemetry', 'node', 'edge', 'report']] ConfigService.init_config() return jsonify(status='OK') @staticmethod + @jwt_required() def kill_all(): mongo.db.monkey.update({'dead': False}, {'$set': {'config.alive': False, 'modifytime': datetime.now()}}, upsert=False, @@ -48,6 +52,7 @@ class Root(flask_restful.Resource): return jsonify(status='OK') @staticmethod + @jwt_required() def get_completed_steps(): is_any_exists = NodeService.is_any_monkey_exists() infection_done = NodeService.is_monkey_finished_running()