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", 32))
34 , ChanMax(tag->getInt("maxchan", 64))
35 , MaxModes(tag->getInt("maxmodes", 20))
36 , IdentMax(tag->getInt("maxident", 11))
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 static ConfigTag* CreateEmptyTag()
49 std::vector<KeyVal>* items;
50 return ConfigTag::create("empty", "<auto>", 0, items);
53 ServerConfig::ServerConfig()
54 : EmptyTag(CreateEmptyTag())
56 RawLog = HideBans = HideSplits = UndernetMsgPrefix = false;
57 WildcardIPv6 = InvBypassModes = true;
60 NetBufferSize = 10240;
68 ServerConfig::~ServerConfig()
73 static void ValidHost(const std::string& p, const std::string& msg)
76 if (p.empty() || p[0] == '.')
77 throw CoreException("The value of "+msg+" is not a valid hostname");
78 for (unsigned int i=0;i < p.length();i++)
83 throw CoreException("The value of "+msg+" is not a valid hostname");
90 throw CoreException("The value of "+msg+" is not a valid hostname");
93 bool ServerConfig::ApplyDisabledCommands(const std::string& data)
95 std::stringstream dcmds(data);
98 /* Enable everything first */
99 const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
100 for (CommandParser::CommandMap::const_iterator x = commands.begin(); x != commands.end(); ++x)
101 x->second->Disable(false);
103 /* Now disable all the ones which the user wants disabled */
104 while (dcmds >> thiscmd)
106 Command* handler = ServerInstance->Parser.GetHandler(thiscmd);
108 handler->Disable(true);
113 static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make)
115 ConfigTagList tags = conf->ConfTags(tag);
116 for(ConfigIter i = tags.first; i != tags.second; ++i)
118 ConfigTag* ctag = i->second;
120 if (!ctag->readString(key, mask))
121 throw CoreException("<"+tag+":"+key+"> missing at " + ctag->getTagLocation());
122 std::string reason = ctag->getString("reason", "<Config>");
123 XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask);
124 if (!ServerInstance->XLines->AddLine(xl, NULL))
129 typedef std::map<std::string, ConfigTag*> LocalIndex;
130 void ServerConfig::CrossCheckOperClassType()
132 LocalIndex operclass;
133 ConfigTagList tags = ConfTags("class");
134 for(ConfigIter i = tags.first; i != tags.second; ++i)
136 ConfigTag* tag = i->second;
137 std::string name = tag->getString("name");
139 throw CoreException("<class:name> missing from tag at " + tag->getTagLocation());
140 if (operclass.find(name) != operclass.end())
141 throw CoreException("Duplicate class block with name " + name + " at " + tag->getTagLocation());
142 operclass[name] = tag;
144 tags = ConfTags("type");
145 for(ConfigIter i = tags.first; i != tags.second; ++i)
147 ConfigTag* tag = i->second;
148 std::string name = tag->getString("name");
150 throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
151 if (OperTypes.find(name) != OperTypes.end())
152 throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
154 OperInfo* ifo = new OperInfo;
155 OperTypes[name] = ifo;
157 ifo->type_block = tag;
159 std::string classname;
160 irc::spacesepstream str(tag->getString("classes"));
161 while (str.GetToken(classname))
163 LocalIndex::iterator cls = operclass.find(classname);
164 if (cls == operclass.end())
165 throw CoreException("Oper type " + name + " has missing class " + classname);
166 ifo->class_blocks.push_back(cls->second);
170 tags = ConfTags("oper");
171 for(ConfigIter i = tags.first; i != tags.second; ++i)
173 ConfigTag* tag = i->second;
175 std::string name = tag->getString("name");
177 throw CoreException("<oper:name> missing from tag at " + tag->getTagLocation());
179 std::string type = tag->getString("type");
180 OperIndex::iterator tblk = OperTypes.find(type);
181 if (tblk == OperTypes.end())
182 throw CoreException("Oper block " + name + " has missing type " + type);
183 if (oper_blocks.find(name) != oper_blocks.end())
184 throw CoreException("Duplicate oper block with name " + name + " at " + tag->getTagLocation());
186 OperInfo* ifo = new OperInfo;
188 ifo->oper_block = tag;
189 ifo->type_block = tblk->second->type_block;
190 ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end());
191 oper_blocks[name] = ifo;
195 void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
197 typedef std::map<std::string, ConnectClass*> ClassMap;
198 ClassMap oldBlocksByMask;
201 for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i)
203 ConnectClass* c = *i;
204 if (c->name.compare(0, 8, "unnamed-", 8))
206 oldBlocksByMask["n" + c->name] = c;
208 else if (c->type == CC_ALLOW || c->type == CC_DENY)
210 std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d";
212 oldBlocksByMask[typeMask] = c;
217 int blk_count = config_data.count("connect");
220 // No connect blocks found; make a trivial default block
221 std::vector<KeyVal>* items;
222 ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
223 items->push_back(std::make_pair("allow", "*"));
224 config_data.insert(std::make_pair("connect", tag));
228 Classes.resize(blk_count);
229 std::map<std::string, int> names;
231 bool try_again = true;
232 for(int tries=0; try_again; tries++)
235 ConfigTagList tags = ConfTags("connect");
237 for(ConfigIter it = tags.first; it != tags.second; ++it, ++i)
239 ConfigTag* tag = it->second;
243 ConnectClass* parent = NULL;
244 std::string parentName = tag->getString("parent");
245 if (!parentName.empty())
247 std::map<std::string,int>::iterator parentIter = names.find(parentName);
248 if (parentIter == names.end())
251 // couldn't find parent this time. If it's the last time, we'll never find it.
252 if (tries >= blk_count)
253 throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation());
256 parent = Classes[parentIter->second];
259 std::string name = tag->getString("name");
260 std::string mask, typeMask;
263 if (tag->readString("allow", mask, false))
266 typeMask = 'a' + mask;
268 else if (tag->readString("deny", mask, false))
271 typeMask = 'd' + mask;
273 else if (!name.empty())
277 typeMask = 'n' + mask;
281 throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation());
286 name = "unnamed-" + ConvToStr(i);
290 typeMask = 'n' + name;
293 if (names.find(name) != names.end())
294 throw CoreException("Two connect classes with name \"" + name + "\" defined!");
297 ConnectClass* me = parent ?
298 new ConnectClass(tag, type, mask, *parent) :
299 new ConnectClass(tag, type, mask);
303 me->registration_timeout = tag->getInt("timeout", me->registration_timeout);
304 me->pingtime = tag->getInt("pingfreq", me->pingtime);
306 if (tag->readString("sendq", sendq))
308 // attempt to guess a good hard/soft sendq from a single value
309 long value = atol(sendq.c_str());
311 me->softsendqmax = value / 16;
313 me->softsendqmax = value;
314 me->hardsendqmax = value * 8;
316 me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
317 me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
318 me->recvqmax = tag->getInt("recvq", me->recvqmax);
319 me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
320 me->commandrate = tag->getInt("commandrate", me->commandrate);
321 me->fakelag = tag->getBool("fakelag", me->fakelag);
322 me->maxlocal = tag->getInt("localmax", me->maxlocal);
323 me->maxglobal = tag->getInt("globalmax", me->maxglobal);
324 me->maxchans = tag->getInt("maxchans", me->maxchans);
325 me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
326 me->limit = tag->getInt("limit", me->limit);
327 me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
329 ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
330 if (oldMask != oldBlocksByMask.end())
332 ConnectClass* old = oldMask->second;
333 oldBlocksByMask.erase(oldMask);
343 /** Represents a deprecated configuration tag.
345 struct DeprecatedConfig
350 /** Attribute key. */
353 /** Attribute value. */
356 /** Reason for deprecation. */
360 static const DeprecatedConfig ChangedConfig[] = {
361 { "bind", "transport", "", "has been moved to <bind:ssl> as of 2.0" },
362 { "die", "value", "", "you need to reread your config" },
363 { "gnutls", "starttls", "", "has been replaced with m_starttls as of 2.2" },
364 { "link", "autoconnect", "", "2.0+ does not use this attribute - define <autoconnect> tags instead" },
365 { "link", "transport", "", "has been moved to <link:ssl> as of 2.0" },
366 { "module", "name", "m_chanprotect.so", "has been replaced with m_customprefix as of 2.2" },
367 { "module", "name", "m_halfop.so", "has been replaced with m_customprefix as of 2.2" },
368 { "options", "cyclehosts", "", "has been replaced with m_hostcycle as of 2.2" },
369 { "performance", "nouserdns", "", "has been moved to <connect:resolvehostnames> as of 2.2" }
372 void ServerConfig::Fill()
374 ConfigTag* options = ConfValue("options");
375 ConfigTag* security = ConfValue("security");
378 ServerName = ConfValue("server")->getString("name", "irc.example.com");
379 ValidHost(ServerName, "<server:name>");
381 sid = ConfValue("server")->getString("id");
382 if (!sid.empty() && !InspIRCd::IsSID(sid))
383 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.");
387 if (ServerName != ConfValue("server")->getString("name"))
388 throw CoreException("You must restart to change the server name");
390 std::string nsid = ConfValue("server")->getString("id");
391 if (!nsid.empty() && nsid != sid)
392 throw CoreException("You must restart to change the server id");
394 SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10);
395 CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
396 MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
397 XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
398 ServerDesc = ConfValue("server")->getString("description", "Configure Me");
399 Network = ConfValue("server")->getString("network", "Network");
400 NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
401 dns_timeout = ConfValue("dns")->getInt("timeout", 5);
402 DisabledCommands = ConfValue("disabled")->getString("commands", "");
403 DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
404 UserStats = security->getString("userstats");
405 CustomVersion = security->getString("customversion");
406 HideSplits = security->getBool("hidesplits");
407 HideBans = security->getBool("hidebans");
408 HideWhoisServer = security->getString("hidewhois");
409 HideKillsServer = security->getString("hidekills");
410 RestrictBannedUsers = security->getBool("restrictbannedusers", true);
411 GenericOper = security->getBool("genericoper");
412 SyntaxHints = options->getBool("syntaxhints");
413 CycleHostsFromUser = options->getBool("cyclehostsfromuser");
414 UndernetMsgPrefix = options->getBool("ircumsgprefix");
415 FullHostInTopic = options->getBool("hostintopic");
416 MaxTargets = security->getInt("maxtargets", 20, 1, 31);
417 DefaultModes = options->getString("defaultmodes", "not");
418 PID = ConfValue("pid")->getString("file");
419 MaxChans = ConfValue("channels")->getInt("users", 20);
420 OperMaxChans = ConfValue("channels")->getInt("opers");
421 c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
422 c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
423 Limits = ServerLimits(ConfValue("limits"));
424 Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH);
425 Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH);
426 Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH);
427 Paths.Module = ConfValue("path")->getString("moduledir", INSPIRCD_MODULE_PATH);
428 InvBypassModes = options->getBool("invitebypassmodes", true);
429 NoSnoticeStack = options->getBool("nosnoticestack", false);
431 if (Network.find(' ') != std::string::npos)
432 throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
434 std::string defbind = options->getString("defaultbind");
435 if (assign(defbind) == "ipv4")
437 WildcardIPv6 = false;
439 else if (assign(defbind) == "ipv6")
446 int socktest = socket(AF_INET6, SOCK_STREAM, 0);
448 WildcardIPv6 = false;
450 SocketEngine::Close(socktest);
453 ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
454 ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
455 ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
456 ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
458 memset(DisabledUModes, 0, sizeof(DisabledUModes));
459 std::string modes = ConfValue("disabled")->getString("usermodes");
460 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
462 // Complain when the character is not a-z or A-Z
463 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
464 throw CoreException("Invalid usermode " + std::string(1, *p) + " was found.");
465 DisabledUModes[*p - 'A'] = 1;
468 memset(DisabledCModes, 0, sizeof(DisabledCModes));
469 modes = ConfValue("disabled")->getString("chanmodes");
470 for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
472 if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
473 throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
474 DisabledCModes[*p - 'A'] = 1;
477 std::string v = security->getString("announceinvites");
480 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
482 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
483 else if (v == "dynamic")
484 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC;
486 AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
488 v = security->getString("operspywhois");
490 OperSpyWhois = SPYWHOIS_SPLITMSG;
491 else if (v == "on" || v == "yes")
492 OperSpyWhois = SPYWHOIS_SINGLEMSG;
494 OperSpyWhois = SPYWHOIS_NONE;
497 // WARNING: it is not safe to use most of the codebase in this function, as it
498 // will run in the config reader thread
499 void ServerConfig::Read()
501 /* Load and parse the config file, if there are any errors then explode */
503 ParseStack stack(this);
506 valid = stack.ParseFile(ServerInstance->ConfigFileName, 0);
508 catch (CoreException& err)
511 errstr << err.GetReason() << std::endl;
515 void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
521 * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
523 this->ServerName = old->ServerName;
524 this->sid = old->sid;
525 this->cmdline = old->cmdline;
528 /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
531 for (int index = 0; index * sizeof(DeprecatedConfig) < sizeof(ChangedConfig); index++)
534 ConfigTagList tags = ConfTags(ChangedConfig[index].tag);
535 for(ConfigIter i = tags.first; i != tags.second; ++i)
537 if (i->second->readString(ChangedConfig[index].key, value, true)
538 && (ChangedConfig[index].value.empty() || value == ChangedConfig[index].value))
540 errstr << "Your configuration contains a deprecated value: <" << ChangedConfig[index].tag;
541 if (ChangedConfig[index].value.empty())
543 errstr << ':' << ChangedConfig[index].key;
547 errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\"";
549 errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")" << std::endl;
556 // Handle special items
557 CrossCheckOperClassType();
558 CrossCheckConnectBlocks(old);
560 catch (CoreException &ce)
562 errstr << ce.GetReason();
565 // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
566 valid = errstr.str().empty();
568 // write once here, to try it out and make sure its ok
570 ServerInstance->WritePID(this->PID);
572 ConfigTagList binds = ConfTags("bind");
573 if (binds.first == binds.second)
574 errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
575 << "You will need to do this if you want clients to be able to connect!" << std::endl;
579 // On first run, ports are bound later on
581 ServerInstance->BindPorts(pl);
584 errstr << "Not all your client ports could be bound." << std::endl
585 << "The following port(s) failed to bind:" << std::endl;
588 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
590 errstr << j << ".\tAddress: " << (i->first.empty() ? "<all>" : i->first.c_str()) << "\tReason: "
591 << i->second << std::endl;
596 User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
600 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "There were errors in your configuration file:");
604 while (errstr.good())
607 getline(errstr, line, '\n');
610 // On startup, print out to console (still attached at this point)
612 std::cout << line << std::endl;
613 // If a user is rehashing, tell them directly
615 user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
617 ServerInstance->SNO->WriteGlobalSno('a', line);
621 errstr.str(std::string());
623 // Re-parse our MOTD and RULES files for colors -- Justasic
624 for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
626 ConfigTag *tag = (*it)->config;
627 // Make sure our connection class allows motd colors
628 if(!tag->getBool("allowmotdcolors"))
631 ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
632 if (file != this->Files.end())
633 InspIRCd::ProcessColors(file->second);
636 /* No old configuration -> initial boot, nothing more to do here */
641 ServerInstance->Exit(EXIT_STATUS_CONFIG);
648 // If there were errors processing configuration, don't touch modules.
655 user->SendText(":%s NOTICE %s :*** Successfully rehashed server.",
656 ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
657 ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
660 void ServerConfig::ApplyModules(User* user)
662 std::vector<std::string> added_modules;
663 ModuleManager::ModuleMap removed_modules = ServerInstance->Modules->GetModules();
665 ConfigTagList tags = ConfTags("module");
666 for(ConfigIter i = tags.first; i != tags.second; ++i)
668 ConfigTag* tag = i->second;
670 if (tag->readString("name", name))
672 // if this module is already loaded, the erase will succeed, so we need do nothing
673 // otherwise, we need to add the module (which will be done later)
674 if (removed_modules.erase(name) == 0)
675 added_modules.push_back(name);
679 for (ModuleManager::ModuleMap::iterator i = removed_modules.begin(); i != removed_modules.end(); ++i)
681 const std::string& modname = i->first;
682 // Don't remove core_*.so, just remove m_*.so
683 if (modname.c_str()[0] == 'c')
685 if (ServerInstance->Modules->Unload(i->second))
687 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
690 user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str());
692 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
697 user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
699 ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
703 for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
705 if (ServerInstance->Modules->Load(adding->c_str()))
707 ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
709 user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str());
711 ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
716 user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
718 ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
723 ConfigTag* ServerConfig::ConfValue(const std::string &tag)
725 ConfigTagList found = config_data.equal_range(tag);
726 if (found.first == found.second)
728 ConfigTag* rv = found.first->second;
730 if (found.first != found.second)
731 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used "
732 "(first at " + rv->getTagLocation() + "; second at " + found.first->second->getTagLocation() + ")");
736 ConfigTagList ServerConfig::ConfTags(const std::string& tag)
738 return config_data.equal_range(tag);
741 std::string ServerConfig::Escape(const std::string& str, bool xml)
744 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
749 escaped += xml ? """ : "\"";
752 escaped += xml ? "&" : "&";
755 escaped += xml ? "\\" : "\\\\";
765 void ConfigReaderThread::Run()
771 void ConfigReaderThread::Finish()
773 ServerConfig* old = ServerInstance->Config;
774 ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Switching to new configuration...");
775 ServerInstance->Config = this->Config;
776 Config->Apply(old, TheUserUID);
781 * Apply the changed configuration from the rehash.
783 * XXX: The order of these is IMPORTANT, do not reorder them without testing
786 ServerInstance->XLines->CheckELines();
787 ServerInstance->XLines->ApplyLines();
788 ChanModeReference ban(NULL, "ban");
789 static_cast<ListModeBase*>(*ban)->DoRehash();
790 Config->ApplyDisabledCommands(Config->DisabledCommands);
791 User* user = ServerInstance->FindNick(TheUserUID);
793 ConfigStatus status(user);
794 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
795 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
796 i->second->ReadConfig(status);
798 // The description of this server may have changed - update it for WHOIS etc.
799 ServerInstance->FakeClient->server->description = Config->ServerDesc;
801 ServerInstance->ISupport.Build();
803 ServerInstance->Logs->CloseLogs();
804 ServerInstance->Logs->OpenFileLogs();
806 if (Config->RawLog && !old->RawLog)
807 ServerInstance->Users->ServerNoticeAll("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
814 ServerInstance->Config = old;