X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=9db1f2665499d4828026f50305321c7cbbbd4606;hb=6f914e2dd80375fa9809619c21a09705e4d24129;hp=335b2458d63745bc1cd6158e7a45a5b38ea12cef;hpb=316167b91713739d784cc4c640275ebe2a9f054a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index 335b2458d..9db1f2665 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -37,12 +37,11 @@ ServerConfig::ServerConfig() WhoWasGroupSize = WhoWasMaxGroups = WhoWasMaxKeep = 0; NoUserDns = OperSpyWhois = HideBans = HideSplits = UndernetMsgPrefix = false; CycleHosts = InvBypassModes = true; - dns_timeout = DieDelay = 5; + dns_timeout = 5; MaxTargets = 20; NetBufferSize = 10240; SoftLimit = ServerInstance->SE->GetMaxFds(); MaxConn = SOMAXCONN; - MaxWhoResults = 0; MaxChans = 20; OperMaxChans = 30; c_ipv4_range = 32; @@ -52,28 +51,29 @@ ServerConfig::ServerConfig() void ServerConfig::Update005() { std::stringstream out(data005); + std::vector data; std::string token; + while (out >> token) + data.push_back(token); + sort(data.begin(), data.end()); + std::string line5; - int token_counter = 0; isupport.clear(); - while (out >> token) + for(unsigned int i=0; i < data.size(); i++) { + token = data[i]; line5 = line5 + token + " "; - token_counter++; - if (token_counter >= 13) + if (i % 13 == 12) { - char buf[MAXBUF]; - snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str()); - isupport.push_back(buf); + line5.append(":are supported by this server"); + isupport.push_back(line5); line5.clear(); - token_counter = 0; } } if (!line5.empty()) { - char buf[MAXBUF]; - snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str()); - isupport.push_back(buf); + line5.append(":are supported by this server"); + isupport.push_back(line5); } } @@ -214,6 +214,7 @@ void ServerConfig::CrossCheckOperClassType() OperInfo* ifo = new OperInfo; oper_blocks[" " + name] = ifo; + ifo->name = name; ifo->type_block = tag; std::string classname; @@ -261,9 +262,16 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i) { ConnectClass* c = *i; - std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d"; - typeMask += c->host; - oldBlocksByMask[typeMask] = c; + if (c->name.substr(0, 8) != "unnamed-") + { + oldBlocksByMask["n" + c->name] = c; + } + else if (c->type == CC_ALLOW || c->type == CC_DENY) + { + std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d"; + typeMask += c->host; + oldBlocksByMask[typeMask] = c; + } } } @@ -278,7 +286,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) blk_count = 1; } - ClassMap newBlocksByMask; Classes.resize(blk_count); std::map names; @@ -304,22 +311,13 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) try_again = true; // couldn't find parent this time. If it's the last time, we'll never find it. if (tries >= blk_count) - throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block " + ConvToStr(i)); + throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation()); continue; } parent = Classes[parentIter->second]; } std::string name = tag->getString("name"); - if (name.empty()) - { - name = "unnamed-" + ConvToStr(i); - } - - if (names.find(name) != names.end()) - throw CoreException("Two connect classes with name \"" + name + "\" defined!"); - names[name] = i; - std::string mask, typeMask; char type; @@ -333,13 +331,29 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) type = CC_DENY; typeMask = 'd' + mask; } + else if (!name.empty()) + { + type = CC_NAMED; + mask = name; + typeMask = 'n' + mask; + } else { - throw CoreException("Connect class must have an allow or deny mask at " + tag->getTagLocation()); + throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation()); } - ClassMap::iterator dupMask = newBlocksByMask.find(typeMask); - if (dupMask != newBlocksByMask.end()) - throw CoreException("Two connect classes cannot have the same mask (" + mask + ")"); + + if (name.empty()) + { + name = "unnamed-" + ConvToStr(i); + } + else + { + typeMask = 'n' + name; + } + + if (names.find(name) != names.end()) + throw CoreException("Two connect classes with name \"" + name + "\" defined!"); + names[name] = i; ConnectClass* me = parent ? new ConnectClass(tag, type, mask, *parent) : @@ -347,8 +361,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) me->name = name; - tag->readString("password", me->pass); - tag->readString("hash", me->hash); me->registration_timeout = tag->getInt("timeout", me->registration_timeout); me->pingtime = tag->getInt("pingfreq", me->pingtime); std::string sendq; @@ -366,9 +378,10 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax); me->recvqmax = tag->getInt("recvq", me->recvqmax); me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold); + me->commandrate = tag->getInt("commandrate", me->commandrate); + me->fakelag = tag->getBool("fakelag", me->fakelag); me->maxlocal = tag->getInt("localmax", me->maxlocal); me->maxglobal = tag->getInt("globalmax", me->maxglobal); - me->port = tag->getInt("port", me->port); me->maxchans = tag->getInt("maxchans", me->maxchans); me->limit = tag->getInt("limit", me->limit); @@ -381,7 +394,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) delete me; me = old; } - newBlocksByMask[typeMask] = me; Classes[i] = me; } } @@ -431,7 +443,6 @@ void ServerConfig::Fill() diepass = ConfValue("power")->getString("diepass"); restartpass = ConfValue("power")->getString("restartpass"); powerhash = ConfValue("power")->getString("hash"); - DieDelay = ConfValue("power")->getInt("pause"); PrefixQuit = options->getString("prefixquit"); SuffixQuit = options->getString("suffixquit"); FixedQuit = options->getString("fixedquit"); @@ -450,7 +461,6 @@ void ServerConfig::Fill() AdminNick = ConfValue("admin")->getString("nick", "admin"); ModPath = ConfValue("path")->getString("moduledir", MOD_PATH); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240); - MaxWhoResults = ConfValue("performance")->getInt("maxwho", 1024); dns_timeout = ConfValue("dns")->getInt("timeout", 5); DisabledCommands = ConfValue("disabled")->getString("commands", ""); DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant"); @@ -494,7 +504,6 @@ void ServerConfig::Fill() range(MaxConn, 0, SOMAXCONN, SOMAXCONN, ""); range(MaxTargets, 1, 31, 20, ""); range(NetBufferSize, 1024, 65534, 10240, ""); - range(MaxWhoResults, 1, 65535, 1024, ""); range(WhoWasGroupSize, 0, 10000, 10, ""); range(WhoWasMaxGroups, 0, 1000000, 10240, ""); range(WhoWasMaxKeep, 3600, INT_MAX, 3600, ""); @@ -579,8 +588,6 @@ void ServerConfig::Read() } if (valid) { - ReadFile(MOTD, ConfValue("files")->getString("motd")); - ReadFile(RULES, ConfValue("files")->getString("rules")); DNSServer = ConfValue("dns")->getString("server"); FindDNS(DNSServer); } @@ -616,6 +623,9 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) // write once here, to try it out and make sure its ok ServerInstance->WritePID(this->PID); + // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances. + valid = errstr.str().empty(); + /* * These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername. */ @@ -644,7 +654,6 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid); - valid = errstr.str().empty(); if (!valid) ServerInstance->Logs->Log("CONFIG",DEFAULT, "There were errors in your configuration file:"); @@ -781,34 +790,6 @@ ConfigTagList ServerConfig::ConfTags(const std::string& tag) return config_data.equal_range(tag); } -/** Read the contents of a file located by `fname' into a file_cache pointed at by `F'. - */ -bool ServerConfig::ReadFile(file_cache &F, const std::string& fname) -{ - if (fname.empty()) - return false; - - char linebuf[MAXBUF]; - - F.clear(); - - FileWrapper file(fopen(fname.c_str(), "r")); - - if (!file) - return false; - while (!feof(file)) - { - if (fgets(linebuf, sizeof(linebuf), file)) - linebuf[strlen(linebuf)-1] = 0; - else - *linebuf = 0; - - F.push_back(*linebuf ? linebuf : " "); - } - - return true; -} - bool ServerConfig::FileExists(const char* file) { struct stat sb; @@ -869,7 +850,7 @@ void ConfigReaderThread::Finish() ServerInstance->Res->Rehash(); ServerInstance->ResetMaxBans(); Config->ApplyDisabledCommands(Config->DisabledCommands); - User* user = TheUserUID.empty() ? ServerInstance->FindNick(TheUserUID) : NULL; + User* user = ServerInstance->FindNick(TheUserUID); FOREACH_MOD(I_OnRehash, OnRehash(user)); ServerInstance->BuildISupport();