1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 08:13:13 +02:00

Moved m_dns's reverse ip method to sockaddrs::reverse().

Updated m_dnsbl to support ipv6.
This commit is contained in:
Alexander Maassen
2017-05-26 18:17:13 +02:00
committed by Adam
parent 087f1cb359
commit bfcfd0b727
4 changed files with 53 additions and 34 deletions
+4 -9
View File
@@ -160,9 +160,8 @@ class ModuleDNSBL : public Module
if (!this->check_on_netburst && !user->server->IsSynced())
return;
/* At this time we only support IPv4 */
if (!user->ip.valid() || user->ip.sa.sa_family != AF_INET)
/* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */
if (!user->ip.valid())
/* User doesn't have a valid IP (spoof/etc) */
return;
if (this->blacklists.empty())
@@ -174,17 +173,13 @@ class ModuleDNSBL : public Module
return;
}
const unsigned long &ip = user->ip.sa4.sin_addr.s_addr;
unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24);
sockaddrs reverse = user->ip;
reverse.sa4.sin_addr.s_addr = reverse_ip;
Anope::string reverse = user->ip.reverse();
for (unsigned i = 0; i < this->blacklists.size(); ++i)
{
const Blacklist &b = this->blacklists[i];
Anope::string dnsbl_host = reverse.addr() + "." + b.name;
Anope::string dnsbl_host = reverse + "." + b.name;
DNSBLResolver *res = NULL;
try
{