#include "xline.h"
#include "cull_list.h"
-irc::whowas::whowas_users whowas;
static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
-typedef std::map<irc::string,char*> opertype_t;
-typedef opertype_t operclass_t;
-
-opertype_t opertypes;
-operclass_t operclass;
-
/* XXX: Used for speeding up WriteCommon operations */
unsigned long uniq_id = 0;
bool InitTypes(ServerConfig* conf, const char* tag)
{
- for (opertype_t::iterator n = opertypes.begin(); n != opertypes.end(); n++)
+ for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++)
{
if (n->second)
delete[] n->second;
}
- opertypes.clear();
+ conf->opertypes.clear();
return true;
}
bool InitClasses(ServerConfig* conf, const char* tag)
{
- for (operclass_t::iterator n = operclass.begin(); n != operclass.end(); n++)
+ for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++)
{
if (n->second)
delete[] n->second;
}
- operclass.clear();
+ conf->operclass.clear();
return true;
}
char* TypeName = (char*)values[0];
char* Classes = (char*)values[1];
- opertypes[TypeName] = strdup(Classes);
+ conf->opertypes[TypeName] = strdup(Classes);
conf->GetInstance()->Log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
return true;
}
char* ClassName = (char*)values[0];
char* CommandList = (char*)values[1];
- operclass[ClassName] = strdup(CommandList);
+ conf->operclass[ClassName] = strdup(CommandList);
conf->GetInstance()->Log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
return true;
}
// are they even an oper at all?
if (*this->oper)
{
- opertype_t::iterator iter_opertype = opertypes.find(this->oper);
- if (iter_opertype != opertypes.end())
+ opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
+ if (iter_opertype != ServerInstance->Config->opertypes.end())
{
char* Classes = strdup(iter_opertype->second);
char* myclass = strtok_r(Classes," ",&savept);
while (myclass)
{
- operclass_t::iterator iter_operclass = operclass.find(myclass);
- if (iter_operclass != operclass.end())
+ operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
+ if (iter_operclass != ServerInstance->Config->operclass.end())
{
char* CommandList = strdup(iter_operclass->second);
mycmd = strtok_r(CommandList," ",&savept2);
}
/* every hour, run this function which removes all entries over 3 days */
- void MaintainWhoWas(time_t t)
+ void MaintainWhoWas(InspIRCd* ServerInstance, time_t t)
{
- for (whowas_users::iterator iter = ::whowas.begin(); iter != ::whowas.end(); iter++)
+ for (whowas_users::iterator iter = ServerInstance->whowas.begin(); iter != ServerInstance->whowas.end(); iter++)
{
whowas_set* n = (whowas_set*)iter->second;
if (n->size())
/* adds or updates an entry in the whowas list */
void userrec::AddToWhoWas()
{
- irc::whowas::whowas_users::iterator iter = whowas.find(this->nick);
+ irc::whowas::whowas_users::iterator iter = ServerInstance->whowas.find(this->nick);
+
+ ServerInstance->Log(DEBUG,"Add to whowas lists");
- if (iter == whowas.end())
+ if (iter == ServerInstance->whowas.end())
{
+ ServerInstance->Log(DEBUG,"Adding new whowas set for %s",this->nick);
irc::whowas::whowas_set* n = new irc::whowas::whowas_set;
irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this);
n->push_back(a);
- whowas[this->nick] = n;
+ ServerInstance->whowas[this->nick] = n;
}
else
{
irc::whowas::whowas_set* group = (irc::whowas::whowas_set*)iter->second;
+ ServerInstance->Log(DEBUG,"Using existing whowas group for %s",this->nick);
+
if (group->size() > 10)
{
+ ServerInstance->Log(DEBUG,"Trimming existing group to ten entries for %s",this->nick);
irc::whowas::WhoWasGroup *a = (irc::whowas::WhoWasGroup*)*(group->begin());
DELETE(a);
group->pop_front();
for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
New->dhost[j] = New->host[j] = *temp;
New->dhost[j] = New->host[j] = 0;
-
+
+ Instance->Log(DEBUG,"Hosts set.");
+
// set the registration timeout for this user
unsigned long class_regtimeout = 90;
int class_flood = 0;
long class_sqmax = 262144; // 256kb
long class_rqmax = 4096; // 4k
+ Instance->Log(DEBUG,"Class stuff set.");
+
for (ClassVector::iterator i = Instance->Config->Classes.begin(); i != Instance->Config->Classes.end(); i++)
{
if ((i->type == CC_ALLOW) && (match(ipaddr,i->host.c_str(),true)))
}
}
+ Instance->Log(DEBUG,"nping etc set.");
+
New->nping = Instance->Time() + New->pingmax + Instance->Config->dns_timeout;
New->timeout = Instance->Time() + class_regtimeout;
New->flood = class_flood;
New->sendqmax = class_sqmax;
New->recvqmax = class_rqmax;
+ Instance->Log(DEBUG,"Push back to local users.");
Instance->local_users.push_back(New);
+ Instance->Log(DEBUG,"Check softlimit: %d %d %d",Instance->local_users.size(), Instance->Config->SoftLimit, MAXCLIENTS);
if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
{
+ Instance->Log(DEBUG,"Check softlimit failed");
+ Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
userrec::QuitUser(Instance, New,"No more connections allowed");
return;
}
+ Instance->Log(DEBUG,"Softlimit passed.");
+
/*
* XXX -
* this is done as a safety check to keep the file descriptors within range of fd_ref_table.
* which for the time being is a physical impossibility (even the largest networks dont have more
* than about 10,000 users on ONE server!)
*/
- if ((unsigned)socket >= MAX_DESCRIPTORS)
+ if ((unsigned int)socket >= MAX_DESCRIPTORS)
{
userrec::QuitUser(Instance, New, "Server is full");
return;
}
+ Instance->Log(DEBUG,"socket < MAX_DESCRIPTORS passed.");
+
ELine* e = Instance->XLines->matches_exception(New);
if (!e)
{
+ Instance->Log(DEBUG,"Doesnt match eline.");
ZLine* r = Instance->XLines->matches_zline(ipaddr);
if (r)
{
+ Instance->Log(DEBUG,"Matches zline.");
char reason[MAXBUF];
snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
userrec::QuitUser(Instance, New, reason);
return;
}
+ Instance->Log(DEBUG,"Doesnt match zline.");
}
+ Instance->Log(DEBUG,"Check before AddFd.");
+
if (socket > -1)
{
+ Instance->Log(DEBUG,"Adding fd.");
if (!Instance->SE->AddFd(New))
{
+ Instance->Log(DEBUG,"Oops, fd already exists");
userrec::QuitUser(Instance, New, "Internal error handling connection");
return;
}
* changes dont go out onto the network and produce 'fake direction'.
*/
FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
- FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
+
this->registered = REG_ALL;
+
+ FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
+
ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
}