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 65
65
import asyncio
66
66
from dataclasses import dataclass
67
67
from datetime import datetime , timedelta , timezone
68
+ import ipaddress
68
69
import os
69
70
import socket
70
71
from typing import Dict , List , Optional
@@ -219,8 +220,10 @@ def _get_local_addresses(self) -> List[str]:
219
220
# Get all network interfaces
220
221
for iface in socket .getaddrinfo (socket .gethostname (), None ):
221
222
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." ):
224
227
addresses .append (addr )
225
228
except Exception as e :
226
229
logger .warning (f"Failed to get local addresses: { e } " )
You can’t perform that action at this time.
0 commit comments