Skip to content

Commit 440caaf

Browse files
lmicciniclaude
andcommitted
Normalize IPv4-mapped IPv6 addresses in UDP listener logs
Strip the ::ffff: prefix from IPv4-mapped IPv6 addresses at the UDP recvfrom site so all downstream log messages show clean IPv4 addresses instead of ::ffff:172.17.0.101. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 320b90b commit 440caaf

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

templates/instanceha/bin/instanceha.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
15191519
def _resolve_hostname_dns(data, address, label):
15201520
"""Resolve hostname via reverse DNS lookup (kdump listener)."""
15211521
try:
1522-
ip = address[0]
1523-
if ip.startswith('::ffff:'):
1524-
ip = ip[7:]
1525-
return _extract_hostname(socket.gethostbyaddr(ip)[0])
1522+
return _extract_hostname(socket.gethostbyaddr(address[0])[0])
15261523
except socket.herror:
15271524
logging.warning(
15281525
'%s packet from %s but reverse DNS lookup failed. '
@@ -1610,6 +1607,9 @@ def _udp_listener(service, port, label, magic_numbers, min_packet_size,
16101607
while not stop_event.is_set():
16111608
try:
16121609
data, address = sock.recvfrom(4096)
1610+
# Normalize IPv4-mapped IPv6 addresses (::ffff:1.2.3.4 -> 1.2.3.4)
1611+
if address[0].startswith('::ffff:'):
1612+
address = (address[0][7:],) + address[1:]
16131613

16141614
if len(data) < min_packet_size:
16151615
continue

0 commit comments

Comments
 (0)