void modulerehash() { int i; sstring **mods; array *autoloads; if (moddir!=NULL) freesstring(moddir); if (modsuffix!=NULL) freesstring(modsuffix); clearmoduledeps(); moddir=getcopyconfigitem("core","moduledir",".",100); modsuffix=getcopyconfigitem("core","modulesuffix",".so",5); initmoduledeps(); /* Check for auto-load modules */ autoloads=getconfigitems("core","loadmodule"); if (autoloads!=NULL) { mods=(sstring **)(autoloads->content); for (i=0;i<autoloads->cursi;i++) { insmod(mods[i]->content); } } }
void _init() { lua_setupdebugsocket(); lua_initnickpusher(); lua_initchanpusher(); dummy.name = getsstring("???", 10); if(!dummy.name) { Error("lua", ERR_ERROR, "Cannot set dummy name."); return; } cpath = getcopyconfigitem("lua", "scriptdir", "", 500); if(!cpath || !cpath->content || !cpath->content[0]) { Error("lua", ERR_ERROR, "Error loading path."); return; } suffix = getcopyconfigitem("lua", "scriptsuffix", ".lua", 10); if(!suffix) { Error("lua", ERR_ERROR, "Error loading suffix."); return; } lua_setpath(); loaded = 1; startsched = scheduleoneshot(time(NULL) + 1, &lua_startup, NULL); }
void lua_startbot(void *arg) { channel *cp; myureconnect = NULL; if(!luabotnick) luabotnick = getcopyconfigitem("lua", "botnick", "U", NICKLEN); lua_nick = registerlocaluser(luabotnick->content, "lua", "quakenet.department.of.corrections", LUA_FULLVERSION, "U", UMODE_ACCOUNT | UMODE_DEAF | UMODE_OPER | UMODE_SERVICE, &lua_bothandler); if(!lua_nick) { myureconnect = scheduleoneshot(time(NULL) + 1, &lua_startbot, NULL); return; } cp = findchannel(LUA_OPERCHAN); if(cp && localjoinchannel(lua_nick, cp)) { localgetops(lua_nick, cp); } else { localcreatechannel(lua_nick, LUA_OPERCHAN); } cp = findchannel(LUA_PUKECHAN); if(cp && localjoinchannel(lua_nick, cp)) { localgetops(lua_nick, cp); } else { localcreatechannel(lua_nick, LUA_PUKECHAN); } myublip = schedulerecurring(time(NULL) + 1, 0, 60, &lua_blip, NULL); myutick = schedulerecurring(time(NULL) + 1, 0, 1, &lua_tick, NULL); lua_registerevents(); }
void _init(void) { char buf[32]; sstring *m; snprintf(buf, sizeof(buf), "%d", PATROL_MINIMUM_HOSTS_BEFORE_POOL); m = getcopyconfigitem("patrol", "minpoolhosts", buf, 32); patrol_min_hosts = atoi(m->content); freesstring(m); scheduleoneshot(time(NULL) + 5, &patrol_sched_repool, NULL); }
void chanservcryptoinit(void) { int ret; FILE *e = fopen(ENTROPYSOURCE, "rb"); if(!e) { Error("chanserv",ERR_STOP,"Unable to open entropy source."); /* shouldn't be running now... */ } ret = fread(rng.randrsl, 1, sizeof(rng.randrsl), e); fclose(e); if(ret != sizeof(rng.randrsl)) { Error("chanserv",ERR_STOP,"Unable to read entropy."); /* shouldn't be running now... */ } prnginit(&rng, 1); secret=getcopyconfigitem("chanserv","secret","",128); if(!secret || !secret->content || !secret->content[0]) { unsigned char buf[32]; char hexbuf[sizeof(buf) * 2 + 1]; freesstring(secret); Error("chanserv",ERR_WARNING,"Shared secret not set, generating a random string..."); cs_getrandbytes(buf, 32); hmac_printhex(buf, hexbuf, sizeof(buf)); secret=getsstring(hexbuf, strlen(hexbuf)); } codesecret=combinesecret("codegenerator"); ticketsecret=getcopyconfigitem("chanserv","ticketsecret","",256); if(!ticketsecret || !ticketsecret->content[0]) { Error("chanserv",ERR_WARNING,"Ticket secret not set, ticketauth disabled."); freesstring(ticketsecret); ticketsecret = NULL; } }
void relayfinishinit(int hooknum, void *arg) { sstring *s; deregisterhook(HOOK_CHANSERV_DBLOADED, relayfinishinit); registercontrolhelpcmd("checkhashpass", NO_RELAY, 3, csa_docheckhashpass, "Usage: checkhashpass <username> <digest> ?junk?"); registercontrolhelpcmd("settempemail", NO_RELAY, 2, csa_dosettempemail, "Usage: settempemail <userid> <email address>"); registercontrolhelpcmd("setemail", NO_RELAY, 3, csa_dosetemail, "Usage: setmail <userid> <timestamp> <email address>"); registercontrolhelpcmd("resendemail", NO_RELAY, 1, csa_doresendemail, "Usage: resendemail <userid>"); registercontrolhelpcmd("activateuser", NO_RELAY, 1, csa_doactivateuser, "Usage: activateuser <userid>"); registercontrolhelpcmd("addchan", NO_RELAY, 3, csa_doaddchan, "Usage: addchan <channel> <userid> <channel type>"); s=getcopyconfigitem("chanserv","createaccountsecret","",128); if(!s || !s->content || !s->content[0]) { Error("chanserv_relay",ERR_WARNING,"createaccountsecret not set, createaccount disabled."); } else if(s->length != KEY_BITS / 8 * 2 || !hex_to_int(s->content, createaccountsecret, sizeof(createaccountsecret))) { Error("chanserv_relay",ERR_WARNING,"createaccountsecret must be a %d character hex string.", KEY_BITS / 8 * 2); } else { registercontrolhelpcmd("createaccount", NO_RELAY, 5, csa_docreateaccount, "Usage: createaccount <execute> <username> <email address> <encrypted password> <activate user>"); createaccountsecret_ok = 1; } freesstring(s); }