summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-09-19 17:21:08 -0400
committerAdam <Adam@anope.org>2010-09-19 17:21:08 -0400
commitce69f294a116bf8dfaf0e5e650159dbefe1b484c (patch)
treef6b5245fe876bbd968f1a12708861ab67fcb7717
parentf8ee95ef989b83d9af7f802a25a8c7d9f81dd116 (diff)
Added configuration for m_dnsbl for what return values get banned
-rw-r--r--data/example.conf13
-rw-r--r--modules/extra/m_dnsbl.cpp29
2 files changed, 37 insertions, 5 deletions
diff --git a/data/example.conf b/data/example.conf
index 639077f65..43a6069f7 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -1744,16 +1744,27 @@ blacklist
{
/* Name of the blacklist */
name = "rbl.efnetrbl.org";
+
/* How long to set the akill for */
time = 4h;
+
/* Reason for akill.
* %n is the nick of the user
* %u is the ident/username of the user
- * %r is the realname of the user
+ * %g is the realname of the user
* %h is the hostname of the user
* %i is the IP of the user
+ * %r is the reason (configured below). Will be nothing if not configured.
*/
reason = "You are listed in the efnet RBL, visit http://rbl.efnetrbl.org/?i=%i for info"
+
+ /* Replies to ban and their reason. If this is totally ommited all replies get banned */
+ 1 = "Open Proxy";
+ /* Don't ban for result 2 or 3 */
+ #2 = "spamtrap666";
+ #3 = "spamtrap50";
+ 4 = "TOR";
+ 5 = "Drones / Flooding";
}
blacklist
{
diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp
index d123fd974..439798ce5 100644
--- a/modules/extra/m_dnsbl.cpp
+++ b/modules/extra/m_dnsbl.cpp
@@ -12,8 +12,9 @@ struct Blacklist
Anope::string name;
time_t bantime;
Anope::string reason;
+ std::map<int, Anope::string> replies;
- Blacklist(const Anope::string &n, time_t b, const Anope::string &r) : name(n), bantime(b), reason(r) { }
+ Blacklist(const Anope::string &n, time_t b, const Anope::string &r, const std::map<int, Anope::string> &re) : name(n), bantime(b), reason(r), replies(re) { }
};
class DNSBLResolver : public DNSRequest
@@ -25,19 +26,32 @@ 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 *)
+ void OnLookupComplete(const DNSRecord *record)
{
if (!user || user->GetExt("m_dnsbl_akilled"))
return;
+ Anope::string record_reason;
+ if (!this->blacklist.replies.empty())
+ {
+ sockaddrs sresult;
+ sresult.pton(AF_INET, record->result);
+ int result = (sresult.sa4.sin_addr.s_addr & 0xFF000000) >> 24;
+
+ if (!this->blacklist.replies.count(result))
+ return;
+ record_reason = this->blacklist.replies[result];
+ }
+
user->Extend("m_dnsbl_akilled");
Anope::string reason = this->blacklist.reason;
reason = reason.replace_all_ci("%n", user->nick);
reason = reason.replace_all_ci("%u", user->GetIdent());
- reason = reason.replace_all_ci("%r", user->realname);
+ reason = reason.replace_all_ci("%g", user->realname);
reason = reason.replace_all_ci("%h", user->host);
reason = reason.replace_all_ci("%i", user->ip.addr());
+ reason = reason.replace_all_ci("%r", record_reason);
XLine *x = NULL;
if (this->add_to_akill && SGLine && (x = SGLine->Add(NULL, NULL, Anope::string("*@") + user->host, Anope::CurTime + this->blacklist.bantime, reason)))
@@ -96,8 +110,15 @@ class ModuleDNSBL : public Module
if (bantime < 0)
bantime = 9000;
Anope::string reason = config.ReadValue("blacklist", "reason", "", i);
+ std::map<int, Anope::string> replies;
+ for (int j = 0; j < 256; ++j)
+ {
+ Anope::string k = config.ReadValue("blacklist", stringify(j), "", i);
+ if (!k.empty())
+ replies[j] = k;
+ }
- this->blacklists.push_back(Blacklist(bname, bantime, reason));
+ this->blacklists.push_back(Blacklist(bname, bantime, reason, replies));
}
}