diff --git a/monkey/common/network/network_utils.py b/monkey/common/network/network_utils.py index 06d754502..6f5bc3ab5 100644 --- a/monkey/common/network/network_utils.py +++ b/monkey/common/network/network_utils.py @@ -5,7 +5,7 @@ from typing import List, Optional, Sequence, Tuple from netifaces import AF_INET, ifaddresses, interfaces -def get_local_ip_addresses() -> Sequence[str]: +def get_my_ip_addresses() -> Sequence[str]: ip_list = [] for interface in interfaces(): addresses = ifaddresses(interface).get(AF_INET, []) diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 406e7bfc4..58ab43fa6 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -7,7 +7,7 @@ import requests from urllib3 import disable_warnings from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT -from common.network.network_utils import get_local_ip_addresses +from common.network.network_utils import get_my_ip_addresses from infection_monkey.config import GUID from infection_monkey.network.info import get_host_subnets from infection_monkey.utils import agent_process @@ -39,7 +39,7 @@ class ControlClient: monkey = { "guid": GUID, "hostname": hostname, - "ip_addresses": get_local_ip_addresses(), + "ip_addresses": get_my_ip_addresses(), "networks": get_host_subnets(), "description": " ".join(platform.uname()), "parent": parent, diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 00a1c730a..3d2fc3555 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -18,7 +18,7 @@ from common.events import CredentialsStolenEvent from common.network.network_utils import ( address_to_ip_port, get_local_interfaces, - get_local_ip_addresses, + get_my_ip_addresses, ) from common.utils.argparse_types import positive_int from common.utils.attack_utils import ScanStatus, UsageEnum @@ -205,7 +205,7 @@ class InfectionMonkey: self._cmd_island_port, client_disconnect_timeout=config.keep_tunnel_open_time, ) - relay_servers = [f"{ip}:{relay_port}" for ip in get_local_ip_addresses()] + relay_servers = [f"{ip}:{relay_port}" for ip in get_my_ip_addresses()] if not maximum_depth_reached(config.propagation.maximum_depth, self._current_depth): self._relay.start() diff --git a/monkey/monkey_island/cc/server_utils/network_utils.py b/monkey/monkey_island/cc/server_utils/network_utils.py index 73abded95..f27823789 100644 --- a/monkey/monkey_island/cc/server_utils/network_utils.py +++ b/monkey/monkey_island/cc/server_utils/network_utils.py @@ -3,12 +3,12 @@ from typing import Sequence from ring import lru -from common.network.network_utils import get_local_interfaces, get_local_ip_addresses +from common.network.network_utils import get_local_interfaces, get_my_ip_addresses @lru(maxsize=1) def get_cached_local_ip_addresses() -> Sequence[IPv4Address]: - return get_local_ip_addresses() + return get_my_ip_addresses() # The subnets list should not change often. Therefore, we can cache the result and never call this