* | 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
NetBufferSize = 10240;
SoftLimit = ServerInstance->SE->GetMaxFds();
MaxConn = SOMAXCONN;
- MaxWhoResults = 0;
MaxChans = 20;
OperMaxChans = 30;
c_ipv4_range = 32;
void ServerConfig::Update005()
{
std::stringstream out(data005);
+ std::vector<std::string> 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);
}
}
OperInfo* ifo = new OperInfo;
oper_blocks[" " + name] = ifo;
+ ifo->name = name;
ifo->type_block = tag;
std::string classname;
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;
+ }
}
}
blk_count = 1;
}
- ClassMap newBlocksByMask;
Classes.resize(blk_count);
std::map<std::string, int> names;
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;
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) :
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;
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);
delete me;
me = old;
}
- newBlocksByMask[typeMask] = me;
Classes[i] = me;
}
}
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");
range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>");
range(MaxTargets, 1, 31, 20, "<security:maxtargets>");
range(NetBufferSize, 1024, 65534, 10240, "<performance:netbuffersize>");
- range(MaxWhoResults, 1, 65535, 1024, "<performace:maxwho>");
range(WhoWasGroupSize, 0, 10000, 10, "<whowas:groupsize>");
range(WhoWasMaxGroups, 0, 1000000, 10240, "<whowas:maxgroups>");
range(WhoWasMaxKeep, 3600, INT_MAX, 3600, "<whowas:maxkeep>");
}
if (valid)
{
- ReadFile(MOTD, ConfValue("files")->getString("motd"));
- ReadFile(RULES, ConfValue("files")->getString("rules"));
DNSServer = ConfValue("dns")->getString("server");
FindDNS(DNSServer);
}
// 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.
*/
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:");
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;
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();