forked from p34709852/monkey
Island: Inject local_ip_addresses into Root resource's constructor
This commit is contained in:
parent
80c6ee8805
commit
4ee1450001
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
from flask import jsonify, make_response, request
|
from flask import jsonify, make_response, request
|
||||||
|
|
||||||
|
@ -6,7 +7,6 @@ from monkey_island.cc.database import mongo
|
||||||
from monkey_island.cc.resources.AbstractResource import AbstractResource
|
from monkey_island.cc.resources.AbstractResource import AbstractResource
|
||||||
from monkey_island.cc.resources.request_authentication import jwt_required
|
from monkey_island.cc.resources.request_authentication import jwt_required
|
||||||
from monkey_island.cc.services.infection_lifecycle import get_completed_steps
|
from monkey_island.cc.services.infection_lifecycle import get_completed_steps
|
||||||
from monkey_island.cc.services.utils.network_utils import get_local_ip_addresses
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ class Root(AbstractResource):
|
||||||
|
|
||||||
urls = ["/api"]
|
urls = ["/api"]
|
||||||
|
|
||||||
|
def __init__(self, local_ip_addresses: Sequence[str]):
|
||||||
|
self._local_ips = local_ip_addresses
|
||||||
|
|
||||||
def get(self, action=None):
|
def get(self, action=None):
|
||||||
if not action:
|
if not action:
|
||||||
action = request.args.get("action")
|
action = request.args.get("action")
|
||||||
|
@ -29,7 +32,7 @@ class Root(AbstractResource):
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def get_server_info(self):
|
def get_server_info(self):
|
||||||
return jsonify(
|
return jsonify(
|
||||||
ip_addresses=get_local_ip_addresses(),
|
ip_addresses=self._local_ips,
|
||||||
mongo=str(mongo.db),
|
mongo=str(mongo.db),
|
||||||
completed_steps=get_completed_steps(),
|
completed_steps=get_completed_steps(),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue