diff --git a/core/services/beacon/settings.py b/core/services/beacon/settings.py index 004a49b0e4..286c5fdbe4 100644 --- a/core/services/beacon/settings.py +++ b/core/services/beacon/settings.py @@ -41,7 +41,11 @@ def get_phys(self) -> List[psutil._common.snicaddr]: def get_ip_strs(self) -> List[str]: """ - get ip as a string. this also translates 'ips[n]' to the n-th ip in that interface + returns a list of the interface IPs (IPv4 only) as a list of strings: + - if self.ip is "ips[*]", it returns all ips of that interface + - if self.ip is "ips[n]", it returns the n-th ip of that interface + - if self.ip is a single ipv4 (like "192.168.2.2"), it returns that ip as a string + - if self.ip is (mistakenly) an IPv6 or any other non-IPv4 format, it raises an InvalidIpAddress error """ address = str(self.ip) # Check for 'ips[n]' @@ -71,7 +75,7 @@ def get_ip_strs(self) -> List[str]: def get_ips(self) -> List[bytes]: """ - returns the ip as 4 bytes + returns a list of the interface IPs (IPv4 only) as a list of 4 bytes """ return [socket.inet_aton(ip) for ip in self.get_ip_strs()] @@ -172,7 +176,7 @@ def migrate(self, data: Dict[str, Any]) -> None: try: if not any(interface["name"] == "uap0" for interface in data["interfaces"]): data["interfaces"].append( - Interface(name="uap0", domain_names=["blueos-hotspot"], advertise=["_http"], ip="ips[0]").as_dict() + Interface(name="uap0", domain_names=["blueos-hotspot"], advertise=["_http"], ip="ips[0]")._data ) except Exception as e: logger.error(f"unable to update SettingsV2 to SettingsV3: {e}")