#include <sstream>
#include <vector>
#include <deque>
-#include <sched.h>
-#ifdef THREADED_DNS
-#include <pthread.h>
-#endif
#include "users.h"
#include "ctables.h"
#include "globals.h"
#include "commands.h"
#include "xline.h"
#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
log(DEBUG,"Processing user with fd %d",cu->fd);
- if (Config->GetIOHook(cu->port))
+ if (Config->GetIOHook(cu->GetPort()))
{
int result2 = 0;
int MOD_RESULT = 0;
try
{
- MOD_RESULT = Config->GetIOHook(cu->port)->OnRawSocketRead(cu->fd,data,65535,result2);
+ MOD_RESULT = Config->GetIOHook(cu->GetPort())->OnRawSocketRead(cu->fd,data,65535,result2);
log(DEBUG,"Data result returned by module: %d",MOD_RESULT);
}
catch (ModuleException& modexcept)
if (!current->AddBuffer(data))
{
// AddBuffer returned false, theres too much data in the user's buffer and theyre up to no good.
- if (current->registered == 7)
+ if (current->registered == REG_ALL)
{
// Make sure they arn't flooding long lines.
if (TIME > current->reset_due)
}
else
{
- WriteOpers("*** Excess flood from %s",(char*)inet_ntoa(current->ip4));
- log(DEFAULT,"Excess flood from: %s",(char*)inet_ntoa(current->ip4));
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)inet_ntoa(current->ip4));
+ WriteOpers("*** Excess flood from %s",current->GetIPString());
+ log(DEFAULT,"Excess flood from: %s",current->GetIPString());
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
if (current->recvq.length() > (unsigned)Config->NetBufferSize)
{
- if (current->registered == 7)
+ if (current->registered == REG_ALL)
{
kill_link(current,"RecvQ exceeded");
}
else
{
- WriteOpers("*** Excess flood from %s",(char*)inet_ntoa(current->ip4));
- log(DEFAULT,"Excess flood from: %s",(char*)inet_ntoa(current->ip4));
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)inet_ntoa(current->ip4));
+ WriteOpers("*** Excess flood from %s",current->GetIPString());
+ log(DEFAULT,"Excess flood from: %s",current->GetIPString());
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
if ((++floodlines > current->flood) && (current->flood != 0))
{
- if (current->registered == 7)
+ if (current->registered == REG_ALL)
{
log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
}
else
{
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)inet_ntoa(current->ip4));
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
{
CullList GlobalGoners;
- for (std::vector<userrec*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
+ /* XXX: IT IS NOT SAFE TO USE AN ITERATOR HERE. DON'T EVEN THINK ABOUT IT. */
+ for (unsigned long count2 = 0; count2 != local_users.size(); count2++)
{
- /* Sanity checks for corrupted iterators (yes, really) */
- userrec* curr = NULL;
+ if (count2 >= local_users.size())
+ break;
- if (*count2)
- curr = (userrec*)(*count2);
- if ((long)curr == -1)
- return;
+ userrec* curr = local_users[count2];
if (curr)
{
* registration timeout -- didnt send USER/NICK/HOST
* in the time specified in their connection class.
*/
- if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != 7))
+ if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != REG_ALL))
{
log(DEBUG,"InspIRCd: registration timeout: %s",curr->nick);
+ //ZapThisDns(curr->fd);
GlobalGoners.AddItem(curr,"Registration timeout");
continue;
}
-
/*
* user has signed on with USER/NICK/PASS, and dns has completed, all the modules
* say this user is ok to proceed, fully connect them.
*/
- if ((TIME > curr->signon) && (curr->registered == 3) && (AllModulesReportReady(curr)))
+ if ((TIME > curr->signon) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
{
curr->dns_done = true;
+ //ZapThisDns(curr->fd);
ServerInstance->stats->statsDnsBad++;
FullConnectUser(curr,&GlobalGoners);
continue;
}
-
- if ((curr->dns_done) && (curr->registered == 3) && (AllModulesReportReady(curr)))
+ if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
{
log(DEBUG,"dns done, registered=3, and modules ready, OK");
FullConnectUser(curr,&GlobalGoners);
+ //ZapThisDns(curr->fd);
continue;
}
-
// It's time to PING this user. Send them a ping.
- if ((TIME > curr->nping) && (curr->registered == 7))
+ if ((TIME > curr->nping) && (curr->registered == REG_ALL))
{
// This user didn't answer the last ping, remove them
if (!curr->lastping)
{
GlobalGoners.AddItem(curr,"Ping timeout");
+ curr->lastping = 1;
+ curr->nping = TIME+curr->pingmax;
continue;
}
-
Write(curr->fd,"PING :%s",Config->ServerName);
curr->lastping = 0;
curr->nping = TIME+curr->pingmax;
* We can flush the write buffer as the last thing we do, because if they
* match any of the above conditions its no use flushing their buffer anyway.
*/
+
curr->FlushWriteBuf();
-
if (*curr->GetWriteError())
{
GlobalGoners.AddItem(curr,curr->GetWriteError());
continue;
}
}
+
}
+
/* Remove all the queued users who are due to be quit, free memory used. */
GlobalGoners.Apply();
}