#include "testsuite.h"
InspIRCd* ServerInstance = NULL;
-int* mysig = NULL;
/** Seperate from the other casemap tables so that code *can* still exclusively rely on RFC casemapping
* if it must.
/* Must be deleted before modes as it decrements modelines */
if (FakeClient)
FakeClient->cull();
- if (Res)
- Res->cull();
DeleteZero(this->FakeClient);
DeleteZero(this->Users);
DeleteZero(this->Modes);
DeleteZero(this->BanCache);
DeleteZero(this->SNO);
DeleteZero(this->Config);
- DeleteZero(this->Res);
DeleteZero(this->chanlist);
DeleteZero(this->PI);
DeleteZero(this->Threads);
this->Parser = 0;
this->XLines = 0;
this->Modes = 0;
- this->Res = 0;
this->ConfigThread = NULL;
this->FakeClient = NULL;
/* Default implementation does nothing */
this->PI = new ProtocolInterface;
- this->s_signal = 0;
-
// Create base manager classes early, so nothing breaks
this->Users = new UserManager;
Logs->OpenFileLogs();
ModeParser::InitBuiltinModes();
- this->Res = new DNS();
-
- /*
- * Initialise SID/UID.
- * For an explanation as to exactly how this works, and why it works this way, see GetUID().
- * -- w00t
- */
+ // If we don't have a SID, generate one based on the server name and the server description
if (Config->sid.empty())
- {
- // Generate one
- unsigned int sid = 0;
- char sidstr[4];
-
- for (const char* x = Config->ServerName.c_str(); *x; ++x)
- sid = 5 * sid + *x;
- for (const char* y = Config->ServerDesc.c_str(); *y; ++y)
- sid = 5 * sid + *y;
- sprintf(sidstr, "%03d", sid % 1000);
+ Config->sid = UIDGenerator::GenerateSID(Config->ServerName, Config->ServerDesc);
- Config->sid = sidstr;
- }
+ // Initialize the UID generator with our sid
+ this->UIDGen.init(Config->sid);
/* set up fake client again this time with the correct uid */
this->FakeClient = new FakeUser(Config->sid, Config->ServerName);
GlobalCulls.Apply();
AtomicActions.Run();
- if (this->s_signal)
+ if (s_signal)
{
this->SignalHandler(s_signal);
- this->s_signal = 0;
+ s_signal = 0;
}
}
/**********************************************************************************/
-/**
- * An ircd in five lines! bwahahaha. ahahahahaha. ahahah *cough*.
- */
-
/* this returns true when all modules are satisfied that the user should be allowed onto the irc server
* (until this returns true, a user will block in the waiting state, waiting to connect up to the
* registration timeout maximum seconds)
return (res == MOD_RES_PASSTHRU);
}
+sig_atomic_t InspIRCd::s_signal = 0;
+
void InspIRCd::SetSignal(int signal)
{
- *mysig = signal;
+ s_signal = signal;
}
/* On posix systems, the flow of the program starts right here, with
ENTRYPOINT
{
new InspIRCd(argc, argv);
- mysig = &ServerInstance->s_signal;
ServerInstance->Run();
delete ServerInstance;
return 0;