Island: Pass local_ip_addresses in IpAddresses resource constructor

This commit is contained in:
Shreya Malviya 2022-08-04 12:35:47 +05:30
parent 1466fccc5f
commit 637c466822
1 changed files with 4 additions and 3 deletions

View File

@ -2,12 +2,14 @@ from typing import Mapping, Sequence
from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.resources.request_authentication import jwt_required
from monkey_island.cc.services.utils.network_utils import get_local_ip_addresses
class IpAddresses(AbstractResource):
urls = ["/api/island/ip-addresses"]
def __init__(self, local_ip_addresses: Sequence[str]):
self._local_ips = local_ip_addresses
@jwt_required
def get(self) -> Mapping[str, Sequence[str]]:
"""
@ -15,6 +17,5 @@ class IpAddresses(AbstractResource):
:return: a dictionary with "ip_addresses" key that points to a list of IP's
"""
local_ips = get_local_ip_addresses()
return {"ip_addresses": local_ips}
return {"ip_addresses": self._local_ips}