This repository has been archived on 2025-02-12. You can view files and clone it, but cannot push or open issues or pull requests.
NeoStats-blsb/blsb.c

600 lines
17 KiB
C
Raw Normal View History

2005-05-08 09:24:11 +00:00
/* NeoStats - IRC Statistical Services
2006-01-26 15:40:07 +00:00
** Copyright (c) 1999-2006 Adam Rutter, Justin Hammond, Mark Hetherington
2005-05-08 09:24:11 +00:00
** http://www.neostats.net/
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
** USA
**
** NeoStats CVS Identification
2005-05-08 09:32:13 +00:00
** $Id$
2005-05-08 09:24:11 +00:00
*/
2005-05-22 20:08:09 +00:00
/* TODO:
* - Akill support.
* - Buffer sizes for name and domain should not need to be so big
2005-05-22 21:39:43 +00:00
* and should be made a more appropriate size.
* - If a remove akill command is added, it must check whether an akill
2005-05-22 20:08:09 +00:00
* was added by blsb before removing it otherwise blsb becomes a way
2005-05-22 21:39:43 +00:00
* for opers to remove any akill on the network including those they
* may not normally have access to.
* - Do we need cache support?.
2005-05-22 20:08:09 +00:00
*/
2005-05-08 09:24:11 +00:00
#include "neostats.h"
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#include "blsb.h"
2005-10-13 22:40:14 +00:00
static int event_nickip( const CmdParams *cmdparams );
static int blsb_cmd_list( const CmdParams *cmdparams );
static int blsb_cmd_add( const CmdParams *cmdparams );
static int blsb_cmd_del( const CmdParams *cmdparams );
static int blsb_cmd_check( const CmdParams *cmdparams );
static int blsb_set_exclusions_cb( const CmdParams *cmdparams, SET_REASON reason );
2005-10-20 21:06:51 +00:00
static struct blsb {
int akilltime;
int doakill;
int verbose;
int exclusions;
list_t *domains;
} blsb;
static Bot *blsb_bot;
2005-05-22 21:39:43 +00:00
static dom_list stddomlist[] =
{
{"Secure-IRC", "bl.irc-chat.net", BL_LOOKUP_TXT_RECORD, "Insecure Host - See http://secure.irc-chat.net/ipinfo.php?ip=%s", 0},
{"Tor_Exit_Server", "exitnodes.tor.dnsbl.sectoor.de", BL_LOOKUP_TXT_RECORD, "Your Host is a Tor Exit Server", 0},
{"IRC Abusive Hosts", "ircbl.ahbl.org", BL_LOOKUP_A_RECORD, "Abusive Host - See http://www.ahbl.org/ for more info and/or removal (your IP is %s)", 0},
2008-03-04 07:07:33 +00:00
{"Drone BlackList", "dnsbl.dronebl.org", BL_LOOKUP_A_RECORD, "Your host is listed in DroneBL. See http://www.dronebl.org/lookup?ip=%s for more info", 0},
{"", "", 0}
};
2005-05-08 09:24:11 +00:00
/** Copyright info */
2005-10-20 21:06:51 +00:00
static const char *blsb_copyright[] =
2005-05-22 21:39:43 +00:00
{
2006-01-26 15:40:07 +00:00
"Copyright (c) 1999-2006, NeoStats",
2005-05-08 09:24:11 +00:00
"http://www.neostats.net/",
NULL
};
/** Module Info definition
2005-05-22 21:39:43 +00:00
* This describes the module to the NeoStats core and provides information
* to end users when modules are queried.
* The structure is required but some fields are optional.
2005-05-08 09:24:11 +00:00
*/
2005-05-22 21:39:43 +00:00
ModuleInfo module_info =
{
"BLSB",
"Black List Scanning Bot",
2005-05-08 09:24:11 +00:00
blsb_copyright,
blsb_about,
NEOSTATS_VERSION,
MODULE_VERSION,
__DATE__,
__TIME__,
MODULE_FLAG_LOCAL_EXCLUDES,
0,
2005-10-20 21:06:51 +00:00
0,
2005-05-08 09:24:11 +00:00
};
static bot_cmd blsb_commands[]=
{
{"ADD", blsb_cmd_add, 4, NS_ULEVEL_ADMIN, blsb_help_add, 0, NULL, NULL},
{"DEL", blsb_cmd_del, 1, NS_ULEVEL_ADMIN, blsb_help_del, 0, NULL, NULL},
{"LIST", blsb_cmd_list, 0, NS_ULEVEL_ADMIN, blsb_help_list, 0, NULL, NULL},
{"CHECK", blsb_cmd_check, 1, NS_ULEVEL_OPER, blsb_help_check, 0, NULL, NULL},
NS_CMD_END()
2005-05-08 09:24:11 +00:00
};
static bot_setting blsb_settings[]=
{
{"AKILL", &blsb.doakill, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, blsb_help_set_akill, NULL, (void*)1 },
{"AKILLTIME", &blsb.akilltime, SET_TYPE_INT, 0, 20736000, NS_ULEVEL_ADMIN, NULL, blsb_help_set_akilltime, NULL, (void*)TS_ONE_DAY },
{"VERBOSE", &blsb.verbose, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, blsb_help_set_verbose, NULL, (void*)1 },
{"EXCLUSIONS", &blsb.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, blsb_help_set_exclusions, blsb_set_exclusions_cb, (void *)0 },
NS_SETTING_END()
2005-05-08 09:24:11 +00:00
};
/** BotInfo */
static BotInfo blsb_botinfo =
{
"blsb",
"blsb1",
"blsb",
BOT_COMMON_HOST,
"BlackList Scanning Bot",
BOT_FLAG_SERVICEBOT|BOT_FLAG_RESTRICT_OPERS|BOT_FLAG_DEAF,
blsb_commands,
blsb_settings,
};
2005-05-22 21:39:43 +00:00
/** Module event list
* What events we will act on
*/
ModuleEvent module_events[] =
{
2005-05-22 20:08:09 +00:00
{ EVENT_NICKIP, event_nickip, EVENT_FLAG_EXCLUDE_ME},
2005-09-19 20:35:36 +00:00
NS_EVENT_END()
};
2005-05-22 20:08:09 +00:00
/** @brief new_bldomain
*
* Allocate a new blacklist domain entry and add to the list
*
* @param name of service
* @param domain of service
* @param type of service
*
* @return pointer to newly allocated entry
*/
static dom_list *new_bldomain( const char *name, const char *domain, BL_LOOKUP_TYPE type, const char *msg , int noban)
2005-05-22 20:08:09 +00:00
{
dom_list *dl;
dl = ns_calloc( sizeof( dom_list ) );
strlcpy( dl->name, name, BUFSIZE );
strlcpy( dl->domain, domain, BUFSIZE );
2005-08-12 15:03:48 +00:00
strlcpy( dl->msg, msg, BUFSIZE );
dl->type = type;
dl->noban = noban;
2005-05-22 20:08:09 +00:00
lnode_create_append( blsb.domains, dl );
DBAStore( "domains", dl->name, (void *)dl, sizeof( dom_list ) );
return dl;
}
2005-05-22 21:39:43 +00:00
/** @brief dnsbl_callback
*
* DNS callback
*
* @param data
* @param a
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-10-20 21:06:51 +00:00
static void dnsbl_callback(void *data, adns_answer *a)
2005-05-22 21:39:43 +00:00
{
scanclient *sc = (scanclient *)data;
2005-08-12 15:03:48 +00:00
int i;
2005-10-20 21:06:51 +00:00
char *show = NULL;
2005-08-12 15:03:48 +00:00
struct in_addr inp;
Client *u=NULL;
2005-08-12 15:03:48 +00:00
if (a && (a->nrrs > 0) && (a->status == adns_s_ok)) {
for (i = 0; i < a->nrrs; i++) {
if (a->type == adns_r_a) {
/* here we should actually check the return IP address and see if we really want to do something with it */
inp = *((struct in_addr*)&a->rrs.inaddr[i]);
show = ns_malloc(BUFSIZE);
ircsnprintf(show, BUFSIZE, sc->domain->msg, sc->ip);
} if (a->type == adns_r_txt) {
show = a->rrs.manyistr[i]->str;
}
irc_chanalert( blsb_bot, "%s (%s) exists in %s blacklist: %s %s", sc->usernick, sc->ip, sc->domain->name, show, sc->domain->noban ? "(NOBAN)" : "" );
if( sc->checknick[0] != '\0' )
u = FindUser( sc->checknick );
if( u )
irc_prefmsg(blsb_bot, u, "%s (%s) exists in %s blacklist: %s %s", sc->usernick, sc->ip, sc->domain->name, show, sc->domain->noban ? "(NOBAN)" : "" );
if (sc->banned == 0 && !sc->domain->noban) {
2005-08-12 15:03:48 +00:00
sc->banned = 1;
/* only ban/msg the user once */
u = FindUser(sc->usernick);
if( u )
irc_prefmsg(blsb_bot, u, "Your Host is listed as a inscure host at %s: %s", sc->domain->name, show);
2005-08-12 15:03:48 +00:00
if (blsb.doakill) {
2006-07-08 06:47:01 +00:00
if( sc->exclude != 1 )
{
irc_akill (blsb_bot, sc->ip, "*", blsb.akilltime, "Your Host is listed as a insecure host at %s: %s", sc->domain->name, show);
irc_chanalert( blsb_bot, "Akilling %s!%s@%s", sc->usernick, sc->username, sc->hostname);
}
2005-08-12 15:03:48 +00:00
}
2005-05-22 21:39:43 +00:00
}
2005-08-12 15:03:48 +00:00
if (a->type == adns_r_a) ns_free(show);
2005-05-22 21:39:43 +00:00
}
} else if (a && ((a->status == adns_s_nxdomain) || (a->status == adns_s_nodata))) {
2005-08-12 15:03:48 +00:00
if (blsb.verbose)
irc_chanalert( blsb_bot, "%s (%s) does not exist in %s blacklist", sc->usernick, sc->ip, sc->domain->name);
if( sc->checknick[0] != '\0' )
u = FindUser( sc->checknick );
if( u )
irc_prefmsg(blsb_bot, u, "%s (%s) does not exist in %s blacklist", sc->usernick, sc->ip, sc->domain->name);
2005-08-12 15:03:48 +00:00
} else if (a->status != adns_s_ok) {
nlog(LOG_WARNING, "DNS error %s", adns_strerror(a->status));
}
2006-01-19 04:25:37 +00:00
ns_free(sc->lookup);
ns_free(sc);
2005-05-22 21:39:43 +00:00
}
/** @brief do_lookup
*
* trigger lookups
*
* @param Client *lookupuser
* @param Client *reportuser
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-05-23 21:15:26 +00:00
2005-10-20 21:06:51 +00:00
static scanclient *do_lookup( Client *lookupuser, Client *reportuser )
2005-05-22 21:39:43 +00:00
{
static char ip[HOSTIPLEN];
static char reverseip[HOSTIPLEN];
lnode_t *node;
dom_list *dl;
scanclient *sc = NULL;
unsigned char a, b, c, d;
2005-10-20 21:06:51 +00:00
unsigned int buflen;
2005-05-22 21:39:43 +00:00
d = (unsigned char) ( lookupuser->ip.s_addr >> 24 ) & 0xFF;
c = (unsigned char) ( lookupuser->ip.s_addr >> 16 ) & 0xFF;
b = (unsigned char) ( lookupuser->ip.s_addr >> 8 ) & 0xFF;
a = (unsigned char) ( lookupuser->ip.s_addr & 0xFF );
ircsnprintf( ip, HOSTIPLEN, "%d.%d.%d.%d", a, b, c, d );
ircsnprintf( reverseip, HOSTIPLEN, "%d.%d.%d.%d", d, c, b, a );
node = list_first( blsb.domains );
while( node )
{
dl = lnode_get( node);
/* Allocate enough for domain, ip address, additional period and NULL */
buflen = strlen( dl->domain ) + HOSTIPLEN + 1 + 1;
sc = ns_malloc( sizeof( scanclient ) );
if( reportuser == NULL )
sc->checknick[0] = '\0';
else
strlcpy( sc->checknick, reportuser->name, MAXNICK );
strlcpy( sc->usernick, lookupuser->name, MAXNICK );
strlcpy( sc->username, lookupuser->user->username, MAXUSER );
strlcpy( sc->hostname, lookupuser->user->hostname, MAXHOST );
if( ModIsUserExcluded( lookupuser ) == NS_FALSE )
sc->exclude = 0;
else
sc->exclude = 1;
2005-05-22 21:39:43 +00:00
sc->domain = dl;
2005-08-12 15:03:48 +00:00
sc->banned = 0;
2005-05-22 21:39:43 +00:00
sc->lookup = ns_malloc( buflen );
strlcpy( sc->ip, ip, HOSTIPLEN );
strlcpy( sc->reverseip, reverseip, HOSTIPLEN );
ircsnprintf( sc->lookup, buflen, "%s.%s", reverseip, dl->domain );
switch (dl->type)
{
case BL_LOOKUP_TXT_RECORD: /* TXT record */
dns_lookup( sc->lookup, adns_r_txt, dnsbl_callback, sc );
break;
case BL_LOOKUP_A_RECORD: /* A record */
dns_lookup( sc->lookup, adns_r_a, dnsbl_callback, sc );
break;
default:
nlog( LOG_WARNING, "Unknown Type for DNS BL %s", dl->name );
break;
}
node = list_next( blsb.domains, node );
2005-05-22 21:39:43 +00:00
}
return sc;
}
2005-05-22 20:08:09 +00:00
/** @brief blsb_cmd_list
*
* LIST command handler
* List entries in the blacklist domain list
*
* @param cmdparam struct
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-10-13 22:40:14 +00:00
int blsb_cmd_list( const CmdParams *cmdparams )
{
dom_list *dl;
lnode_t *lnode;
lnode = list_first(blsb.domains);
2005-05-22 20:08:09 +00:00
irc_prefmsg (blsb_bot, cmdparams->source, "BlackList domains:");
while (lnode) {
dl = lnode_get(lnode);
irc_prefmsg (blsb_bot, cmdparams->source, "%s: %s (type %d) %s", dl->domain, dl->name, dl->type, dl->noban ? "NOBAN" : "");
lnode = list_next(blsb.domains, lnode);
}
irc_prefmsg (blsb_bot, cmdparams->source, "End of list.");
2005-05-22 20:08:09 +00:00
CommandReport(blsb_bot, "%s requested blacklist domain list", cmdparams->source->name);
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief blsb_cmd_add
*
* ADD command handler
* Add an entry to the blacklist domain list
*
* @param cmdparam struct
2005-05-22 21:39:43 +00:00
* cmdparams->av[0] = domain
* cmdparams->av[1] = type
* cmdparams->av[2] = name
2005-05-22 20:08:09 +00:00
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-10-13 22:40:14 +00:00
int blsb_cmd_add( const CmdParams *cmdparams )
{
dom_list *dl;
lnode_t *lnode;
2005-05-22 20:08:09 +00:00
int type;
2005-08-12 15:03:48 +00:00
char *msg;
2005-05-22 21:39:43 +00:00
if( list_isfull( blsb.domains ) )
{
irc_prefmsg( blsb_bot, cmdparams->source, "Error, domain list is full" );
2005-05-22 20:08:09 +00:00
return NS_FAILURE;
}
2005-05-22 21:39:43 +00:00
type = atoi( cmdparams->av[1] );
if( type <= BL_LOOKUP_TYPE_MIN || type >= BL_LOOKUP_TYPE_MAX )
{
irc_prefmsg( blsb_bot, cmdparams->source, "type field does not contain a valid type" );
2005-05-22 20:08:09 +00:00
return NS_FAILURE;
}
2005-08-12 15:03:48 +00:00
msg = joinbuf( cmdparams->av, cmdparams->ac, 3 );
/* XXX do a initial lookup on the domain to check it exists? */
/* check for duplicates */
2005-05-22 21:39:43 +00:00
lnode = list_first( blsb.domains );
while( lnode )
{
dl = lnode_get( lnode );
2005-11-14 22:34:38 +00:00
if( ( ircstrcasecmp( dl->name, cmdparams->av[2] ) == 0 ) || ( ircstrcasecmp(dl->domain, cmdparams->av[0] ) == 0 ) )
2005-05-22 21:39:43 +00:00
{
irc_prefmsg( blsb_bot, cmdparams->source, "%s already has an entry", cmdparams->av[0] );
return NS_SUCCESS;
}
lnode = list_next(blsb.domains, lnode);
}
2005-12-15 08:14:46 +00:00
dl = new_bldomain( cmdparams->av[2], cmdparams->av[0], type, msg , ircstrcasecmp( cmdparams->av[3], "NOBAN" ) ? 0 : 1);
2005-05-22 21:39:43 +00:00
irc_prefmsg( blsb_bot, cmdparams->source, "Added domain %s (%s) as type %d", dl->name, dl->domain, dl->type );
CommandReport( blsb_bot, "%s added domain %s (%s) as type %d", cmdparams->source->name, dl->name, dl->domain, dl->type );
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief blsb_cmd_del
*
* DEL command handler
* deletes an entry from the blacklist domain list
*
* @param cmdparam struct
2005-05-22 21:39:43 +00:00
* cmdparams->av[0] = domain
2005-05-22 20:08:09 +00:00
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-10-13 22:40:14 +00:00
int blsb_cmd_del( const CmdParams *cmdparams )
{
dom_list *dl;
lnode_t *lnode;
2005-05-22 20:08:09 +00:00
lnode = list_first(blsb.domains);
while (lnode) {
2005-05-22 21:39:43 +00:00
dl = lnode_get(lnode);
if( ircstrcasecmp( dl->domain, cmdparams->av[0] ) == 0 )
{
2005-05-22 20:08:09 +00:00
list_delete(blsb.domains, lnode);
lnode_destroy(lnode);
2005-05-22 21:39:43 +00:00
irc_prefmsg (blsb_bot, cmdparams->source, "Deleted %s (%s) from blacklist domains", dl->name, dl->domain);
CommandReport(blsb_bot, "%s deleted %s (%s) from blacklist domains", cmdparams->source->name, dl->name, dl->domain);
2005-05-22 20:08:09 +00:00
DBADelete("domains", dl->name);
ns_free(dl);
return NS_SUCCESS;
}
lnode = list_next(blsb.domains, lnode);
}
/* if we get here, then we can't find the entry */
2005-05-29 04:38:46 +00:00
irc_prefmsg (blsb_bot, cmdparams->source, "Error, no entry for %s", cmdparams->av[0]);
2005-05-22 20:08:09 +00:00
return NS_FAILURE;
}
2005-05-22 20:08:09 +00:00
/** @brief blsb_cmd_check
*
* CHECK command handler
*
* @param cmdparam struct
*
* @return NS_SUCCESS if suceeds else result of command
*/
2005-10-13 22:40:14 +00:00
int blsb_cmd_check( const CmdParams *cmdparams )
{
scanclient *sc = NULL;
2005-05-22 21:39:43 +00:00
Client *user;
user = FindUser(cmdparams->av[0]);
2005-05-22 21:39:43 +00:00
if (!user)
{
#if 0
/* XXX TODO: Lookup Hostname */
if (!ValidateHost(cmdparams->av[0]) {
irc_prefmsg(blsb_bot, cmdparams->source, "Invalid Nick or Host");
return NS_FAILURE;
} else {
2005-05-22 20:08:09 +00:00
sc = ns_malloc(sizeof(scanclient));
strlcpy( sc->checknick, cmdparams->source->name, MAXNICK );
strlcpy( sc->usernick, cmdparams->source->name, MAXNICK );
strlcpy( sc->username, cmdparams->source->user->username, MAXUSER );
strlcpy( sc->hostname, cmdparams->source->user->hostname, MAXHOST );
if( ModIsUserExcluded( cmdparams->source ) == NS_FALSE )
sc->exclude = 0;
else
sc->exclude = 1;
2005-05-22 20:08:09 +00:00
sc->domain = dl;
sc->lookup = ns_malloc(buflen);
ircsnprintf(sc->lookup, buflen, "%d.%d.%d.%d.%s", d, c, b, a, dl->domain);
#endif
2005-05-22 21:39:43 +00:00
irc_prefmsg(blsb_bot, cmdparams->source, "Can not find %s online", cmdparams->av[0]);
return NS_ERR_SYNTAX_ERROR;
}
2005-05-22 21:39:43 +00:00
sc = do_lookup( user, cmdparams->source );
if( sc )
{
irc_prefmsg( blsb_bot, cmdparams->source, "Checking %s (%s) against DNS Blacklists", sc->usernick, sc->ip );
CommandReport( blsb_bot, "%s is checking %s (%s) against DNS Blacklists", cmdparams->source->name, sc->usernick, sc->ip );
}
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief event_nickip
*
* NICKIP event handler
* scan user that just signed on the network
*
* @cmdparams pointer to commands param struct
*
* @return NS_SUCCESS if suceeds else NS_FAILURE
*/
2005-10-13 22:40:14 +00:00
static int event_nickip( const CmdParams *cmdparams )
2005-05-08 09:24:11 +00:00
{
SET_SEGV_LOCATION();
2005-05-22 20:08:09 +00:00
if (ModIsServerExcluded(cmdparams->source->uplink))
return NS_SUCCESS;
2005-05-22 20:08:09 +00:00
if (IsNetSplit(cmdparams->source))
return NS_SUCCESS;
2005-10-20 21:06:51 +00:00
(void)do_lookup( cmdparams->source, NULL );
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief load_dom
*
* Database load domains row callback handler
*
* @param pointer to loaded data
* @param size of loaded data
*
* @return NS_FALSE
*/
static int load_dom( void *data, int size )
{
dom_list *dl;
if( size == sizeof(dom_list) )
{
dl = ns_calloc( sizeof(dom_list));
os_memcpy(dl, data, sizeof (dom_list));
lnode_create_append(blsb.domains, dl);
}
return NS_FALSE;
2005-05-08 09:24:11 +00:00
}
2005-05-22 20:08:09 +00:00
/** @brief load_default_bldomains
*
* Load default domain settings
*
* @param none
*
* @return none
*/
static void load_default_bldomains( void )
2005-05-08 09:24:11 +00:00
{
2005-05-22 20:08:09 +00:00
dom_list *default_domains;
default_domains = stddomlist;
2005-05-22 21:39:43 +00:00
while( default_domains->type != BL_LOOKUP_TYPE_MIN )
2005-05-22 20:08:09 +00:00
{
(void)new_bldomain( default_domains->name, default_domains->domain, default_domains->type, default_domains->msg , default_domains->noban );
2005-05-22 20:08:09 +00:00
default_domains++;
}
}
/** @brief ModInit
*
* Init handler
*
* @param none
*
* @return NS_SUCCESS if suceeds else NS_FAILURE
*/
int ModInit( void )
{
ModuleConfig( blsb_settings );
2005-10-11 22:02:11 +00:00
blsb.domains = list_create( LISTCOUNT_T_MAX );
2005-08-12 15:03:48 +00:00
me.want_nickip = 1;
2005-05-22 20:08:09 +00:00
if( !blsb.domains ) {
nlog( LOG_CRITICAL, "Unable to create domain list" );
return NS_FAILURE;
}
2005-05-22 20:08:09 +00:00
DBAFetchRows( "domains", load_dom );
/* If no domains, this must be our first run so load defaults */
if( list_count( blsb.domains ) == 0 )
load_default_bldomains();
2005-05-08 09:24:11 +00:00
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief ModSynch
*
* Startup handler
*
* @param none
*
* @return NS_SUCCESS if suceeds else NS_FAILURE
*/
int ModSynch (void)
{
SET_SEGV_LOCATION();
blsb_bot = AddBot (&blsb_botinfo);
if( !blsb_bot )
return NS_FAILURE;
if( blsb.verbose )
irc_chanalert (blsb_bot, "Black List Scanning bot has started");
return NS_SUCCESS;
}
/** @brief ModFini
*
* Fini handler
*
* @param none
*
* @return NS_SUCCESS if suceeds else NS_FAILURE
*/
2005-05-08 09:24:11 +00:00
int ModFini( void )
{
return NS_SUCCESS;
}
2005-05-22 20:08:09 +00:00
/** @brief blsb_set_exclusions_cb
*
* Set callback for exclusions
* Enable or disable exclude event flag
*
* @cmdparams pointer to commands param struct
* @cmdparams reason for SET
*
* @return NS_SUCCESS if suceeds else NS_FAILURE
*/
2005-10-13 22:40:14 +00:00
static int blsb_set_exclusions_cb( const CmdParams *cmdparams, SET_REASON reason )
2005-05-22 20:08:09 +00:00
{
if( reason == SET_LOAD || reason == SET_CHANGE )
{
SetAllEventFlags( EVENT_FLAG_USE_EXCLUDE, blsb.exclusions );
}
return NS_SUCCESS;
}