void ReadConfig(ConfigStatus& status) override { ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois"); sw.SetOperOnly(tag->getBool("opersonly", true)); ShowWhoisFromOpers = tag->getBool("showfromopers", true); }
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; }
void OnRehash(User*) { ConfigTag* tag = ServerInstance->Config->ConfValue("invisible"); hidejoin = tag->getBool("join"); hidelist = tag->getBool("list"); hidewho = tag->getBool("who"); hidemsg = tag->getBool("msg"); }
void OnRehash(User* user) { ConfigTag* tag = ServerInstance->Config->ConfValue("override"); activetime = ServerInstance->Duration(tag->getString("umodeexpire", "10m")); expiremsg = tag->getString("expiremsg"); snoonexpire = tag->getBool("snoonexpire"); snoonset = tag->getBool("snoonset", true); snoonunset = tag->getBool("snoonunset"); }
void init() override { ConfigTagList tags = ServerInstance->Config->ConfTags("customprefix"); for (ConfigIter iter = tags.first; iter != tags.second; ++iter) { ConfigTag* tag = iter->second; const std::string name = tag->getString("name"); if (name.empty()) throw ModuleException("<customprefix:name> must be specified at " + tag->getTagLocation()); if (tag->getBool("change")) { ModeHandler* mh = ServerInstance->Modes.FindMode(name, MODETYPE_CHANNEL); if (!mh) throw ModuleException("<customprefix:change> specified for a non-existent mode at " + tag->getTagLocation()); PrefixMode* pm = mh->IsPrefixMode(); if (!pm) throw ModuleException("<customprefix:change> specified for a non-prefix mode at " + tag->getTagLocation()); unsigned long rank = tag->getUInt("rank", pm->GetPrefixRank(), 0, UINT_MAX); unsigned long setrank = tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, UINT_MAX); unsigned long unsetrank = tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, UINT_MAX); bool depriv = tag->getBool("depriv", pm->CanSelfRemove()); pm->Update(rank, setrank, unsetrank, depriv); ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Changed the %s prefix: depriv=%u rank=%u ranktoset=%u ranktounset=%u", pm->name.c_str(), pm->CanSelfRemove(), pm->GetPrefixRank(), pm->GetLevelRequired(true), pm->GetLevelRequired(false)); continue; } const std::string letter = tag->getString("letter"); if (letter.length() != 1) throw ModuleException("<customprefix:letter> must be set to a mode character at " + tag->getTagLocation()); const std::string prefix = tag->getString("prefix"); if (prefix.length() != 1) throw ModuleException("<customprefix:prefix> must be set to a mode prefix at " + tag->getTagLocation()); try { CustomPrefixMode* mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag); modes.push_back(mh); ServerInstance->Modules.AddService(*mh); } catch (ModuleException& e) { throw ModuleException(e.GetReason() + " (while creating mode from " + tag->getTagLocation() + ")"); } } }
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"); usebcrypt = conf->getBool("usebcrypt"); }
bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user) { long matches = 0; ConfigTag* insane = Config->ConfValue("insane"); if (insane->getBool("nickmasks")) return false; float itrigger = insane->getFloat("trigger", 95.5); for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { if (InspIRCd::Match(u->second->nick, nick)) matches++; } if (!matches) return false; float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > itrigger) { SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),nick.c_str(),percent); return true; } return false; }
void OnRehash(User* user) { ConfigTag* Conf = ServerInstance->Config->ConfValue("ojoin"); if (!np) { // This is done on module load only std::string npre = Conf->getString("prefix"); NPrefix = npre.empty() ? 0 : npre[0]; if (NPrefix && ServerInstance->Modes->FindPrefix(NPrefix)) throw ModuleException("Looks like the +Y prefix you picked for m_ojoin is already in use. Pick another."); } notice = Conf->getBool("notice", true); op = Conf->getBool("op", true); }
ModResult OnUserRegister(LocalUser* user) { ConfigTag* tag = user->MyClass->config; if (tag->getBool("requirectcp", true)) { if (!ctcp.empty()) { user->WriteServ("PRIVMSG %s :\001%s\001", user->nick.c_str(), ctcp.c_str()); } ext.set(user, 1); } return MOD_RES_PASSTHRU; }
virtual void OnRehash(User* user) { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); std::string cmds = tag->getString("enabledcommands"); std::transform(cmds.begin(), cmds.end(), cmds.begin(), ::toupper); if (cmds.empty()) cmds = "PING PONG QUIT"; ShunEnabledCommands.clear(); std::stringstream dcmds(cmds); std::string thiscmd; while (dcmds >> thiscmd) { ShunEnabledCommands.insert(thiscmd); } NotifyOfShun = tag->getBool("notifyuser", true); affectopers = tag->getBool("affectopers", false); }
void ReadConfig(ConfigStatus& status) override { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); std::string cmds = tag->getString("enabledcommands"); std::transform(cmds.begin(), cmds.end(), cmds.begin(), ::toupper); if (cmds.empty()) cmds = "PING PONG QUIT"; ShunEnabledCommands.clear(); irc::spacesepstream dcmds(cmds); std::string thiscmd; while (dcmds.GetToken(thiscmd)) { ShunEnabledCommands.insert(thiscmd); } NotifyOfShun = tag->getBool("notifyuser", true); affectopers = tag->getBool("affectopers", false); }
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; }
void OnUserInit(LocalUser *user) { ConfigTag* tag = user->MyClass->config; if (!tag->getBool("useident", true)) return; user->WriteServ("NOTICE Auth :*** Looking up your ident..."); try { IdentRequestSocket *isock = new IdentRequestSocket(IS_LOCAL(user)); ext.set(user, isock); } catch (ModuleException &e) { ServerInstance->Logs->Log("m_ident",DEBUG,"Ident exception: %s", e.GetReason()); } }
void OnRehash(User *user) { ConfigTag *tag = ServerInstance->Config->ConfValue("telegraf"); silent = tag->getBool("silent"); reconnectTimeout = tag->getInt("reconnect", 60); int new_port = tag->getInt("port"); if (port != new_port) { if (tSock) { StopMetrics(); } port = new_port; if (port > 0 && port < 65536) { StartMetrics(); } } }
void ReadConfig(ConfigStatus& status) override { // TODO: Multiple SNI profiles ConfigTag* tag = ServerInstance->Config->ConfValue("sts"); if (tag == ServerInstance->Config->EmptyTag) throw ModuleException("You must define a STS policy!"); const std::string host = tag->getString("host"); if (host.empty()) throw ModuleException("<sts:host> must contain a hostname, at " + tag->getTagLocation()); unsigned int port = tag->getUInt("port", 0, 0, UINT16_MAX); if (!HasValidSSLPort(port)) throw ModuleException("<sts:port> must be a TLS port, at " + tag->getTagLocation()); unsigned long duration = tag->getDuration("duration", 60*60*24*30*2); bool preload = tag->getBool("preload"); cap.SetPolicy(host, duration, port, preload); }
void ReadConfig(ConfigStatus& status) override { AllowList newallows; ConfigTagList tags = ServerInstance->Config->ConfTags("securehost"); for (ConfigIter i = tags.first; i != tags.second; ++i) { std::string host = i->second->getString("exception"); if (host.empty()) throw ModuleException("<securehost:exception> is a required field at " + i->second->getTagLocation()); newallows.push_back(host); } ConfigTag* tag = ServerInstance->Config->ConfValue("securelist"); exemptregistered = tag->getBool("exemptregistered"); WaitTime = tag->getDuration("waittime", 60, 1); allowlist.swap(newallows); }
bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey) { ConfigTag* insane = ServerInstance->Config->ConfValue("insane"); if (insane->getBool(confkey)) return false; float itrigger = insane->getFloat("trigger", 95.5); long matches = test.Run(mask); if (!matches) return false; float percent = ((float)matches / (float)ServerInstance->Users->GetUsers().size()) * 100; if (percent > itrigger) { ServerInstance->SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a %s-line mask of %s, which covers %.2f%% of the network!", user->nick.c_str(), bantype, mask.c_str(), percent); return true; } return false; }
void TreeServer::CheckULine() { uline = silentuline = false; ConfigTagList tags = ServerInstance->Config->ConfTags("uline"); for (ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; std::string server = tag->getString("server"); if (!strcasecmp(server.c_str(), GetName().c_str())) { if (this->IsRoot()) { ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Servers should not uline themselves (at " + tag->getTagLocation() + ")"); return; } uline = true; silentuline = tag->getBool("silent"); break; } } }
void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); if (sid.empty()) { ServerName = ConfValue("server")->getString("name"); sid = ConfValue("server")->getString("id"); ValidHost(ServerName, "<server:name>"); if (!sid.empty() && !InspIRCd::IsSID(sid)) throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter."); } else { if (ServerName != ConfValue("server")->getString("name")) throw CoreException("You must restart to change the server name or SID"); std::string nsid = ConfValue("server")->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server name or SID"); } diepass = ConfValue("power")->getString("diepass"); restartpass = ConfValue("power")->getString("restartpass"); powerhash = ConfValue("power")->getString("hash"); PrefixQuit = options->getString("prefixquit"); SuffixQuit = options->getString("suffixquit"); FixedQuit = options->getString("fixedquit"); PrefixPart = options->getString("prefixpart"); SuffixPart = options->getString("suffixpart"); FixedPart = options->getString("fixedpart"); SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds()); MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN); MoronBanner = options->getString("moronbanner", "You're banned!"); ServerDesc = ConfValue("server")->getString("description", "Configure Me"); Network = ConfValue("server")->getString("network", "Network"); AdminName = ConfValue("admin")->getString("name", ""); AdminEmail = ConfValue("admin")->getString("email", "*****@*****.**"); AdminNick = ConfValue("admin")->getString("nick", "admin"); ModPath = ConfValue("path")->getString("moduledir", MOD_PATH); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240); dns_timeout = ConfValue("dns")->getInt("timeout", 5); DisabledCommands = ConfValue("disabled")->getString("commands", ""); DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant"); UserStats = security->getString("userstats"); CustomVersion = security->getString("customversion", Network + " IRCd"); HideSplits = security->getBool("hidesplits"); HideBans = security->getBool("hidebans"); HideWhoisServer = security->getString("hidewhois"); HideKillsServer = security->getString("hidekills"); RestrictBannedUsers = security->getBool("restrictbannedusers", true); GenericOper = security->getBool("genericoper"); SyntaxHints = options->getBool("syntaxhints"); CycleHosts = options->getBool("cyclehosts"); CycleHostsFromUser = options->getBool("cyclehostsfromuser"); UndernetMsgPrefix = options->getBool("ircumsgprefix"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getInt("maxtargets", 20); DefaultModes = options->getString("defaultmodes", "nt"); PID = ConfValue("pid")->getString("file"); MaxChans = ConfValue("channels")->getInt("users", 20); OperMaxChans = ConfValue("channels")->getInt("opers", 60); c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32); c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128); Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32); Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64); Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20); Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11); Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255); Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307); Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255); Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128); Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200); InvBypassModes = options->getBool("invitebypassmodes", true); NoSnoticeStack = options->getBool("nosnoticestack", false); range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>"); if (ConfValue("performance")->getBool("limitsomaxconn", true)) range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>"); range(MaxTargets, 1, 31, 20, "<security:maxtargets>"); range(NetBufferSize, 1024, 65534, 10240, "<performance:netbuffersize>"); std::string defbind = options->getString("defaultbind"); if (assign(defbind) == "ipv4") { WildcardIPv6 = false; } else if (assign(defbind) == "ipv6") { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else ServerInstance->SE->Close(socktest); } ConfigTagList tags = ConfTags("uline"); for(ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; std::string server; if (!tag->readString("server", server)) throw CoreException("<uline> tag missing server at " + tag->getTagLocation()); ulines[assign(server)] = tag->getBool("silent"); } ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z")); ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q")); ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K")); ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E")); memset(DisabledUModes, 0, sizeof(DisabledUModes)); std::string modes = ConfValue("disabled")->getString("usermodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { // Complain when the character is not a-z or A-Z if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid usermode " + std::string(1, *p) + " was found."); DisabledUModes[*p - 'A'] = 1; } memset(DisabledCModes, 0, sizeof(DisabledCModes)); modes = ConfValue("disabled")->getString("chanmodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found."); DisabledCModes[*p - 'A'] = 1; } memset(HideModeLists, 0, sizeof(HideModeLists)); modes = ConfValue("security")->getString("hidemodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) HideModeLists[(unsigned char) *p] = true; std::string v = security->getString("announceinvites"); if (v == "ops") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS; else if (v == "all") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL; else if (v == "dynamic") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC; else AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE; v = security->getString("operspywhois"); if (v == "splitmsg") OperSpyWhois = SPYWHOIS_SPLITMSG; else if (v == "on" || v == "yes") OperSpyWhois = SPYWHOIS_SINGLEMSG; else OperSpyWhois = SPYWHOIS_NONE; }
void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) { typedef std::map<std::string, ConnectClass*> ClassMap; ClassMap oldBlocksByMask; if (current) { for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i) { ConnectClass* c = *i; if (c->name.substr(0, 8) != "unnamed-") { oldBlocksByMask["n" + c->name] = c; } else if (c->type == CC_ALLOW || c->type == CC_DENY) { std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d"; typeMask += c->host; oldBlocksByMask[typeMask] = c; } } } int blk_count = config_data.count("connect"); if (blk_count == 0) { // No connect blocks found; make a trivial default block std::vector<KeyVal>* items; ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items); items->push_back(std::make_pair("allow", "*")); config_data.insert(std::make_pair("connect", tag)); blk_count = 1; } Classes.resize(blk_count); std::map<std::string, int> names; bool try_again = true; for(int tries=0; try_again; tries++) { try_again = false; ConfigTagList tags = ConfTags("connect"); int i=0; for(ConfigIter it = tags.first; it != tags.second; ++it, ++i) { ConfigTag* tag = it->second; if (Classes[i]) continue; ConnectClass* parent = NULL; std::string parentName = tag->getString("parent"); if (!parentName.empty()) { std::map<std::string,int>::iterator parentIter = names.find(parentName); if (parentIter == names.end()) { try_again = true; // couldn't find parent this time. If it's the last time, we'll never find it. if (tries >= blk_count) throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation()); continue; } parent = Classes[parentIter->second]; } std::string name = tag->getString("name"); std::string mask, typeMask; char type; if (tag->readString("allow", mask, false)) { type = CC_ALLOW; typeMask = 'a' + mask; } else if (tag->readString("deny", mask, false)) { type = CC_DENY; typeMask = 'd' + mask; } else if (!name.empty()) { type = CC_NAMED; mask = name; typeMask = 'n' + mask; } else { throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation()); } if (name.empty()) { name = "unnamed-" + ConvToStr(i); } else { typeMask = 'n' + name; } if (names.find(name) != names.end()) throw CoreException("Two connect classes with name \"" + name + "\" defined!"); names[name] = i; ConnectClass* me = parent ? new ConnectClass(tag, type, mask, *parent) : new ConnectClass(tag, type, mask); me->name = name; me->registration_timeout = tag->getInt("timeout", me->registration_timeout); me->pingtime = tag->getInt("pingfreq", me->pingtime); std::string sendq; if (tag->readString("sendq", sendq)) { // attempt to guess a good hard/soft sendq from a single value long value = atol(sendq.c_str()); if (value > 16384) me->softsendqmax = value / 16; else me->softsendqmax = value; me->hardsendqmax = value * 8; } me->softsendqmax = tag->getInt("softsendq", me->softsendqmax); me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax); me->recvqmax = tag->getInt("recvq", me->recvqmax); me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold); me->commandrate = tag->getInt("commandrate", me->commandrate); me->fakelag = tag->getBool("fakelag", me->fakelag); me->maxlocal = tag->getInt("localmax", me->maxlocal); me->maxglobal = tag->getInt("globalmax", me->maxglobal); me->maxchans = tag->getInt("maxchans", me->maxchans); me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn); me->limit = tag->getInt("limit", me->limit); me->nouserdns = tag->getBool("nouserdns", me->nouserdns); ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask); if (oldMask != oldBlocksByMask.end()) { ConnectClass* old = oldMask->second; oldBlocksByMask.erase(oldMask); old->Update(me); delete me; me = old; } Classes[i] = me; } } }
void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); ConfigTag* server = ConfValue("server"); if (sid.empty()) { ServerName = server->getString("name", "irc.example.com", InspIRCd::IsHost); sid = server->getString("id"); if (!sid.empty() && !InspIRCd::IsSID(sid)) throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter."); } else { std::string name = server->getString("name"); if (!name.empty() && name != ServerName) throw CoreException("You must restart to change the server name"); std::string nsid = server->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server id"); } SoftLimit = ConfValue("performance")->getUInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); MaxConn = ConfValue("performance")->getUInt("somaxconn", SOMAXCONN); TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30); XLineMessage = options->getString("xlinemessage", "You're banned!"); ServerDesc = server->getString("description", "Configure Me"); Network = server->getString("network", "Network"); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534); CustomVersion = security->getString("customversion"); HideBans = security->getBool("hidebans"); HideServer = security->getString("hideserver"); SyntaxHints = options->getBool("syntaxhints"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getUInt("maxtargets", 20, 1, 31); DefaultModes = options->getString("defaultmodes", "not"); PID = ConfValue("pid")->getString("file"); c_ipv4_range = ConfValue("cidr")->getUInt("ipv4clone", 32, 1, 32); c_ipv6_range = ConfValue("cidr")->getUInt("ipv6clone", 128, 1, 128); Limits = ServerLimits(ConfValue("limits")); Paths = ServerPaths(ConfValue("path")); NoSnoticeStack = options->getBool("nosnoticestack", false); std::string defbind = options->getString("defaultbind"); if (stdalgo::string::equalsci(defbind, "ipv4")) { WildcardIPv6 = false; } else if (stdalgo::string::equalsci(defbind, "ipv6")) { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else SocketEngine::Close(socktest); } ServerInstance->XLines->ClearConfigLines(); ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z")); ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q")); ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K")); ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E")); const std::string restrictbannedusers = options->getString("restrictbannedusers", "yes"); if (stdalgo::string::equalsci(restrictbannedusers, "no")) RestrictBannedUsers = ServerConfig::BUT_NORMAL; else if (stdalgo::string::equalsci(restrictbannedusers, "silent")) RestrictBannedUsers = ServerConfig::BUT_RESTRICT_SILENT; else if (stdalgo::string::equalsci(restrictbannedusers, "yes")) RestrictBannedUsers = ServerConfig::BUT_RESTRICT_NOTIFY; else throw CoreException(restrictbannedusers + " is an invalid <options:restrictbannedusers> value, at " + options->getTagLocation()); }
void OnRehash(User* user) { ConfigTag* tag = ServerInstance->Config->ConfValue("waitpong"); sendsnotice = tag->getBool("sendsnotice", true); killonbadreply = tag->getBool("killonbadreply", true); }
void SpanningTreeUtilities::ReadConfiguration() { ConfigTag* security = ServerInstance->Config->ConfValue("security"); ConfigTag* options = ServerInstance->Config->ConfValue("options"); FlatLinks = security->getBool("flatlinks"); HideULines = security->getBool("hideulines"); AnnounceTSChange = options->getBool("announcets"); AllowOptCommon = options->getBool("allowmismatch"); ChallengeResponse = !security->getBool("disablehmac"); quiet_bursts = ServerInstance->Config->ConfValue("performance")->getBool("quietbursts"); PingWarnTime = options->getInt("pingwarning"); PingFreq = options->getInt("serverpingfreq"); if (PingFreq == 0) PingFreq = 60; if (PingWarnTime < 0 || PingWarnTime > PingFreq - 1) PingWarnTime = 0; AutoconnectBlocks.clear(); LinkBlocks.clear(); ConfigTagList tags = ServerInstance->Config->ConfTags("link"); for(ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; reference<Link> L = new Link(tag); std::string linkname = tag->getString("name"); L->Name = linkname.c_str(); irc::spacesepstream sep = tag->getString("allowmask"); for (std::string s; sep.GetToken(s);) L->AllowMasks.push_back(s); L->IPAddr = tag->getString("ipaddr"); L->Port = tag->getInt("port"); L->SendPass = tag->getString("sendpass", tag->getString("password")); L->RecvPass = tag->getString("recvpass", tag->getString("password")); L->Fingerprint = tag->getString("fingerprint"); L->HiddenFromStats = tag->getBool("statshidden"); L->Timeout = tag->getDuration("timeout", 30); L->Hook = tag->getString("ssl"); L->Bind = tag->getString("bind"); L->Hidden = tag->getBool("hidden"); if (L->Name.empty()) throw ModuleException("Invalid configuration, found a link tag without a name!" + (!L->IPAddr.empty() ? " IP address: "+L->IPAddr : "")); if (L->Name.find('.') == std::string::npos) throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it must contain at least one '.' character"); if (L->Name.length() > 64) throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than 64 characters"); if (L->RecvPass.empty()) throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', recvpass not defined"); if (L->SendPass.empty()) throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', sendpass not defined"); if ((L->SendPass.find(' ') != std::string::npos) || (L->RecvPass.find(' ') != std::string::npos)) throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that contains a space character which is invalid"); if ((L->SendPass[0] == ':') || (L->RecvPass[0] == ':')) throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that begins with a colon (:) which is invalid"); if (L->IPAddr.empty()) { L->IPAddr = "*"; ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want."); } if (!L->Port) ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no port defined, you will not be able to /connect it."); L->Fingerprint.erase(std::remove(L->Fingerprint.begin(), L->Fingerprint.end(), ':'), L->Fingerprint.end()); LinkBlocks.push_back(L); } tags = ServerInstance->Config->ConfTags("autoconnect"); for(ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; reference<Autoconnect> A = new Autoconnect(tag); A->Period = tag->getDuration("period", 60, 1); A->NextConnectTime = ServerInstance->Time() + A->Period; A->position = -1; irc::spacesepstream ss(tag->getString("server")); std::string server; while (ss.GetToken(server)) { A->servers.push_back(server); } if (A->servers.empty()) { throw ModuleException("Invalid configuration for autoconnect, server cannot be empty!"); } AutoconnectBlocks.push_back(A); } for (server_hash::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i) i->second->CheckULine(); RefreshIPCache(); }
void ReadConfig(ConfigStatus&) override { ConfigTag* tag = ServerInstance->Config->ConfValue("geoip"); extban = tag->getBool("extban"); }
void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) { valid = true; if (old) { /* * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername. */ this->ServerName = old->ServerName; this->sid = old->sid; this->cmdline = old->cmdline; } /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */ try { for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++) { std::string value; ConfigTagList tags = ConfTags(ChangedConfig[index].tag); for(ConfigIter i = tags.first; i != tags.second; ++i) { if (i->second->readString(ChangedConfig[index].key, value, true) && (ChangedConfig[index].value.empty() || value == ChangedConfig[index].value)) { errstr << "Your configuration contains a deprecated value: <" << ChangedConfig[index].tag; if (ChangedConfig[index].value.empty()) { errstr << ':' << ChangedConfig[index].key; } else { errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\""; } errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")\n"; } } } Fill(); // Handle special items CrossCheckOperClassType(); CrossCheckConnectBlocks(old); } catch (CoreException &ce) { errstr << ce.GetReason(); } // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances. valid = errstr.str().empty(); // write once here, to try it out and make sure its ok if (valid) ServerInstance->WritePID(this->PID); if (old) { // On first run, ports are bound later on FailedPortList pl; ServerInstance->BindPorts(pl); if (pl.size()) { errstr << "Not all your client ports could be bound.\nThe following port(s) failed to bind:\n"; int j = 1; for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++) { char buf[MAXBUF]; snprintf(buf, MAXBUF, "%d. Address: %s Reason: %s\n", j, i->first.empty() ? "<all>" : i->first.c_str(), i->second.c_str()); errstr << buf; } } } User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid); if (!valid) ServerInstance->Logs->Log("CONFIG",LOG_DEFAULT, "There were errors in your configuration file:"); while (errstr.good()) { std::string line; getline(errstr, line, '\n'); if (line.empty()) continue; // On startup, print out to console (still attached at this point) if (!old) std::cout << line << std::endl; // If a user is rehashing, tell them directly if (user) user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str()); // Also tell opers ServerInstance->SNO->WriteGlobalSno('a', line); } errstr.clear(); errstr.str(std::string()); // Re-parse our MOTD and RULES files for colors -- Justasic for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it) { ConfigTag *tag = (*it)->config; // Make sure our connection class allows motd colors if(!tag->getBool("allowmotdcolors")) continue; ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd")); if (file != this->Files.end()) InspIRCd::ProcessColors(file->second); file = this->Files.find(tag->getString("rules", "rules")); if (file != this->Files.end()) InspIRCd::ProcessColors(file->second); } /* No old configuration -> initial boot, nothing more to do here */ if (!old) { if (!valid) { ServerInstance->Exit(EXIT_STATUS_CONFIG); } return; } // If there were errors processing configuration, don't touch modules. if (!valid) return; ApplyModules(user); if (user) user->SendText(":%s NOTICE %s :*** Successfully rehashed server.", ServerInstance->Config->ServerName.c_str(), user->nick.c_str()); ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server."); }
void ReadConfig(ConfigStatus& status) override { ConfigTag* tag = ServerInstance->Config->ConfValue("remove"); supportnokicks = tag->getBool("supportnokicks"); cmd1.protectedrank = cmd2.protectedrank = tag->getUInt("protectedrank", 50000); }
void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); if (sid.empty()) { ServerName = ConfValue("server")->getString("name", "irc.example.com"); ValidHost(ServerName, "<server:name>"); sid = ConfValue("server")->getString("id"); if (!sid.empty() && !InspIRCd::IsSID(sid)) throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter."); } else { if (ServerName != ConfValue("server")->getString("name")) throw CoreException("You must restart to change the server name"); std::string nsid = ConfValue("server")->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server id"); } SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN); XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!")); ServerDesc = ConfValue("server")->getString("description", "Configure Me"); Network = ConfValue("server")->getString("network", "Network"); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534); dns_timeout = ConfValue("dns")->getInt("timeout", 5); DisabledCommands = ConfValue("disabled")->getString("commands", ""); DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant"); UserStats = security->getString("userstats"); CustomVersion = security->getString("customversion"); HideSplits = security->getBool("hidesplits"); HideBans = security->getBool("hidebans"); HideWhoisServer = security->getString("hidewhois"); HideKillsServer = security->getString("hidekills"); RestrictBannedUsers = security->getBool("restrictbannedusers", true); GenericOper = security->getBool("genericoper"); SyntaxHints = options->getBool("syntaxhints"); CycleHostsFromUser = options->getBool("cyclehostsfromuser"); UndernetMsgPrefix = options->getBool("ircumsgprefix"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getInt("maxtargets", 20, 1, 31); DefaultModes = options->getString("defaultmodes", "not"); PID = ConfValue("pid")->getString("file"); MaxChans = ConfValue("channels")->getInt("users", 20); OperMaxChans = ConfValue("channels")->getInt("opers"); c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32); c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128); Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32); Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64); Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20); Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11); Limits.MaxHost = ConfValue("limits")->getInt("maxhost", 64); Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255); Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307); Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255); Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128); Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200); Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512); Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH); Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH); Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH); Paths.Module = ConfValue("path")->getString("moduledir", INSPIRCD_MODULE_PATH); InvBypassModes = options->getBool("invitebypassmodes", true); NoSnoticeStack = options->getBool("nosnoticestack", false); if (Network.find(' ') != std::string::npos) throw CoreException(Network + " is not a valid network name. A network name must not contain spaces."); std::string defbind = options->getString("defaultbind"); if (assign(defbind) == "ipv4") { WildcardIPv6 = false; } else if (assign(defbind) == "ipv6") { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else SocketEngine::Close(socktest); } ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z")); ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q")); ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K")); ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E")); memset(DisabledUModes, 0, sizeof(DisabledUModes)); std::string modes = ConfValue("disabled")->getString("usermodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { // Complain when the character is not a-z or A-Z if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid usermode " + std::string(1, *p) + " was found."); DisabledUModes[*p - 'A'] = 1; } memset(DisabledCModes, 0, sizeof(DisabledCModes)); modes = ConfValue("disabled")->getString("chanmodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found."); DisabledCModes[*p - 'A'] = 1; } memset(HideModeLists, 0, sizeof(HideModeLists)); modes = ConfValue("security")->getString("hidemodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) HideModeLists[(unsigned char) *p] = true; std::string v = security->getString("announceinvites"); if (v == "ops") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS; else if (v == "all") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL; else if (v == "dynamic") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC; else AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE; v = security->getString("operspywhois"); if (v == "splitmsg") OperSpyWhois = SPYWHOIS_SPLITMSG; else if (v == "on" || v == "yes") OperSpyWhois = SPYWHOIS_SINGLEMSG; else OperSpyWhois = SPYWHOIS_NONE; }
void OnRehash(User*) { ConfigTag* tag = ServerInstance->Config->ConfValue("nocreate"); telluser = tag->getBool("telluser", false); noisy = tag->getBool("noisy", true); }
virtual void OnRehash(User* user) { ConfigTag* conftag = ServerInstance->Config->ConfValue("antirandom"); this->ShowFailedConnects = conftag->getBool("showfailedconnects", true); this->DebugMode = conftag->getBool("debugmode"); this->Threshold = conftag->getInt("threshold", 10); // Sanity checks if (this->Threshold < 1) this->Threshold = 1; if (this->Threshold >= 100) this->Threshold = 100; this->BanAction = ANTIRANDOM_ACT_NONE; std::string tmp = conftag->getString("banaction"); if (tmp == "GLINE") { this->BanAction = ANTIRANDOM_ACT_GLINE; } if (tmp == "ZLINE") { this->BanAction = ANTIRANDOM_ACT_ZLINE; } else if (tmp == "KILL") { this->BanAction = ANTIRANDOM_ACT_KILL; } tmp = conftag->getString("banduration"); if (!tmp.empty()) { this->BanDuration = ServerInstance->Duration(tmp.c_str()); // Sanity check if ((int)this->BanDuration <= 0) this->BanDuration = 1; } else this->BanDuration = 86400; // One day. tmp = conftag->getString("banreason"); if (!tmp.empty()) this->BanReason = tmp; else this->BanReason = "You look like a bot. Change your nick/ident/gecos and try reconnecting."; Exempts.clear(); ConfigTagList exempts_list = ServerInstance->Config->ConfTags("antirandomexempt"); for (ConfigIter i = exempts_list.first; i != exempts_list.second; ++i) { ConfigTag* tag = i->second; std::string type = tag->getString("type"); std::string pattern = tag->getString("pattern"); if(pattern.length() && type.length()) { AntirandomExemptType exemptType; if (type == "nick") exemptType = NICK; else if (type == "ident") exemptType = IDENT; else if (type == "host") exemptType = HOST; else if (type == "fullname") exemptType = FULLNAME; else { ServerInstance->SNO->WriteGlobalSno('a', "m_antirandom: Invalid <antirandomexempt:type> value in config: %s", type.c_str()); ServerInstance->Logs->Log("CONFIG",DEFAULT, "m_antirandom: Invalid <antirandomexempt:type> value in config: %s", type.c_str()); continue; } Exempts.push_back(AntirandomExempt(exemptType, pattern)); if (this->DebugMode) ServerInstance->SNO->WriteGlobalSno('a', "m_antirandom: Added exempt: %s (%s)", type.c_str(), pattern.c_str()); } else { ServerInstance->Logs->Log("CONFIG",DEFAULT, "m_antirandom: Invalid block <antirandomexempt type=\"%s\" pattern=\"%s\">", type.c_str(), pattern.c_str()); ServerInstance->SNO->WriteGlobalSno('a', "m_antirandom: Invalid block <antirandomexempt type=\"%s\" pattern=\"%s\">", type.c_str(), pattern.c_str()); continue; } } }