void ReadConfig(ConfigStatus& status) override { ConfigTag* tag = ServerInstance->Config->ConfValue("rline"); MatchOnNickChange = tag->getBool("matchonnickchange"); ZlineOnMatch = tag->getBool("zlineonmatch"); std::string newrxengine = tag->getString("engine"); factory = rxfactory ? (rxfactory.operator->()) : NULL; if (newrxengine.empty()) rxfactory.SetProvider("regex"); else rxfactory.SetProvider("regex/" + newrxengine); if (!rxfactory) { if (newrxengine.empty()) ServerInstance->SNO.WriteToSnoMask('a', "WARNING: No regex engine loaded - R-line functionality disabled until this is corrected."); else ServerInstance->SNO.WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-line functionality disabled until this is corrected.", newrxengine.c_str()); ServerInstance->XLines->DelAll(f.GetType()); } else if ((!initing) && (rxfactory.operator->() != factory)) { ServerInstance->SNO.WriteToSnoMask('a', "Regex engine has changed, removing all R-lines."); ServerInstance->XLines->DelAll(f.GetType()); } initing = false; }
FilterResult(dynamic_reference<RegexFactory>& RegexEngine, const std::string& free, const std::string& rea, FilterAction act, long gt, const std::string& fla) : freeform(free), reason(rea), action(act), gline_time(gt) { if (!RegexEngine) throw ModuleException("Regex module implementing '"+RegexEngine.GetProvider()+"' is not loaded!"); regex = RegexEngine->Create(free); this->FillFlags(fla); }
void OnRehash(User* user) { ConfigTag* conf = ServerInstance->Config->ConfValue("sqlauth"); std::string dbid = conf->getString("dbid"); if (dbid.empty()) SQL.SetProvider("SQL"); else SQL.SetProvider("SQL/" + dbid); freeformquery = conf->getString("query"); killreason = conf->getString("killreason"); allowpattern = conf->getString("allowpattern"); verbose = conf->getBool("verbose"); }
ModResult OnUserRegister(LocalUser* user) { // Note this is their initial (unresolved) connect block ConfigTag* tag = user->MyClass->config; if (!tag->getBool("usesqlauth", true)) return MOD_RES_PASSTHRU; if (!allowpattern.empty() && InspIRCd::Match(user->nick,allowpattern)) return MOD_RES_PASSTHRU; if (pendingExt.get(user)) return MOD_RES_PASSTHRU; if (!SQL) { ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s (SQL database not present)", user->GetFullRealHost().c_str()); ServerInstance->Users->QuitUser(user, killreason); return MOD_RES_PASSTHRU; } pendingExt.set(user, AUTH_STATE_BUSY); ParamM userinfo; SQL->PopulateUserInfo(user, userinfo); userinfo["pass"] = user->password; HashProvider* md5 = ServerInstance->Modules->FindDataService<HashProvider>("hash/md5"); if (md5) userinfo["md5pass"] = md5->hexsum(user->password); HashProvider* sha256 = ServerInstance->Modules->FindDataService<HashProvider>("hash/sha256"); if (sha256) userinfo["sha256pass"] = sha256->hexsum(user->password); AuthQuery* authQuery = NULL; if (usebcrypt) { authQuery = new BCryptAuthQuery(this, user->uuid, user->password, pendingExt, verbose); } else { authQuery = new AuthQuery(this, user->uuid, pendingExt, verbose); } SQL->submit(authQuery, freeformquery, userinfo); return MOD_RES_PASSTHRU; }
/** Create a R-line. * @param s_time The set time * @param d The duration of the xline * @param src The sender of the xline * @param re The reason of the xline * @param regex Pattern to match with * @ */ RLine(time_t s_time, unsigned long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference<RegexFactory>& rxfactory) : XLine(s_time, d, src, re, "R") , matchtext(regexs) { /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time */ regex = rxfactory->Create(regexs); }
/** * 2.0-style cloaking function * @param item The item to cloak (part of an IP or hostname) * @param id A unique ID for this type of item (to make it unique if the item matches) * @param len The length of the output. Maximum for MD5 is 16 characters. */ std::string SegmentCloak(const std::string& item, char id, int len) { std::string input; input.reserve(key.length() + 3 + item.length()); input.append(1, id); input.append(key); input.append(1, '\0'); // null does not terminate a C++ string input.append(item); std::string rv = Hash->sum(input).substr(0,len); for(int i=0; i < len; i++) { // this discards 3 bits per byte. We have an // overabundance of bits in the hash output, doesn't // matter which ones we are discarding. rv[i] = base32[rv[i] & 0x1F]; } return rv; }