X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=20cc0c2b3c30f63c3c8d15f9f9ceb7e98aa71713;hb=f1c95ba9301178017542afe9262a3f2f0528afd5;hp=c62973c8993388058aafeefc0192c59a778117bc;hpb=54242e2c5839c5493a344badb49cbcb76e298f9f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index c62973c89..20cc0c2b3 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -11,20 +11,6 @@ * --------------------------------------------------- */ -/* $Core */ -/* $CopyInstall: conf/inspircd.quotes.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.rules.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.motd.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.helpop-full.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.helpop.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.censor.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.filter.example $(CONPATH) */ -/* $CopyInstall: conf/inspircd.conf.example $(CONPATH) */ -/* $CopyInstall: conf/modules.conf.example $(CONPATH) */ -/* $CopyInstall: conf/opers.conf.example $(CONPATH) */ -/* $CopyInstall: conf/links.conf.example $(CONPATH) */ -/* $CopyInstall: tools/gdbargs $(BASE)/.gdbargs */ - #include "inspircd.h" #include #include "xline.h" @@ -42,7 +28,6 @@ ServerConfig::ServerConfig() NetBufferSize = 10240; SoftLimit = ServerInstance->SE->GetMaxFds(); MaxConn = SOMAXCONN; - MaxWhoResults = 0; MaxChans = 20; OperMaxChans = 30; c_ipv4_range = 32; @@ -52,28 +37,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 +200,7 @@ void ServerConfig::CrossCheckOperClassType() OperInfo* ifo = new OperInfo; oper_blocks[" " + name] = ifo; + ifo->name = name; ifo->type_block = tag; std::string classname; @@ -261,9 +248,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 +272,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) blk_count = 1; } - ClassMap newBlocksByMask; Classes.resize(blk_count); std::map names; @@ -304,22 +297,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 +317,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 +347,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; @@ -370,7 +368,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) 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); @@ -383,7 +380,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) delete me; me = old; } - newBlocksByMask[typeMask] = me; Classes[i] = me; } } @@ -451,7 +447,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"); @@ -495,7 +490,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, ""); @@ -580,8 +574,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); } @@ -784,34 +776,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; @@ -872,7 +836,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();