diff --git a/darkhttpd.c b/darkhttpd.c index ea778b4..a4a4c8f 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -797,8 +797,12 @@ static const char *get_address_text(const void *addr) { #ifdef HAVE_INET6 if (inet6) { static char text_addr[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, (const struct in6_addr *)addr, text_addr, - INET6_ADDRSTRLEN); + const struct in6_addr *in6_addr = addr; + inet_ntop(AF_INET6, in6_addr, text_addr, INET6_ADDRSTRLEN); + /* IPv4 addresses via dual stack result in mapped IPv6 addresses. + Strip the prefix (::ffff:) for plain IPv4 addresses. */ + if (IN6_IS_ADDR_V4MAPPED(in6_addr)) + return text_addr + 7; return text_addr; } else #endif