mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Rather largeish change to class checking on connect to fix a few minor bits and bobs here and there
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7029 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
af2b10e82c
commit
5dbf63c2a3
@ -75,7 +75,7 @@ enum MessageType {
|
||||
* ipv4 servers, so this value will be ten times as
|
||||
* high on ipv6 servers.
|
||||
*/
|
||||
#define NATIVE_API_VERSION 11023
|
||||
#define NATIVE_API_VERSION 11024
|
||||
#ifdef IPV6
|
||||
#define API_VERSION (NATIVE_API_VERSION * 10)
|
||||
#else
|
||||
|
@ -708,6 +708,10 @@ class userrec : public connection
|
||||
*/
|
||||
void Oper(const std::string &opertype);
|
||||
|
||||
/** Call this method to find the matching <connect> for a user, and to check them against it.
|
||||
*/
|
||||
void CheckClass();
|
||||
|
||||
/** Use this method to fully connect a user.
|
||||
* This will send the message of the day, check G/K/E lines, etc.
|
||||
*/
|
||||
|
@ -900,27 +900,12 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
|
||||
Instance->AddLocalClone(New);
|
||||
Instance->AddGlobalClone(New);
|
||||
|
||||
/*
|
||||
* First class check. We do this again in FullConnect after DNS is done, and NICK/USER is recieved.
|
||||
* See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
|
||||
*/
|
||||
ConnectClass* i = New->GetClass();
|
||||
|
||||
if ((!i) || (i->GetType() == CC_DENY))
|
||||
{
|
||||
userrec::QuitUser(Instance, New,"Unauthorised connection");
|
||||
return;
|
||||
}
|
||||
|
||||
/* fix: do maxperlocal/global IP here, not on full connect to stop fd exhaustion attempts */
|
||||
if ((i->GetMaxLocal()) && (New->LocalCloneCount() > i->GetMaxLocal()))
|
||||
{
|
||||
userrec::QuitUser(Instance, New, "No more connections allowed from your host via this connect class (local)");
|
||||
Instance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", i->GetMaxLocal(), New->GetIPString());
|
||||
return;
|
||||
}
|
||||
else if ((i->GetMaxGlobal()) && (New->GlobalCloneCount() > i->GetMaxGlobal()))
|
||||
{
|
||||
userrec::QuitUser(Instance, New, "No more connections allowed from your host via this connect class (global)");
|
||||
Instance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",i->GetMaxGlobal(), New->GetIPString());
|
||||
return;
|
||||
}
|
||||
New->CheckClass();
|
||||
|
||||
New->pingmax = i->GetPingTime();
|
||||
New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
|
||||
@ -1001,27 +986,58 @@ unsigned long userrec::LocalCloneCount()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void userrec::FullConnect()
|
||||
/*
|
||||
* Check class restrictions
|
||||
*/
|
||||
void userrec::CheckClass()
|
||||
{
|
||||
ServerInstance->stats->statsConnects++;
|
||||
this->idle_lastmsg = ServerInstance->Time();
|
||||
|
||||
ConnectClass* a = this->GetClass();
|
||||
|
||||
if ((!a) || (a->GetType() == CC_DENY))
|
||||
{
|
||||
this->muted = true;
|
||||
ServerInstance->GlobalCulls.AddItem(this,"Unauthorised connection");
|
||||
userrec::QuitUser(ServerInstance, this, "Unauthorised connection");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!a->GetPass().empty()) && (!this->haspassed))
|
||||
{
|
||||
this->muted = true;
|
||||
ServerInstance->GlobalCulls.AddItem(this,"Invalid password");
|
||||
userrec::QuitUser(ServerInstance, this, "Invalid password");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!a) || (a->GetType() == CC_DENY))
|
||||
{
|
||||
userrec::QuitUser(ServerInstance, this,"Unauthorised connection");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
|
||||
{
|
||||
userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
|
||||
ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
|
||||
return;
|
||||
}
|
||||
else if ((a->GetMaxGlobal()) && (this->GlobalCloneCount() > a->GetMaxGlobal()))
|
||||
{
|
||||
userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (global)");
|
||||
ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void userrec::FullConnect()
|
||||
{
|
||||
ServerInstance->stats->statsConnects++;
|
||||
this->idle_lastmsg = ServerInstance->Time();
|
||||
|
||||
/*
|
||||
* You may be thinking "wtf, we checked this in userrec::AddClient!" - and yes, we did, BUT.
|
||||
* At the time AddClient is called, we don't have a resolved host, by here we probably do - which
|
||||
* may put the user into a totally seperate class with different restrictions! so we *must* check again.
|
||||
* Don't remove this! -- w00t
|
||||
*/
|
||||
this->CheckClass();
|
||||
|
||||
if (!this->exempt)
|
||||
{
|
||||
GLine* r = ServerInstance->XLines->matches_gline(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user