const char *reason;
unsigned int duration;
unsigned int mask;
+ unsigned int debug : 1;
char zone[1];
};
static dict_t blacklist_reasons; /* maps strings to themselves (poor man's data sharing) */
static struct {
+ struct userNode *debug_bot;
+ struct chanNode *debug_channel;
unsigned long gline_duration;
} conf;
+#define blacklist_debug(format...) do { if (conf.debug_bot && conf.debug_channel) send_channel_notice(conf.debug_channel , conf.debug_bot , ## format); } while (0)
+
static void
do_expandos(char *output, unsigned int out_len, const char *input, ...)
{
/* Expand elements of the message as necessary. */
do_expandos(reason, sizeof(reason), message, "%txt%", (txt ? txt : "(no-txt)"), "%ip%", data->client_ip, NULL);
- /* Now generate the G-line. */
- target[0] = '*';
- target[1] = '@';
- strcpy(target + 2, data->client_ip);
- gline_add(self->name, target, zone->duration, reason, now, now, 1);
+ if (zone->debug) {
+ blacklist_debug("DNSBL match: [%s] %s (%s)", zone->zone, data->client_ip, reason);
+ } else {
+ /* Now generate the G-line. */
+ target[0] = '*';
+ target[1] = '@';
+ strcpy(target + 2, data->client_ip);
+ gline_add(self->name, target, zone->duration, reason, now, now, 1);
+ }
}
free(txt);
}
if (node == NULL)
return;
+ str1 = database_get_data(node, "debug_bot", RECDB_QSTRING);
+ if (str1)
+ conf.debug_bot = GetUserH(str1);
+
+ str1 = database_get_data(node, "debug_channel", RECDB_QSTRING);
+ if (conf.debug_bot && str1) {
+ str2 = database_get_data(node, "debug_channel_modes", RECDB_QSTRING);
+ if (!str2)
+ str2 = "+tinms";
+ conf.debug_channel = AddChannel(str1, now, str2, NULL);
+ AddChannelUser(conf.debug_bot, conf.debug_channel)->modes |= MODE_CHANOP;
+ } else {
+ conf.debug_channel = NULL;
+ }
+
str1 = database_get_data(node, "file", RECDB_QSTRING);
str2 = database_get_data(node, "file_reason", RECDB_QSTRING);
blacklist_load_file(str1, str2);
zone->duration = str1 ? ParseInterval(str1) : 3600;
str1 = database_get_data(dnsbl, "mask", RECDB_QSTRING);
zone->mask = str1 ? strtoul(str1, NULL, 0) : ~0u;
+ str1 = database_get_data(dnsbl, "debug", RECDB_QSTRING);
+ zone->debug = str1 ? enabled_string(str1) : 0;
zone->reasons.used = 0;
zone->reasons.size = 0;
zone->reasons.list = NULL;
"file_reason" "client is blacklisted";
// How long should a blacklist G-line last?
"gline_duration" "1h";
+ // Bot used to send debug notices
+ "debug_bot" "OpServ";
+ // To which channel should debug output be sent?
+ "debug_channel" "#opserv";
+ "debug_channel_modes" "+tinms";
// If you want to use DNS blacklists, add them here:
"dnsbl" {
// This DNSBL zone does not exist - you'll have to pick your own.
"dnsbl.example.org" {
+ // Send a notice instead of glining blacklisted ips
+ "debug" "1";
"description" "Example DNSBL entry";
"reason" "busted by a dns blacklist";
"duration" "1h";