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 ServerConfig::ServerConfig()
34 RawLog = HideBans = HideSplits = UndernetMsgPrefix = false;
35 WildcardIPv6 = InvBypassModes = true;
38 NetBufferSize = 10240;
46 static void ValidHost(const std::string& p, const std::string& msg)
49 if (p.empty() || p[0] == '.')
50 throw CoreException("The value of "+msg+" is not a valid hostname");
51 for (unsigned int i=0;i < p.length();i++)
56 throw CoreException("The value of "+msg+" is not a valid hostname");
63 throw CoreException("The value of "+msg+" is not a valid hostname");
66 bool ServerConfig::ApplyDisabledCommands(const std::string& data)
68 std::stringstream dcmds(data);
71 /* Enable everything first */
72 for (Commandtable::iterator x = ServerInstance->Parser->cmdlist.begin(); x != ServerInstance->Parser->cmdlist.end(); x++)
73 x->second->Disable(false);
75 /* Now disable all the ones which the user wants disabled */
76 while (dcmds >> thiscmd)
78 Command* handler = ServerInstance->Parser->GetHandler(thiscmd);
80 handler->Disable(true);
85 static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make)
87 ConfigTagList tags = conf->ConfTags(tag);
88 for(ConfigIter i = tags.first; i != tags.second; ++i)
90 ConfigTag* ctag = i->second;
92 if (!ctag->readString(key, mask))
93 throw CoreException("<"+tag+":"+key+"> missing at " + ctag->getTagLocation());
94 std::string reason = ctag->getString("reason", "<Config>");
95 XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask);
96 if (!ServerInstance->XLines->AddLine(xl, NULL))
101 typedef std::map<std::string, ConfigTag*> LocalIndex;
102 void ServerConfig::CrossCheckOperClassType()
104 LocalIndex operclass;
105 ConfigTagList tags = ConfTags("class");
106 for(ConfigIter i = tags.first; i != tags.second; ++i)
108 ConfigTag* tag = i->second;
109 std::string name = tag->getString("name");
111 throw CoreException("<class:name> missing from tag at " + tag->getTagLocation());
112 if (operclass.find(name) != operclass.end())
113 throw CoreException("Duplicate class block with name " + name + " at " + tag->getTagLocation());
114 operclass[name] = tag;
116 tags = ConfTags("type");
117 for(ConfigIter i = tags.first; i != tags.second; ++i)
119 ConfigTag* tag = i->second;
120 std::string name = tag->getString("name");
122 throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
123 if (OperTypes.find(name) != OperTypes.end())
124 throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
126 OperInfo* ifo = new OperInfo;
127 OperTypes[name] = ifo;
129 ifo->type_block = tag;
131 std::string classname;
132 irc::spacesepstream str(tag->getString("classes"));
133 while (str.GetToken(classname))
135 LocalIndex::iterator cls = operclass.find(classname);
136 if (cls == operclass.end())
137 throw CoreException("Oper type " + name + " has missing class " + classname);
138 ifo->class_blocks.push_back(cls->second);
142 tags = ConfTags("oper");
143 for(ConfigIter i = tags.first; i != tags.second; ++i)
145 ConfigTag* tag = i->second;
147 std::string name = tag->getString("name");
149 throw CoreException("<oper:name> missing from tag at " + tag->getTagLocation());
151 std::string type = tag->getString("type");
152 OperIndex::iterator tblk = OperTypes.find(type);
153 if (tblk == OperTypes.end())
154 throw CoreException("Oper block " + name + " has missing type " + type);
155 if (oper_blocks.find(name) != oper_blocks.end())
156 throw CoreException("Duplicate oper block with name " + name + " at " + tag->getTagLocation());
158 OperInfo* ifo = new OperInfo;
160 ifo->oper_block = tag;
161 ifo->type_block = tblk->second->type_block;
162 ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end());
163 oper_blocks[name] = ifo;
167 void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
169 typedef std::map<std::string, ConnectClass*> ClassMap;
170 ClassMap oldBlocksByMask;
173 for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i)
175 ConnectClass* c = *i;
176 if (c->name.compare(0, 8, "unnamed-", 8))
178 oldBlocksByMask["n" + c->name] = c;
180 else if (c->type == CC_ALLOW || c->type == CC_DENY)
182 std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d";
184 oldBlocksByMask[typeMask] = c;
189 int blk_count = config_data.count("connect");
192 // No connect blocks found; make a trivial default block
193 std::vector<KeyVal>* items;
194 ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
195 items->push_back(std::make_pair("allow", "*"));
196 config_data.insert(std::make_pair("connect", tag));
200 Classes.resize(blk_count);
201 std::map<std::string, int> names;
203 bool try_again = true;
204 for(int tries=0; try_again; tries++)
207 ConfigTagList tags = ConfTags("connect");
209 for(ConfigIter it = tags.first; it != tags.second; ++it, ++i)
211 ConfigTag* tag = it->second;
215 ConnectClass* parent = NULL;
216 std::string parentName = tag->getString("parent");
217 if (!parentName.empty())
219 std::map<std::string,int>::iterator parentIter = names.find(parentName);
220 if (parentIter == names.end())
223 // couldn't find parent this time. If it's the last time, we'll never find it.
224 if (tries >= blk_count)
225 throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation());
228 parent = Classes[parentIter->second];
231 std::string name = tag->getString("name");
232 std::string mask, typeMask;
235 if (tag->readString("allow", mask, false))
238 typeMask = 'a' + mask;
240 else if (tag->readString("deny", mask, false))
243 typeMask = 'd' + mask;
245 else if (!name.empty())
249 typeMask = 'n' + mask;
253 throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation());
258 name = "unnamed-" + ConvToStr(i);
262 typeMask = 'n' + name;
265 if (names.find(name) != names.end())
266 throw CoreException("Two connect classes with name \"" + name + "\" defined!");
269 ConnectClass* me = parent ?
270 new ConnectClass(tag, type, mask, *parent) :
271 new ConnectClass(tag, type, mask);
275 me->registration_timeout = tag->getInt("timeout", me->registration_timeout);
276 me->pingtime = tag->getInt("pingfreq", me->pingtime);
278 if (tag->readString("sendq", sendq))
280 // attempt to guess a good hard/soft sendq from a single value
281 long value = atol(sendq.c_str());
283 me->softsendqmax = value / 16;
285 me->softsendqmax = value;
286 me->hardsendqmax = value * 8;
288 me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
289 me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
290 me->recvqmax = tag->getInt("recvq", me->recvqmax);
291 me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
292 me->commandrate = tag->getInt("commandrate", me->commandrate);
293 me->fakelag = tag->getBool("fakelag", me->fakelag);
294 me->maxlocal = tag->getInt("localmax", me->maxlocal);
295 me->maxglobal = tag->getInt("globalmax", me->maxglobal);
296 me->maxchans = tag->getInt("maxchans", me->maxchans);
297 me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
298 me->limit = tag->getInt("limit", me->limit);
299 me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
301 ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
302 if (oldMask != oldBlocksByMask.end())
304 ConnectClass* old = oldMask->second;
305 oldBlocksByMask.erase(oldMask);
315 /** Represents a deprecated configuration tag.
317 struct DeprecatedConfig
322 /** Attribute key. */
325 /** Attribute value. */
328 /** Reason for deprecation. */
332 static const DeprecatedConfig ChangedConfig[] = {
333 { "bind", "transport", "", "has been moved to <bind:ssl> as of 2.0" },
334 { "die", "value", "", "you need to reread your config" },
335 { "gnutls", "starttls", "", "has been replaced with m_starttls as of 2.2" },
336 { "link", "autoconnect", "", "2.0+ does not use this attribute - define <autoconnect> tags instead" },
337 { "link", "transport", "", "has been moved to <link:ssl> as of 2.0" },
338 { "module", "name", "m_chanprotect.so", "has been replaced with m_customprefix as of 2.2" },
339 { "module", "name", "m_halfop.so", "has been replaced with m_customprefix as of 2.2" },
340 { "options", "cyclehosts", "", "has been replaced with m_hostcycle as of 2.2" },
341 { "performance", "nouserdns", "", "has been moved to <connect:resolvehostnames> as of 2.2" }
344 void ServerConfig::Fill()
346 ConfigTag* options = ConfValue("options");
347 ConfigTag* security = ConfValue("security");
350 ServerName = ConfValue("server")->getString("name", "irc.example.com");
351 ValidHost(ServerName, "<server:name>");
353 sid = ConfValue("server")->getString("id");
354 if (!sid.empty() && !InspIRCd::IsSID(sid))
355 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.");
359 if (ServerName != ConfValue("server")->getString("name"))
360 throw CoreException("You must restart to change the server name");
362 std::string nsid = ConfValue("server")->getString("id");
363 if (!nsid.empty() && nsid != sid)
364 throw CoreException("You must restart to change the server id");
366 SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10);
367 CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
368 MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
369 XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
370 ServerDesc = ConfValue("server")->getString("description", "Configure Me");
371 Network = ConfValue("server")->getString("network", "Network");
372 NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
373 dns_timeout = ConfValue("dns")->getInt("timeout", 5);
374 DisabledCommands = ConfValue("disabled")->getString("commands", "");
375 DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
376 UserStats = security->getString("userstats");
377 CustomVersion = security->getString("customversion");
378 HideSplits = security->getBool("hidesplits");
379 HideBans = security->getBool("hidebans");
380 HideWhoisServer = security->getString("hidewhois");
381 HideKillsServer = security->getString("hidekills");
382 RestrictBannedUsers = security->getBool("restrictbannedusers", true);
383 GenericOper = security->getBool("genericoper");
384 SyntaxHints = options->getBool("syntaxhints");
385 CycleHostsFromUser = options->getBool("cyclehostsfromuser");
386 UndernetMsgPrefix = options->getBool("ircumsgprefix");
387 FullHostInTopic = options->getBool("hostintopic");
388 MaxTargets = security->getInt("maxtargets", 20, 1, 31);
389 DefaultModes = options->getString("defaultmodes", "not");
390 PID = ConfValue("pid")->getString("file");
391 MaxChans = ConfValue("channels")->getInt("users", 20);
392 OperMaxChans = ConfValue("channels")->getInt("opers");
393 c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
394 c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
395 Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32);
396 Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64);
397 Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20);
398 Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11);
399 Limits.MaxHost = ConfValue("limits")->getInt("maxhost", 64);
400 Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255);
401 Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307);
402 Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255);
403 Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128);
404 Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
405 Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512);
406 Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH);
407 Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH);
408 Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH);
409 Paths.Module = ConfValue("path")->getString("moduledir", INSPIRCD_MODULE_PATH);
410 InvBypassModes = options->getBool("invitebypassmodes", true);
411 NoSnoticeStack = options->getBool("nosnoticestack", false);
413 if (Network.find(' ') != std::string::npos)
414 throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
416 std::string defbind = options->getString("defaultbind");
417 if (assign(defbind) == "ipv4")
419 WildcardIPv6 = false;
421 else if (assign(defbind) == "ipv6")
428 int socktest = socket(AF_INET6, SOCK_STREAM, 0);
430 WildcardIPv6 = false;
432 SocketEngine::Close(socktest);
435 ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
436 ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
437 ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
438 ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
440 memset(DisabledUModes, 0, sizeof(DisabledUModes));
441 std::string modes = ConfValue("disabled")->getString("usermodes");
442 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
444 // Complain when the character is not a-z or A-Z
445 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
446 throw CoreException("Invalid usermode " + std::string(1, *p) + " was found.");
447 DisabledUModes[*p - 'A'] = 1;
450 memset(DisabledCModes, 0, sizeof(DisabledCModes));
451 modes = ConfValue("disabled")->getString("chanmodes");
452 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
454 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
455 throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
456 DisabledCModes[*p - 'A'] = 1;
459 memset(HideModeLists, 0, sizeof(HideModeLists));
460 modes = ConfValue("security")->getString("hidemodes");
461 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
462 HideModeLists[(unsigned char) *p] = true;
464 std::string v = security->getString("announceinvites");
467 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
469 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
470 else if (v == "dynamic")
471 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC;
473 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
475 v = security->getString("operspywhois");
477 OperSpyWhois = SPYWHOIS_SPLITMSG;
478 else if (v == "on" || v == "yes")
479 OperSpyWhois = SPYWHOIS_SINGLEMSG;
481 OperSpyWhois = SPYWHOIS_NONE;
484 // WARNING: it is not safe to use most of the codebase in this function, as it
485 // will run in the config reader thread
486 void ServerConfig::Read()
488 /* Load and parse the config file, if there are any errors then explode */
490 ParseStack stack(this);
493 valid = stack.ParseFile(ServerInstance->ConfigFileName, 0);
495 catch (CoreException& err)
498 errstr << err.GetReason() << std::endl;
502 void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
508 * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
510 this->ServerName = old->ServerName;
511 this->sid = old->sid;
512 this->cmdline = old->cmdline;
515 /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
518 for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++)
521 ConfigTagList tags = ConfTags(ChangedConfig[index].tag);
522 for(ConfigIter i = tags.first; i != tags.second; ++i)
524 if (i->second->readString(ChangedConfig[index].key, value, true)
525 && (ChangedConfig[index].value.empty() || value == ChangedConfig[index].value))
527 errstr << "Your configuration contains a deprecated value: <" << ChangedConfig[index].tag;
528 if (ChangedConfig[index].value.empty())
530 errstr << ':' << ChangedConfig[index].key;
534 errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\"";
536 errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")" << std::endl;
543 // Handle special items
544 CrossCheckOperClassType();
545 CrossCheckConnectBlocks(old);
547 catch (CoreException &ce)
549 errstr << ce.GetReason();
552 // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
553 valid = errstr.str().empty();
555 // write once here, to try it out and make sure its ok
557 ServerInstance->WritePID(this->PID);
559 ConfigTagList binds = ConfTags("bind");
560 if (binds.first == binds.second)
561 errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
562 << "You will need to do this if you want clients to be able to connect!" << std::endl;
566 // On first run, ports are bound later on
568 ServerInstance->BindPorts(pl);
571 errstr << "Not all your client ports could be bound." << std::endl
572 << "The following port(s) failed to bind:" << std::endl;
575 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
577 errstr << j << ".\tAddress: " << (i->first.empty() ? "<all>" : i->first.c_str()) << "\tReason: "
578 << i->second << std::endl;
583 User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
587 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "There were errors in your configuration file:");
591 while (errstr.good())
594 getline(errstr, line, '\n');
597 // On startup, print out to console (still attached at this point)
599 std::cout << line << std::endl;
600 // If a user is rehashing, tell them directly
602 user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
604 ServerInstance->SNO->WriteGlobalSno('a', line);
608 errstr.str(std::string());
610 // Re-parse our MOTD and RULES files for colors -- Justasic
611 for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
613 ConfigTag *tag = (*it)->config;
614 // Make sure our connection class allows motd colors
615 if(!tag->getBool("allowmotdcolors"))
618 ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
619 if (file != this->Files.end())
620 InspIRCd::ProcessColors(file->second);
623 /* No old configuration -> initial boot, nothing more to do here */
628 ServerInstance->Exit(EXIT_STATUS_CONFIG);
635 // If there were errors processing configuration, don't touch modules.
642 user->SendText(":%s NOTICE %s :*** Successfully rehashed server.",
643 ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
644 ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
647 void ServerConfig::ApplyModules(User* user)
649 std::vector<std::string> added_modules;
650 ModuleManager::ModuleMap removed_modules = ServerInstance->Modules->GetModules();
652 ConfigTagList tags = ConfTags("module");
653 for(ConfigIter i = tags.first; i != tags.second; ++i)
655 ConfigTag* tag = i->second;
657 if (tag->readString("name", name))
659 // if this module is already loaded, the erase will succeed, so we need do nothing
660 // otherwise, we need to add the module (which will be done later)
661 if (removed_modules.erase(name) == 0)
662 added_modules.push_back(name);
666 for (ModuleManager::ModuleMap::iterator i = removed_modules.begin(); i != removed_modules.end(); ++i)
668 const std::string& modname = i->first;
669 // Don't remove core_*.so, just remove m_*.so
670 if (modname.c_str()[0] == 'c')
672 if (ServerInstance->Modules->Unload(i->second))
674 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
677 user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str());
679 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
684 user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
686 ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
690 for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
692 if (ServerInstance->Modules->Load(adding->c_str()))
694 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
696 user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str());
698 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
703 user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
705 ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
710 ConfigTag* ServerConfig::ConfValue(const std::string &tag)
712 ConfigTagList found = config_data.equal_range(tag);
713 if (found.first == found.second)
715 ConfigTag* rv = found.first->second;
717 if (found.first != found.second)
718 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used "
719 "(first at " + rv->getTagLocation() + "; second at " + found.first->second->getTagLocation() + ")");
723 ConfigTagList ServerConfig::ConfTags(const std::string& tag)
725 return config_data.equal_range(tag);
728 std::string ServerConfig::Escape(const std::string& str, bool xml)
731 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
736 escaped += xml ? """ : "\"";
739 escaped += xml ? "&" : "&";
742 escaped += xml ? "\\" : "\\\\";
752 void ConfigReaderThread::Run()
758 void ConfigReaderThread::Finish()
760 ServerConfig* old = ServerInstance->Config;
761 ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Switching to new configuration...");
762 ServerInstance->Config = this->Config;
763 Config->Apply(old, TheUserUID);
768 * Apply the changed configuration from the rehash.
770 * XXX: The order of these is IMPORTANT, do not reorder them without testing
773 ServerInstance->XLines->CheckELines();
774 ServerInstance->XLines->ApplyLines();
775 ChanModeReference ban(NULL, "ban");
776 static_cast<ListModeBase*>(*ban)->DoRehash();
777 Config->ApplyDisabledCommands(Config->DisabledCommands);
778 User* user = ServerInstance->FindNick(TheUserUID);
780 ConfigStatus status(user);
781 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
782 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
783 i->second->ReadConfig(status);
785 ServerInstance->ISupport.Build();
787 ServerInstance->Logs->CloseLogs();
788 ServerInstance->Logs->OpenFileLogs();
790 if (Config->RawLog && !old->RawLog)
791 ServerInstance->Users->ServerNoticeAll("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
798 ServerInstance->Config = old;