1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 19:23:14 +02:00

Cleaned up the dns engine, and fixed sometimes parsing multiple answer queries incorrectly

This commit is contained in:
Adam
2011-08-23 19:06:15 -04:00
parent d5749c11f3
commit b504791bad
4 changed files with 537 additions and 451 deletions
+7 -4
View File
@@ -28,16 +28,21 @@ class DNSBLResolver : public DNSRequest
public:
DNSBLResolver(Module *c, User *u, const Blacklist &b, const Anope::string &host, bool add_akill) : DNSRequest(host, DNS_QUERY_A, true, c), user(u), blacklist(b), add_to_akill(add_akill) { }
void OnLookupComplete(const DNSRecord *record)
void OnLookupComplete(const DNSQuery *record)
{
if (!user || user->GetExt("m_dnsbl_akilled"))
return;
const ResourceRecord &ans_record = record->answers[0];
// Replies should be in 127.0.0.0/24
if (ans_record.rdata.find("127.0.0.") != 0)
return;
Anope::string record_reason;
if (!this->blacklist.replies.empty())
{
sockaddrs sresult;
sresult.pton(AF_INET, record->result);
sresult.pton(AF_INET, ans_record.rdata);
int result = (sresult.sa4.sin_addr.s_addr & 0xFF000000) >> 24;
if (!this->blacklist.replies.count(result))
@@ -155,8 +160,6 @@ class ModuleDNSBL : public Module
Log() << "m_dnsbl: " << ex.GetReason();
}
}
return;
}
};