- /* 2008/08/18: add <cloak:ipalways> which always cloaks
- * the IP, for anonymity. --nenolod
- */
- if (!cu->ipalways)
- {
- /** Reset the Hash module, and send it our IV and hex table */
- HashResetRequest(this, cu->HashProvider).Send();
- HashKeyRequest(this, cu->HashProvider, iv).Send();
- HashHexRequest(this, cu->HashProvider, cu->xtab[(dest->host[0]) % 4]);
-
- /* Generate a cloak using specialized Hash */
- std::string hostcloak = cu->prefix + "-" + std::string(HashSumRequest(this, cu->HashProvider, dest->host.c_str()).Send()).substr(0,8) + a;
-
- /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
- * according to the DNS RFC) then tough titty, they get cloaked as an IP.
- * Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie
- * vhost.
- */
- std::string testaddr;
- int testport;
- if (!irc::sockets::satoap(&dest->client_sa, testaddr, testport) && (hostcloak.length() <= 64))
- /* not a valid address, must have been a host, so cloak as a host */
- b = hostcloak;
- else if (dest->client_sa.sa.sa_family == AF_INET6)
- b = cu->Cloak6(dest->GetIPString());
- else
- b = cu->Cloak4(dest->GetIPString());
- }
- else
- {
- if (dest->client_sa.sa.sa_family == AF_INET6)
- b = cu->Cloak6(dest->GetIPString());
- else
- b = cu->Cloak4(dest->GetIPString());
- }
+ // If we're cloaking an IP address we pass it in the IP field too.
+ irc::sockets::sockaddrs sa;
+ const char* ipaddr = irc::sockets::aptosa(parameters[0], 0, sa) ? parameters[0].c_str() : "";