#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)
}
else
{
- WriteOpers("*** Excess flood from %s",(char*)insp_ntoa(current->ip4));
- log(DEFAULT,"Excess flood from: %s",(char*)insp_ntoa(current->ip4));
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_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);
}
}
else
{
- WriteOpers("*** Excess flood from %s",(char*)insp_ntoa(current->ip4));
- log(DEFAULT,"Excess flood from: %s",(char*)insp_ntoa(current->ip4));
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_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);
}
}
else
{
- add_zline(120,Config->ServerName,"Flood from unregistered connection",(char*)insp_ntoa(current->ip4));
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
{
CullList GlobalGoners;
- int cfd = 0;
-
/* 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++)
{
if (curr)
{
- cfd = curr->fd;
-
- if ((cfd > -1) && (cfd < MAX_DESCRIPTORS) && (fd_ref_table[cfd] == curr) && (curr))
+ /*
+ * registration timeout -- didnt send USER/NICK/HOST
+ * in the time specified in their connection class.
+ */
+ if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != REG_ALL))
{
- /*
- * registration timeout -- didnt send USER/NICK/HOST
- * in the time specified in their connection class.
- */
- 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 == REG_NICKUSER) && (AllModulesReportReady(curr)))
- {
- curr->dns_done = true;
- ZapThisDns(curr->fd);
- ServerInstance->stats->statsDnsBad++;
- FullConnectUser(curr,&GlobalGoners);
- continue;
- }
-
- if ((fd_ref_table[cfd] != curr) && (curr))
- /* Somebody blatted this user in OnCheckReady (!) */
- continue;
-
- 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;
- }
-
- if ((fd_ref_table[cfd] != curr) && (curr))
- /* Somebody blatted this user in OnCheckReady (!) */
- continue;
-
- // It's time to PING this user. Send them a ping.
- if ((TIME > curr->nping) && (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 == REG_NICKUSER) && (AllModulesReportReady(curr)))
+ {
+ curr->dns_done = true;
+ //ZapThisDns(curr->fd);
+ ServerInstance->stats->statsDnsBad++;
+ FullConnectUser(curr,&GlobalGoners);
+ continue;
+ }
+ 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 == REG_ALL))
+ {
+ // This user didn't answer the last ping, remove them
+ if (!curr->lastping)
{
- // 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;
+ 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.
*/
-
- /* Check again that theyre still here (something above may have changed that) */
- if ((cfd > -1) && (cfd < MAX_DESCRIPTORS) && (fd_ref_table[cfd] == curr) && (curr))
+
+ curr->FlushWriteBuf();
+ if (*curr->GetWriteError())
{
- curr->FlushWriteBuf();
- if (*curr->GetWriteError())
- {
- GlobalGoners.AddItem(curr,curr->GetWriteError());
- continue;
- }
+ GlobalGoners.AddItem(curr,curr->GetWriteError());
+ continue;
}
}
+
}
+
/* Remove all the queued users who are due to be quit, free memory used. */
GlobalGoners.Apply();
}