Fix bug #45: [Request] Whoip command.

Rewrote patches from Zoltan to support ip ranges and multiple results per IP.
Needed to make sure IPv6 mapped IPv4 addresses were converted to proper IPv4 addresses after accept().
This commit is contained in:
Jan Vidar Krey
2009-07-26 04:02:14 +02:00
parent 041ce7a1fb
commit 6358c7f9cd
4 changed files with 79 additions and 2 deletions

View File

@@ -337,7 +337,18 @@ int net_accept(int fd, struct ip_addr_encap* ipaddr)
ipaddr->af = addr4->sin_family;
if (ipaddr->af == AF_INET6)
{
memcpy(&ipaddr->internal_ip_data.in6, &addr6->sin6_addr, sizeof(struct in6_addr));
char address[INET6_ADDRSTRLEN+1] = { 0, };
net_address_to_string(AF_INET6, (void*) &addr6->sin6_addr, address, INET6_ADDRSTRLEN+1);
if (!strncmp(address, "::ffff:", 7))
{
/* Hack to convert IPv6 mapped IPv4 addresses to true IPv4 addresses */
net_string_to_address(AF_INET, address + 7, (void*) &ipaddr->internal_ip_data.in);
ipaddr->af = AF_INET;
}
else
{
memcpy(&ipaddr->internal_ip_data.in6, &addr6->sin6_addr, sizeof(struct in6_addr));
}
}
else
{