On a tangential note, the last bit remaining is httpgate IPv4 addresses, which still have ::ffff: prepended to them. This patch merely introduces the ability to log the IPv6 addresses of visitors and is not needed for IPv6 functionality itself. Without it, IPv6 connections can be made, but the visitor's address and $PEER environment variable will be recorded as "0.0.0.0". --- mgod.c 2011-11-20 14:16:30.000000000 +0000 +++ mgod.c 2017-03-16 09:54:25.386666670 +0000 @@ -1186,11 +1186,25 @@ if(!peer) { /* if peer not specified, try to retrieve info from stdin socket */ - struct sockaddr_in addr; - socklen_t i = sizeof(addr); - int r = getpeername(0, (struct sockaddr *) &addr, &i); - if(r == 0) - peer = inet_ntoa(addr.sin_addr); + struct sockaddr_storage addr; + socklen_t addrlen = sizeof(addr); + int result1 = getpeername(0, (struct sockaddr *) &addr, &addrlen); + if (result1 == 0) { + char buffer[INET6_ADDRSTRLEN]; + const char* result2; + if (addr.ss_family == AF_INET) { + struct sockaddr_in *s = (struct sockaddr_in *) &addr; + result2 = inet_ntop(AF_INET, &s->sin_addr, buffer, sizeof(buffer)); + } else { + struct sockaddr_in6 *s = (struct sockaddr_in6 *) &addr; + result2 = inet_ntop(AF_INET6, &s->sin6_addr, buffer, sizeof(buffer)); + } + + if (result2 == 0) + peer = "unknown"; + else + peer = buffer; + } else peer = "unknown"; }