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;
45 std::vector<KeyVal>* items;
46 EmptyTag = ConfigTag::create("empty", "<auto>", 0, items);
49 ServerConfig::~ServerConfig()
54 static void ValidHost(const std::string& p, const std::string& msg)
57 if (p.empty() || p[0] == '.')
58 throw CoreException("The value of "+msg+" is not a valid hostname");
59 for (unsigned int i=0;i < p.length();i++)
64 throw CoreException("The value of "+msg+" is not a valid hostname");
71 throw CoreException("The value of "+msg+" is not a valid hostname");
74 bool ServerConfig::ApplyDisabledCommands(const std::string& data)
76 std::stringstream dcmds(data);
79 /* Enable everything first */
80 const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
81 for (CommandParser::CommandMap::const_iterator x = commands.begin(); x != commands.end(); ++x)
82 x->second->Disable(false);
84 /* Now disable all the ones which the user wants disabled */
85 while (dcmds >> thiscmd)
87 Command* handler = ServerInstance->Parser.GetHandler(thiscmd);
89 handler->Disable(true);
94 static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make)
96 ConfigTagList tags = conf->ConfTags(tag);
97 for(ConfigIter i = tags.first; i != tags.second; ++i)
99 ConfigTag* ctag = i->second;
101 if (!ctag->readString(key, mask))
102 throw CoreException("<"+tag+":"+key+"> missing at " + ctag->getTagLocation());
103 std::string reason = ctag->getString("reason", "<Config>");
104 XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask);
105 if (!ServerInstance->XLines->AddLine(xl, NULL))
110 typedef std::map<std::string, ConfigTag*> LocalIndex;
111 void ServerConfig::CrossCheckOperClassType()
113 LocalIndex operclass;
114 ConfigTagList tags = ConfTags("class");
115 for(ConfigIter i = tags.first; i != tags.second; ++i)
117 ConfigTag* tag = i->second;
118 std::string name = tag->getString("name");
120 throw CoreException("<class:name> missing from tag at " + tag->getTagLocation());
121 if (operclass.find(name) != operclass.end())
122 throw CoreException("Duplicate class block with name " + name + " at " + tag->getTagLocation());
123 operclass[name] = tag;
125 tags = ConfTags("type");
126 for(ConfigIter i = tags.first; i != tags.second; ++i)
128 ConfigTag* tag = i->second;
129 std::string name = tag->getString("name");
131 throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
132 if (OperTypes.find(name) != OperTypes.end())
133 throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
135 OperInfo* ifo = new OperInfo;
136 OperTypes[name] = ifo;
138 ifo->type_block = tag;
140 std::string classname;
141 irc::spacesepstream str(tag->getString("classes"));
142 while (str.GetToken(classname))
144 LocalIndex::iterator cls = operclass.find(classname);
145 if (cls == operclass.end())
146 throw CoreException("Oper type " + name + " has missing class " + classname);
147 ifo->class_blocks.push_back(cls->second);
151 tags = ConfTags("oper");
152 for(ConfigIter i = tags.first; i != tags.second; ++i)
154 ConfigTag* tag = i->second;
156 std::string name = tag->getString("name");
158 throw CoreException("<oper:name> missing from tag at " + tag->getTagLocation());
160 std::string type = tag->getString("type");
161 OperIndex::iterator tblk = OperTypes.find(type);
162 if (tblk == OperTypes.end())
163 throw CoreException("Oper block " + name + " has missing type " + type);
164 if (oper_blocks.find(name) != oper_blocks.end())
165 throw CoreException("Duplicate oper block with name " + name + " at " + tag->getTagLocation());
167 OperInfo* ifo = new OperInfo;
169 ifo->oper_block = tag;
170 ifo->type_block = tblk->second->type_block;
171 ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end());
172 oper_blocks[name] = ifo;
176 void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
178 typedef std::map<std::string, ConnectClass*> ClassMap;
179 ClassMap oldBlocksByMask;
182 for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i)
184 ConnectClass* c = *i;
185 if (c->name.compare(0, 8, "unnamed-", 8))
187 oldBlocksByMask["n" + c->name] = c;
189 else if (c->type == CC_ALLOW || c->type == CC_DENY)
191 std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d";
193 oldBlocksByMask[typeMask] = c;
198 int blk_count = config_data.count("connect");
201 // No connect blocks found; make a trivial default block
202 std::vector<KeyVal>* items;
203 ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
204 items->push_back(std::make_pair("allow", "*"));
205 config_data.insert(std::make_pair("connect", tag));
209 Classes.resize(blk_count);
210 std::map<std::string, int> names;
212 bool try_again = true;
213 for(int tries=0; try_again; tries++)
216 ConfigTagList tags = ConfTags("connect");
218 for(ConfigIter it = tags.first; it != tags.second; ++it, ++i)
220 ConfigTag* tag = it->second;
224 ConnectClass* parent = NULL;
225 std::string parentName = tag->getString("parent");
226 if (!parentName.empty())
228 std::map<std::string,int>::iterator parentIter = names.find(parentName);
229 if (parentIter == names.end())
232 // couldn't find parent this time. If it's the last time, we'll never find it.
233 if (tries >= blk_count)
234 throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation());
237 parent = Classes[parentIter->second];
240 std::string name = tag->getString("name");
241 std::string mask, typeMask;
244 if (tag->readString("allow", mask, false))
247 typeMask = 'a' + mask;
249 else if (tag->readString("deny", mask, false))
252 typeMask = 'd' + mask;
254 else if (!name.empty())
258 typeMask = 'n' + mask;
262 throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation());
267 name = "unnamed-" + ConvToStr(i);
271 typeMask = 'n' + name;
274 if (names.find(name) != names.end())
275 throw CoreException("Two connect classes with name \"" + name + "\" defined!");
278 ConnectClass* me = parent ?
279 new ConnectClass(tag, type, mask, *parent) :
280 new ConnectClass(tag, type, mask);
284 me->registration_timeout = tag->getInt("timeout", me->registration_timeout);
285 me->pingtime = tag->getInt("pingfreq", me->pingtime);
287 if (tag->readString("sendq", sendq))
289 // attempt to guess a good hard/soft sendq from a single value
290 long value = atol(sendq.c_str());
292 me->softsendqmax = value / 16;
294 me->softsendqmax = value;
295 me->hardsendqmax = value * 8;
297 me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
298 me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
299 me->recvqmax = tag->getInt("recvq", me->recvqmax);
300 me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
301 me->commandrate = tag->getInt("commandrate", me->commandrate);
302 me->fakelag = tag->getBool("fakelag", me->fakelag);
303 me->maxlocal = tag->getInt("localmax", me->maxlocal);
304 me->maxglobal = tag->getInt("globalmax", me->maxglobal);
305 me->maxchans = tag->getInt("maxchans", me->maxchans);
306 me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
307 me->limit = tag->getInt("limit", me->limit);
308 me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
310 ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
311 if (oldMask != oldBlocksByMask.end())
313 ConnectClass* old = oldMask->second;
314 oldBlocksByMask.erase(oldMask);
324 /** Represents a deprecated configuration tag.
326 struct DeprecatedConfig
331 /** Attribute key. */
334 /** Attribute value. */
337 /** Reason for deprecation. */
341 static const DeprecatedConfig ChangedConfig[] = {
342 { "bind", "transport", "", "has been moved to <bind:ssl> as of 2.0" },
343 { "die", "value", "", "you need to reread your config" },
344 { "gnutls", "starttls", "", "has been replaced with m_starttls as of 2.2" },
345 { "link", "autoconnect", "", "2.0+ does not use this attribute - define <autoconnect> tags instead" },
346 { "link", "transport", "", "has been moved to <link:ssl> as of 2.0" },
347 { "module", "name", "m_chanprotect.so", "has been replaced with m_customprefix as of 2.2" },
348 { "module", "name", "m_halfop.so", "has been replaced with m_customprefix as of 2.2" },
349 { "options", "cyclehosts", "", "has been replaced with m_hostcycle as of 2.2" },
350 { "performance", "nouserdns", "", "has been moved to <connect:resolvehostnames> as of 2.2" }
353 void ServerConfig::Fill()
355 ConfigTag* options = ConfValue("options");
356 ConfigTag* security = ConfValue("security");
359 ServerName = ConfValue("server")->getString("name", "irc.example.com");
360 ValidHost(ServerName, "<server:name>");
362 sid = ConfValue("server")->getString("id");
363 if (!sid.empty() && !InspIRCd::IsSID(sid))
364 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.");
368 if (ServerName != ConfValue("server")->getString("name"))
369 throw CoreException("You must restart to change the server name");
371 std::string nsid = ConfValue("server")->getString("id");
372 if (!nsid.empty() && nsid != sid)
373 throw CoreException("You must restart to change the server id");
375 SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10);
376 CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
377 MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
378 XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
379 ServerDesc = ConfValue("server")->getString("description", "Configure Me");
380 Network = ConfValue("server")->getString("network", "Network");
381 NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
382 dns_timeout = ConfValue("dns")->getInt("timeout", 5);
383 DisabledCommands = ConfValue("disabled")->getString("commands", "");
384 DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
385 UserStats = security->getString("userstats");
386 CustomVersion = security->getString("customversion");
387 HideSplits = security->getBool("hidesplits");
388 HideBans = security->getBool("hidebans");
389 HideWhoisServer = security->getString("hidewhois");
390 HideKillsServer = security->getString("hidekills");
391 RestrictBannedUsers = security->getBool("restrictbannedusers", true);
392 GenericOper = security->getBool("genericoper");
393 SyntaxHints = options->getBool("syntaxhints");
394 CycleHostsFromUser = options->getBool("cyclehostsfromuser");
395 UndernetMsgPrefix = options->getBool("ircumsgprefix");
396 FullHostInTopic = options->getBool("hostintopic");
397 MaxTargets = security->getInt("maxtargets", 20, 1, 31);
398 DefaultModes = options->getString("defaultmodes", "not");
399 PID = ConfValue("pid")->getString("file");
400 MaxChans = ConfValue("channels")->getInt("users", 20);
401 OperMaxChans = ConfValue("channels")->getInt("opers");
402 c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
403 c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
404 Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32);
405 Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64);
406 Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20);
407 Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11);
408 Limits.MaxHost = ConfValue("limits")->getInt("maxhost", 64);
409 Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255);
410 Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307);
411 Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255);
412 Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128);
413 Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
414 Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512);
415 Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH);
416 Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH);
417 Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH);
418 Paths.Module = ConfValue("path")->getString("moduledir", INSPIRCD_MODULE_PATH);
419 InvBypassModes = options->getBool("invitebypassmodes", true);
420 NoSnoticeStack = options->getBool("nosnoticestack", false);
422 if (Network.find(' ') != std::string::npos)
423 throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
425 std::string defbind = options->getString("defaultbind");
426 if (assign(defbind) == "ipv4")
428 WildcardIPv6 = false;
430 else if (assign(defbind) == "ipv6")
437 int socktest = socket(AF_INET6, SOCK_STREAM, 0);
439 WildcardIPv6 = false;
441 SocketEngine::Close(socktest);
444 ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
445 ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
446 ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
447 ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
449 memset(DisabledUModes, 0, sizeof(DisabledUModes));
450 std::string modes = ConfValue("disabled")->getString("usermodes");
451 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
453 // Complain when the character is not a-z or A-Z
454 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
455 throw CoreException("Invalid usermode " + std::string(1, *p) + " was found.");
456 DisabledUModes[*p - 'A'] = 1;
459 memset(DisabledCModes, 0, sizeof(DisabledCModes));
460 modes = ConfValue("disabled")->getString("chanmodes");
461 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
463 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
464 throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
465 DisabledCModes[*p - 'A'] = 1;
468 std::string v = security->getString("announceinvites");
471 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
473 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
474 else if (v == "dynamic")
475 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC;
477 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
479 v = security->getString("operspywhois");
481 OperSpyWhois = SPYWHOIS_SPLITMSG;
482 else if (v == "on" || v == "yes")
483 OperSpyWhois = SPYWHOIS_SINGLEMSG;
485 OperSpyWhois = SPYWHOIS_NONE;
488 // WARNING: it is not safe to use most of the codebase in this function, as it
489 // will run in the config reader thread
490 void ServerConfig::Read()
492 /* Load and parse the config file, if there are any errors then explode */
494 ParseStack stack(this);
497 valid = stack.ParseFile(ServerInstance->ConfigFileName, 0);
499 catch (CoreException& err)
502 errstr << err.GetReason() << std::endl;
506 void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
512 * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
514 this->ServerName = old->ServerName;
515 this->sid = old->sid;
516 this->cmdline = old->cmdline;
519 /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
522 for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++)
525 ConfigTagList tags = ConfTags(ChangedConfig[index].tag);
526 for(ConfigIter i = tags.first; i != tags.second; ++i)
528 if (i->second->readString(ChangedConfig[index].key, value, true)
529 && (ChangedConfig[index].value.empty() || value == ChangedConfig[index].value))
531 errstr << "Your configuration contains a deprecated value: <" << ChangedConfig[index].tag;
532 if (ChangedConfig[index].value.empty())
534 errstr << ':' << ChangedConfig[index].key;
538 errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\"";
540 errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")" << std::endl;
547 // Handle special items
548 CrossCheckOperClassType();
549 CrossCheckConnectBlocks(old);
551 catch (CoreException &ce)
553 errstr << ce.GetReason();
556 // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
557 valid = errstr.str().empty();
559 // write once here, to try it out and make sure its ok
561 ServerInstance->WritePID(this->PID);
563 ConfigTagList binds = ConfTags("bind");
564 if (binds.first == binds.second)
565 errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
566 << "You will need to do this if you want clients to be able to connect!" << std::endl;
570 // On first run, ports are bound later on
572 ServerInstance->BindPorts(pl);
575 errstr << "Not all your client ports could be bound." << std::endl
576 << "The following port(s) failed to bind:" << std::endl;
579 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
581 errstr << j << ".\tAddress: " << (i->first.empty() ? "<all>" : i->first.c_str()) << "\tReason: "
582 << i->second << std::endl;
587 User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
591 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "There were errors in your configuration file:");
595 while (errstr.good())
598 getline(errstr, line, '\n');
601 // On startup, print out to console (still attached at this point)
603 std::cout << line << std::endl;
604 // If a user is rehashing, tell them directly
606 user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
608 ServerInstance->SNO->WriteGlobalSno('a', line);
612 errstr.str(std::string());
614 // Re-parse our MOTD and RULES files for colors -- Justasic
615 for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
617 ConfigTag *tag = (*it)->config;
618 // Make sure our connection class allows motd colors
619 if(!tag->getBool("allowmotdcolors"))
622 ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
623 if (file != this->Files.end())
624 InspIRCd::ProcessColors(file->second);
627 /* No old configuration -> initial boot, nothing more to do here */
632 ServerInstance->Exit(EXIT_STATUS_CONFIG);
639 // If there were errors processing configuration, don't touch modules.
646 user->SendText(":%s NOTICE %s :*** Successfully rehashed server.",
647 ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
648 ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
651 void ServerConfig::ApplyModules(User* user)
653 std::vector<std::string> added_modules;
654 ModuleManager::ModuleMap removed_modules = ServerInstance->Modules->GetModules();
656 ConfigTagList tags = ConfTags("module");
657 for(ConfigIter i = tags.first; i != tags.second; ++i)
659 ConfigTag* tag = i->second;
661 if (tag->readString("name", name))
663 // if this module is already loaded, the erase will succeed, so we need do nothing
664 // otherwise, we need to add the module (which will be done later)
665 if (removed_modules.erase(name) == 0)
666 added_modules.push_back(name);
670 for (ModuleManager::ModuleMap::iterator i = removed_modules.begin(); i != removed_modules.end(); ++i)
672 const std::string& modname = i->first;
673 // Don't remove core_*.so, just remove m_*.so
674 if (modname.c_str()[0] == 'c')
676 if (ServerInstance->Modules->Unload(i->second))
678 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
681 user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str());
683 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
688 user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
690 ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
694 for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
696 if (ServerInstance->Modules->Load(adding->c_str()))
698 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
700 user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str());
702 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
707 user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
709 ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
714 ConfigTag* ServerConfig::ConfValue(const std::string &tag)
716 ConfigTagList found = config_data.equal_range(tag);
717 if (found.first == found.second)
719 ConfigTag* rv = found.first->second;
721 if (found.first != found.second)
722 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used "
723 "(first at " + rv->getTagLocation() + "; second at " + found.first->second->getTagLocation() + ")");
727 ConfigTagList ServerConfig::ConfTags(const std::string& tag)
729 return config_data.equal_range(tag);
732 std::string ServerConfig::Escape(const std::string& str, bool xml)
735 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
740 escaped += xml ? """ : "\"";
743 escaped += xml ? "&" : "&";
746 escaped += xml ? "\\" : "\\\\";
756 void ConfigReaderThread::Run()
762 void ConfigReaderThread::Finish()
764 ServerConfig* old = ServerInstance->Config;
765 ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Switching to new configuration...");
766 ServerInstance->Config = this->Config;
767 Config->Apply(old, TheUserUID);
772 * Apply the changed configuration from the rehash.
774 * XXX: The order of these is IMPORTANT, do not reorder them without testing
777 ServerInstance->XLines->CheckELines();
778 ServerInstance->XLines->ApplyLines();
779 ChanModeReference ban(NULL, "ban");
780 static_cast<ListModeBase*>(*ban)->DoRehash();
781 Config->ApplyDisabledCommands(Config->DisabledCommands);
782 User* user = ServerInstance->FindNick(TheUserUID);
784 ConfigStatus status(user);
785 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
786 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
787 i->second->ReadConfig(status);
789 // The description of this server may have changed - update it for WHOIS etc.
790 ServerInstance->FakeClient->server->description = Config->ServerDesc;
792 ServerInstance->ISupport.Build();
794 ServerInstance->Logs->CloseLogs();
795 ServerInstance->Logs->OpenFileLogs();
797 if (Config->RawLog && !old->RawLog)
798 ServerInstance->Users->ServerNoticeAll("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
805 ServerInstance->Config = old;