mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Update connect block matching on rehash to prefer names, show more useful information in /STATS i
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12337 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
1cda046fed
commit
7fdd55570e
@ -198,7 +198,7 @@ struct CoreExport ConnectClass : public refcountbase
|
||||
*/
|
||||
unsigned int GetPenaltyThreshold()
|
||||
{
|
||||
return (penaltythreshold ? penaltythreshold : 10);
|
||||
return penaltythreshold ? penaltythreshold : (fakelag ? 10 : 20);
|
||||
}
|
||||
|
||||
unsigned int GetCommandRate()
|
||||
@ -206,7 +206,7 @@ struct CoreExport ConnectClass : public refcountbase
|
||||
return commandrate ? commandrate : 1000;
|
||||
}
|
||||
|
||||
/** Returusn the maximum number of local sessions
|
||||
/** Return the maximum number of local sessions
|
||||
*/
|
||||
unsigned long GetMaxLocal()
|
||||
{
|
||||
|
@ -261,9 +261,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" : (c->type == CC_DENY) ? "d" : "n";
|
||||
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 +285,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
|
||||
blk_count = 1;
|
||||
}
|
||||
|
||||
ClassMap newBlocksByMask;
|
||||
Classes.resize(blk_count);
|
||||
std::map<std::string, int> names;
|
||||
|
||||
@ -304,22 +310,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,15 +330,29 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
|
||||
type = CC_DENY;
|
||||
typeMask = 'd' + mask;
|
||||
}
|
||||
else
|
||||
else if (!name.empty())
|
||||
{
|
||||
type = CC_NAMED;
|
||||
mask = name;
|
||||
typeMask = 'n' + mask;
|
||||
}
|
||||
ClassMap::iterator dupMask = newBlocksByMask.find(typeMask);
|
||||
if (dupMask != newBlocksByMask.end())
|
||||
throw CoreException("Two connect classes cannot have the same mask (" + mask + ")");
|
||||
else
|
||||
{
|
||||
throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation());
|
||||
}
|
||||
|
||||
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) :
|
||||
@ -385,7 +396,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
|
||||
delete me;
|
||||
me = old;
|
||||
}
|
||||
newBlocksByMask[typeMask] = me;
|
||||
Classes[i] = me;
|
||||
}
|
||||
}
|
||||
|
@ -65,12 +65,31 @@ void InspIRCd::DoStats(char statschar, User* user, string_list &results)
|
||||
|
||||
case 'i':
|
||||
{
|
||||
int idx = 0;
|
||||
for (ClassVector::iterator i = this->Config->Classes.begin(); i != this->Config->Classes.end(); i++)
|
||||
{
|
||||
ConnectClass* c = *i;
|
||||
results.push_back(sn+" 215 "+user->nick+" i NOMATCH * "+c->GetHost()+" "+ConvToStr(c->limit ? c->limit : this->SE->GetMaxFds())+" "+ConvToStr(idx)+" "+this->Config->ServerName+" *");
|
||||
idx++;
|
||||
std::stringstream res;
|
||||
res << sn << " 215 " << user->nick << " I " << c->name << ' ';
|
||||
if (c->type == CC_ALLOW)
|
||||
res << '+';
|
||||
if (c->type == CC_DENY)
|
||||
res << '-';
|
||||
|
||||
if (c->type == CC_NAMED)
|
||||
res << '*';
|
||||
else
|
||||
res << c->host;
|
||||
|
||||
if (c->port)
|
||||
res << ' ' << c->port << ' ';
|
||||
else
|
||||
res << " * ";
|
||||
|
||||
res << c->GetRecvqMax() << ' ' << c->GetSendqSoftMax() << ' ' << c->GetSendqHardMax()
|
||||
<< ' ' << c->GetCommandRate() << ' ' << c->GetPenaltyThreshold();
|
||||
if (c->fakelag)
|
||||
res << '*';
|
||||
results.push_back(res.str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -81,6 +100,7 @@ void InspIRCd::DoStats(char statschar, User* user, string_list &results)
|
||||
for (ClassVector::iterator i = this->Config->Classes.begin(); i != this->Config->Classes.end(); i++)
|
||||
{
|
||||
ConnectClass* c = *i;
|
||||
results.push_back(sn+" 215 "+user->nick+" i NOMATCH * "+c->GetHost()+" "+ConvToStr(c->limit ? c->limit : this->SE->GetMaxFds())+" "+ConvToStr(idx)+" "+this->Config->ServerName+" *");
|
||||
results.push_back(sn+" 218 "+user->nick+" Y "+ConvToStr(idx)+" "+ConvToStr(c->GetPingTime())+" 0 "+ConvToStr(c->GetSendqHardMax())+" :"+
|
||||
ConvToStr(c->GetRecvqMax())+" "+ConvToStr(c->GetRegTimeout()));
|
||||
idx++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user