File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 6565import asyncio
6666from dataclasses import dataclass
6767from datetime import datetime , timedelta , timezone
68+ import ipaddress
6869import os
6970import socket
7071from typing import Dict , List , Optional
@@ -219,8 +220,10 @@ def _get_local_addresses(self) -> List[str]:
219220 # Get all network interfaces
220221 for iface in socket .getaddrinfo (socket .gethostname (), None ):
221222 addr = iface [4 ][0 ]
222- # Skip localhost
223- if not addr .startswith ("127." ):
223+ ip_obj = ipaddress .ip_address (addr )
224+ is_ipv4 = isinstance (ip_obj , ipaddress .IPv4Address )
225+ # Skip localhost and non ipv4 addresses
226+ if is_ipv4 and not addr .startswith ("127." ):
224227 addresses .append (addr )
225228 except Exception as e :
226229 logger .warning (f"Failed to get local addresses: { e } " )
You can’t perform that action at this time.
0 commit comments