2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007-2009 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2006-2009 Dennis Friis <peavey@inspircd.org>
7 * Copyright (C) 2006-2008 Craig Edwards <craigedwards@brainbox.cc>
8 * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
9 * Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
11 * This file is part of InspIRCd. InspIRCd is free software: you can
12 * redistribute it and/or modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation, version 2.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "exitcodes.h"
29 #include "configparser.h"
32 ServerLimits::ServerLimits(ConfigTag* tag)
33 : NickMax(tag->getInt("maxnick", 30))
34 , ChanMax(tag->getInt("maxchan", 64))
35 , MaxModes(tag->getInt("maxmodes", 20))
36 , IdentMax(tag->getInt("maxident", 10))
37 , MaxQuit(tag->getInt("maxquit", 255))
38 , MaxTopic(tag->getInt("maxtopic", 307))
39 , MaxKick(tag->getInt("maxkick", 255))
40 , MaxGecos(tag->getInt("maxgecos", 128))
41 , MaxAway(tag->getInt("maxaway", 200))
42 , MaxLine(tag->getInt("maxline", 512))
43 , MaxHost(tag->getInt("maxhost", 64))
47 ServerConfig::ServerPaths::ServerPaths(ConfigTag* tag)
48 : Config(tag->getString("configdir", INSPIRCD_CONFIG_PATH))
49 , Data(tag->getString("datadir", INSPIRCD_DATA_PATH))
50 , Log(tag->getString("logdir", INSPIRCD_LOG_PATH))
51 , Module(tag->getString("moduledir", INSPIRCD_MODULE_PATH))
55 static ConfigTag* CreateEmptyTag()
58 return ConfigTag::create("empty", "<auto>", 0, items);
61 ServerConfig::ServerConfig()
62 : EmptyTag(CreateEmptyTag())
65 , NoSnoticeStack(false)
67 RawLog = HideBans = HideSplits = false;
70 NetBufferSize = 10240;
78 ServerConfig::~ServerConfig()
83 static void ValidHost(const std::string& p, const std::string& msg)
86 if (p.empty() || p[0] == '.')
87 throw CoreException("The value of "+msg+" is not a valid hostname");
88 for (unsigned int i=0;i < p.length();i++)
93 throw CoreException("The value of "+msg+" is not a valid hostname");
100 throw CoreException("The value of "+msg+" is not a valid hostname");
103 bool ServerConfig::ApplyDisabledCommands(const std::string& data)
105 std::stringstream dcmds(data);
108 /* Enable everything first */
109 const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
110 for (CommandParser::CommandMap::const_iterator x = commands.begin(); x != commands.end(); ++x)
111 x->second->Disable(false);
113 /* Now disable all the ones which the user wants disabled */
114 while (dcmds >> thiscmd)
116 Command* handler = ServerInstance->Parser.GetHandler(thiscmd);
118 handler->Disable(true);
123 static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make)
125 ConfigTagList tags = conf->ConfTags(tag);
126 for(ConfigIter i = tags.first; i != tags.second; ++i)
128 ConfigTag* ctag = i->second;
130 if (!ctag->readString(key, mask))
131 throw CoreException("<"+tag+":"+key+"> missing at " + ctag->getTagLocation());
132 std::string reason = ctag->getString("reason", "<Config>");
133 XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask);
134 if (!ServerInstance->XLines->AddLine(xl, NULL))
139 typedef std::map<std::string, ConfigTag*> LocalIndex;
140 void ServerConfig::CrossCheckOperClassType()
142 LocalIndex operclass;
143 ConfigTagList tags = ConfTags("class");
144 for(ConfigIter i = tags.first; i != tags.second; ++i)
146 ConfigTag* tag = i->second;
147 std::string name = tag->getString("name");
149 throw CoreException("<class:name> missing from tag at " + tag->getTagLocation());
150 if (operclass.find(name) != operclass.end())
151 throw CoreException("Duplicate class block with name " + name + " at " + tag->getTagLocation());
152 operclass[name] = tag;
154 tags = ConfTags("type");
155 for(ConfigIter i = tags.first; i != tags.second; ++i)
157 ConfigTag* tag = i->second;
158 std::string name = tag->getString("name");
160 throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
161 if (OperTypes.find(name) != OperTypes.end())
162 throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
164 OperInfo* ifo = new OperInfo;
165 OperTypes[name] = ifo;
167 ifo->type_block = tag;
169 std::string classname;
170 irc::spacesepstream str(tag->getString("classes"));
171 while (str.GetToken(classname))
173 LocalIndex::iterator cls = operclass.find(classname);
174 if (cls == operclass.end())
175 throw CoreException("Oper type " + name + " has missing class " + classname);
176 ifo->class_blocks.push_back(cls->second);
180 tags = ConfTags("oper");
181 for(ConfigIter i = tags.first; i != tags.second; ++i)
183 ConfigTag* tag = i->second;
185 std::string name = tag->getString("name");
187 throw CoreException("<oper:name> missing from tag at " + tag->getTagLocation());
189 std::string type = tag->getString("type");
190 OperIndex::iterator tblk = OperTypes.find(type);
191 if (tblk == OperTypes.end())
192 throw CoreException("Oper block " + name + " has missing type " + type);
193 if (oper_blocks.find(name) != oper_blocks.end())
194 throw CoreException("Duplicate oper block with name " + name + " at " + tag->getTagLocation());
196 OperInfo* ifo = new OperInfo;
198 ifo->oper_block = tag;
199 ifo->type_block = tblk->second->type_block;
200 ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end());
201 oper_blocks[name] = ifo;
205 void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
207 typedef std::map<std::string, ConnectClass*> ClassMap;
208 ClassMap oldBlocksByMask;
211 for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i)
213 ConnectClass* c = *i;
214 if (c->name.compare(0, 8, "unnamed-", 8))
216 oldBlocksByMask["n" + c->name] = c;
218 else if (c->type == CC_ALLOW || c->type == CC_DENY)
220 std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d";
222 oldBlocksByMask[typeMask] = c;
227 int blk_count = config_data.count("connect");
230 // No connect blocks found; make a trivial default block
232 ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
233 (*items)["allow"] = "*";
234 config_data.insert(std::make_pair("connect", tag));
238 Classes.resize(blk_count);
239 std::map<std::string, int> names;
241 bool try_again = true;
242 for(int tries=0; try_again; tries++)
245 ConfigTagList tags = ConfTags("connect");
247 for(ConfigIter it = tags.first; it != tags.second; ++it, ++i)
249 ConfigTag* tag = it->second;
253 ConnectClass* parent = NULL;
254 std::string parentName = tag->getString("parent");
255 if (!parentName.empty())
257 std::map<std::string,int>::iterator parentIter = names.find(parentName);
258 if (parentIter == names.end())
261 // couldn't find parent this time. If it's the last time, we'll never find it.
262 if (tries >= blk_count)
263 throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation());
266 parent = Classes[parentIter->second];
269 std::string name = tag->getString("name");
270 std::string mask, typeMask;
273 if (tag->readString("allow", mask, false))
276 typeMask = 'a' + mask;
278 else if (tag->readString("deny", mask, false))
281 typeMask = 'd' + mask;
283 else if (!name.empty())
287 typeMask = 'n' + mask;
291 throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation());
296 name = "unnamed-" + ConvToStr(i);
300 typeMask = 'n' + name;
303 if (names.find(name) != names.end())
304 throw CoreException("Two connect classes with name \"" + name + "\" defined!");
307 ConnectClass* me = parent ?
308 new ConnectClass(tag, type, mask, *parent) :
309 new ConnectClass(tag, type, mask);
313 me->registration_timeout = tag->getDuration("timeout", me->registration_timeout);
314 me->pingtime = tag->getDuration("pingfreq", me->pingtime);
316 if (tag->readString("sendq", sendq))
318 // attempt to guess a good hard/soft sendq from a single value
319 long value = atol(sendq.c_str());
321 me->softsendqmax = value / 16;
323 me->softsendqmax = value;
324 me->hardsendqmax = value * 8;
326 me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
327 me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
328 me->recvqmax = tag->getInt("recvq", me->recvqmax);
329 me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
330 me->commandrate = tag->getInt("commandrate", me->commandrate);
331 me->fakelag = tag->getBool("fakelag", me->fakelag);
332 me->maxlocal = tag->getInt("localmax", me->maxlocal);
333 me->maxglobal = tag->getInt("globalmax", me->maxglobal);
334 me->maxchans = tag->getInt("maxchans", me->maxchans);
335 me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
336 me->limit = tag->getInt("limit", me->limit);
337 me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
339 std::string ports = tag->getString("port");
342 irc::portparser portrange(ports, false);
343 while (int port = portrange.GetToken())
344 me->ports.insert(port);
347 ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
348 if (oldMask != oldBlocksByMask.end())
350 ConnectClass* old = oldMask->second;
351 oldBlocksByMask.erase(oldMask);
361 /** Represents a deprecated configuration tag.
363 struct DeprecatedConfig
368 /** Attribute key. */
371 /** Attribute value. */
374 /** Reason for deprecation. */
378 static const DeprecatedConfig ChangedConfig[] = {
379 { "bind", "transport", "", "has been moved to <bind:ssl> as of 2.0" },
380 { "die", "value", "", "you need to reread your config" },
381 { "gnutls", "starttls", "", "has been replaced with m_starttls as of 3.0" },
382 { "link", "autoconnect", "", "2.0+ does not use this attribute - define <autoconnect> tags instead" },
383 { "link", "transport", "", "has been moved to <link:ssl> as of 2.0" },
384 { "module", "name", "m_chanprotect.so", "has been replaced with m_customprefix as of 3.0" },
385 { "module", "name", "m_halfop.so", "has been replaced with m_customprefix as of 3.0" },
386 { "options", "cyclehosts", "", "has been replaced with m_hostcycle as of 3.0" },
387 { "performance", "nouserdns", "", "has been moved to <connect:resolvehostnames> as of 3.0" }
390 void ServerConfig::Fill()
392 ConfigTag* options = ConfValue("options");
393 ConfigTag* security = ConfValue("security");
394 ConfigTag* server = ConfValue("server");
397 ServerName = server->getString("name", "irc.example.com");
398 ValidHost(ServerName, "<server:name>");
400 sid = server->getString("id");
401 if (!sid.empty() && !InspIRCd::IsSID(sid))
402 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.");
404 CaseMapping = options->getString("casemapping", "rfc1459");
405 if (CaseMapping == "ascii")
406 national_case_insensitive_map = ascii_case_insensitive_map;
407 else if (CaseMapping == "rfc1459")
408 national_case_insensitive_map = rfc_case_insensitive_map;
410 throw CoreException("<options:casemapping> must be set to 'ascii', or 'rfc1459'");
414 std::string name = server->getString("name");
415 if (!name.empty() && name != ServerName)
416 throw CoreException("You must restart to change the server name");
418 std::string nsid = server->getString("id");
419 if (!nsid.empty() && nsid != sid)
420 throw CoreException("You must restart to change the server id");
422 std::string casemapping = options->getString("casemapping");
423 if (!casemapping.empty() && casemapping != CaseMapping)
424 throw CoreException("You must restart to change the server casemapping");
427 SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10);
428 CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
429 MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
430 XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
431 ServerDesc = server->getString("description", "Configure Me");
432 Network = server->getString("network", "Network");
433 NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
434 DisabledCommands = ConfValue("disabled")->getString("commands", "");
435 DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
436 UserStats = security->getString("userstats");
437 CustomVersion = security->getString("customversion");
438 HideSplits = security->getBool("hidesplits");
439 HideBans = security->getBool("hidebans");
440 HideWhoisServer = security->getString("hidewhois");
441 HideKillsServer = security->getString("hidekills");
442 HideULineKills = security->getBool("hideulinekills");
443 RestrictBannedUsers = security->getBool("restrictbannedusers", true);
444 GenericOper = security->getBool("genericoper");
445 SyntaxHints = options->getBool("syntaxhints");
446 CycleHostsFromUser = options->getBool("cyclehostsfromuser");
447 FullHostInTopic = options->getBool("hostintopic");
448 MaxTargets = security->getInt("maxtargets", 20, 1, 31);
449 DefaultModes = options->getString("defaultmodes", "not");
450 PID = ConfValue("pid")->getString("file");
451 MaxChans = ConfValue("channels")->getInt("users", 20);
452 OperMaxChans = ConfValue("channels")->getInt("opers");
453 c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
454 c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
455 Limits = ServerLimits(ConfValue("limits"));
456 Paths = ServerPaths(ConfValue("path"));
457 NoSnoticeStack = options->getBool("nosnoticestack", false);
459 if (Network.find(' ') != std::string::npos)
460 throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
462 std::string defbind = options->getString("defaultbind");
463 if (stdalgo::string::equalsci(defbind, "ipv4"))
465 WildcardIPv6 = false;
467 else if (stdalgo::string::equalsci(defbind, "ipv6"))
474 int socktest = socket(AF_INET6, SOCK_STREAM, 0);
476 WildcardIPv6 = false;
478 SocketEngine::Close(socktest);
481 ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
482 ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
483 ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
484 ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
486 DisabledUModes.reset();
487 std::string modes = ConfValue("disabled")->getString("usermodes");
488 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
490 // Complain when the character is not a valid mode character.
491 if (!ModeParser::IsModeChar(*p))
492 throw CoreException("Invalid usermode " + std::string(1, *p) + " was found.");
493 DisabledUModes.set(*p - 'A');
496 DisabledCModes.reset();
497 modes = ConfValue("disabled")->getString("chanmodes");
498 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
500 if (!ModeParser::IsModeChar(*p))
501 throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
502 DisabledCModes.set(*p - 'A');
505 std::string v = security->getString("announceinvites");
508 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
510 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
511 else if (v == "dynamic")
512 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC;
514 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
516 v = security->getString("operspywhois");
518 OperSpyWhois = SPYWHOIS_SPLITMSG;
519 else if (v == "on" || v == "yes")
520 OperSpyWhois = SPYWHOIS_SINGLEMSG;
522 OperSpyWhois = SPYWHOIS_NONE;
525 // WARNING: it is not safe to use most of the codebase in this function, as it
526 // will run in the config reader thread
527 void ServerConfig::Read()
529 /* Load and parse the config file, if there are any errors then explode */
531 ParseStack stack(this);
534 valid = stack.ParseFile(ServerInstance->ConfigFileName, 0);
536 catch (CoreException& err)
539 errstr << err.GetReason() << std::endl;
543 void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
549 * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
551 this->CaseMapping = old->CaseMapping;
552 this->ServerName = old->ServerName;
553 this->sid = old->sid;
554 this->cmdline = old->cmdline;
557 /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
560 for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++)
563 ConfigTagList tags = ConfTags(ChangedConfig[index].tag);
564 for(ConfigIter i = tags.first; i != tags.second; ++i)
566 if (i->second->readString(ChangedConfig[index].key, value, true)
567 && (ChangedConfig[index].value.empty() || value == ChangedConfig[index].value))
569 errstr << "Your configuration contains a deprecated value: <" << ChangedConfig[index].tag;
570 if (ChangedConfig[index].value.empty())
572 errstr << ':' << ChangedConfig[index].key;
576 errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\"";
578 errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")" << std::endl;
585 // Handle special items
586 CrossCheckOperClassType();
587 CrossCheckConnectBlocks(old);
589 catch (CoreException &ce)
591 errstr << ce.GetReason() << std::endl;
594 // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
595 valid = errstr.str().empty();
597 // write once here, to try it out and make sure its ok
599 ServerInstance->WritePID(this->PID, !old);
601 ConfigTagList binds = ConfTags("bind");
602 if (binds.first == binds.second)
603 errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
604 << "You will need to do this if you want clients to be able to connect!" << std::endl;
608 // On first run, ports are bound later on
610 ServerInstance->BindPorts(pl);
613 errstr << "Not all your client ports could be bound." << std::endl
614 << "The following port(s) failed to bind:" << std::endl;
617 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
619 errstr << j << ".\tAddress: " << i->first.str() << "\tReason: " << strerror(i->second) << std::endl;
624 User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
628 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "There were errors in your configuration file:");
632 while (errstr.good())
635 getline(errstr, line, '\n');
638 // On startup, print out to console (still attached at this point)
640 std::cout << line << std::endl;
641 // If a user is rehashing, tell them directly
643 user->WriteRemoteNotice(InspIRCd::Format("*** %s", line.c_str()));
645 ServerInstance->SNO->WriteGlobalSno('a', line);
649 errstr.str(std::string());
651 // Re-parse our MOTD and RULES files for colors -- Justasic
652 for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
654 ConfigTag *tag = (*it)->config;
655 // Make sure our connection class allows motd colors
656 if(!tag->getBool("allowmotdcolors"))
659 ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
660 if (file != this->Files.end())
661 InspIRCd::ProcessColors(file->second);
664 /* No old configuration -> initial boot, nothing more to do here */
669 ServerInstance->Exit(EXIT_STATUS_CONFIG);
676 // If there were errors processing configuration, don't touch modules.
683 user->WriteRemoteNotice("*** Successfully rehashed server.");
684 ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
687 void ServerConfig::ApplyModules(User* user)
689 std::vector<std::string> added_modules;
690 ModuleManager::ModuleMap removed_modules = ServerInstance->Modules->GetModules();
692 ConfigTagList tags = ConfTags("module");
693 for(ConfigIter i = tags.first; i != tags.second; ++i)
695 ConfigTag* tag = i->second;
697 if (tag->readString("name", name))
699 name = ModuleManager::ExpandModName(name);
700 // if this module is already loaded, the erase will succeed, so we need do nothing
701 // otherwise, we need to add the module (which will be done later)
702 if (removed_modules.erase(name) == 0)
703 added_modules.push_back(name);
707 for (ModuleManager::ModuleMap::iterator i = removed_modules.begin(); i != removed_modules.end(); ++i)
709 const std::string& modname = i->first;
710 // Don't remove core_*.so, just remove m_*.so
711 if (InspIRCd::Match(modname, "core_*.so", ascii_case_insensitive_map))
713 if (ServerInstance->Modules->Unload(i->second))
715 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
718 user->WriteNumeric(RPL_UNLOADEDMODULE, modname, InspIRCd::Format("Module %s successfully unloaded.", modname.c_str()));
720 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
725 user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, InspIRCd::Format("Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str()));
727 ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
731 for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
733 if (ServerInstance->Modules->Load(*adding))
735 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
737 user->WriteNumeric(RPL_LOADEDMODULE, *adding, InspIRCd::Format("Module %s successfully loaded.", adding->c_str()));
739 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
744 user->WriteNumeric(ERR_CANTLOADMODULE, *adding, InspIRCd::Format("Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()));
746 ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
751 ConfigTag* ServerConfig::ConfValue(const std::string &tag)
753 ConfigTagList found = config_data.equal_range(tag);
754 if (found.first == found.second)
756 ConfigTag* rv = found.first->second;
758 if (found.first != found.second)
759 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used "
760 "(first at " + rv->getTagLocation() + "; second at " + found.first->second->getTagLocation() + ")");
764 ConfigTagList ServerConfig::ConfTags(const std::string& tag)
766 return config_data.equal_range(tag);
769 std::string ServerConfig::Escape(const std::string& str, bool xml)
772 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
777 escaped += xml ? """ : "\"";
780 escaped += xml ? "&" : "&";
783 escaped += xml ? "\\" : "\\\\";
793 void ConfigReaderThread::Run()
799 void ConfigReaderThread::Finish()
801 ServerConfig* old = ServerInstance->Config;
802 ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Switching to new configuration...");
803 ServerInstance->Config = this->Config;
804 Config->Apply(old, TheUserUID);
809 * Apply the changed configuration from the rehash.
811 * XXX: The order of these is IMPORTANT, do not reorder them without testing
814 ServerInstance->Users.RehashCloneCounts();
815 ServerInstance->XLines->CheckELines();
816 ServerInstance->XLines->ApplyLines();
817 ChanModeReference ban(NULL, "ban");
818 static_cast<ListModeBase*>(*ban)->DoRehash();
819 Config->ApplyDisabledCommands(Config->DisabledCommands);
820 User* user = ServerInstance->FindNick(TheUserUID);
822 ConfigStatus status(user);
823 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
824 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
825 i->second->ReadConfig(status);
827 // The description of this server may have changed - update it for WHOIS etc.
828 ServerInstance->FakeClient->server->description = Config->ServerDesc;
830 ServerInstance->ISupport.Build();
832 ServerInstance->Logs->CloseLogs();
833 ServerInstance->Logs->OpenFileLogs();
835 if (Config->RawLog && !old->RawLog)
836 ServerInstance->Users->ServerNoticeAll("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
843 ServerInstance->Config = old;