From fc4c05405bfbd1973530b2fb4c230335244d542d Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 23 Sep 2022 08:13:20 -0400 Subject: [PATCH] Common: Add get_my_ip_addresses() -> Sequence[IPv4Address] --- monkey/common/network/network_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monkey/common/network/network_utils.py b/monkey/common/network/network_utils.py index ce8002d0c..0ea079239 100644 --- a/monkey/common/network/network_utils.py +++ b/monkey/common/network/network_utils.py @@ -1,12 +1,16 @@ import ipaddress -from ipaddress import IPv4Interface +from ipaddress import IPv4Address, IPv4Interface from typing import List, Optional, Sequence, Tuple from netifaces import AF_INET, ifaddresses, interfaces def get_my_ip_addresses_legacy() -> Sequence[str]: - return [str(interface.ip) for interface in get_network_interfaces()] + return [str(ip) for ip in get_my_ip_addresses()] + + +def get_my_ip_addresses() -> Sequence[IPv4Address]: + return [interface.ip for interface in get_network_interfaces()] def get_network_interfaces() -> List[IPv4Interface]: