FOREACH_MOD(I_OnRehash,OnRehash(""));
}
-void InspIRCd::SetSignals()
+void InspIRCd::SetSignals(bool SEGVHandler)
{
signal (SIGALRM, SIG_IGN);
signal (SIGHUP, Rehash);
signal (SIGPIPE, SIG_IGN);
signal (SIGTERM, Exit);
- signal (SIGSEGV, Error);
+ if (SEGVHandler)
+ signal (SIGSEGV, Error);
}
bool InspIRCd::DaemonSeed()
InspIRCd::InspIRCd(int argc, char** argv)
{
+ bool SEGVHandler = false;
+
this->Start();
module_sockets.clear();
this->startup_time = time(NULL);
{
printf("WARNING: The `-nolimit' option is deprecated, and now on by default. This behaviour may change in the future.\n");
}
+ else if (!strcmp(argv[i],"-notraceback"))
+ {
+ SEGVHandler = false;
+ }
else if (!strcmp(argv[i],"-logfile"))
{
if (argc > i+1)
printf("ERROR: The -logfile parameter must be followed by a log file name and path.\n");
Exit(ERROR);
}
+ i++;
+ }
+ else
+ {
+ printf("Usage: %s [-nofork] [-nolog] [-debug] [-wait] [-nolimit] [-notraceback] [-logfile <filename>]\n",argv[0]);
+ Exit(ERROR);
}
}
}
this->stats = new serverstats();
this->Parser = new CommandParser();
Config->ClearStack();
- Config->Read(true,NULL);
+ Config->Read(true, NULL);
CheckRoot();
this->ModeGrok = new ModeParser();
AddServerName(Config->ServerName);
memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
printf("\n");
- this->SetSignals();
+ this->SetSignals(SEGVHandler);
if (!Config->nofork)
{
if (!this->DaemonSeed())
}
// found the module
+ log(DEBUG,"Removing dependent commands...");
+ Parser->RemoveCommands(filename);
log(DEBUG,"Deleting module...");
this->EraseModule(j);
log(DEBUG,"Erasing module entry...");
this->EraseFactory(j);
- log(DEBUG,"Removing dependent commands...");
- Parser->RemoveCommands(filename);
log(DEFAULT,"Module %s unloaded",filename);
MODCOUNT--;
BuildISupport();
return false;
}
}
- ircd_module* a = new ircd_module(modfile);
- factory[MODCOUNT+1] = a;
- if (factory[MODCOUNT+1]->LastError())
- {
- log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
- snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
- return false;
- }
try
{
- if (factory[MODCOUNT+1]->factory)
+ ircd_module* a = new ircd_module(modfile);
+ factory[MODCOUNT+1] = a;
+ if (factory[MODCOUNT+1]->LastError())
+ {
+ log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
+ snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
+ return false;
+ }
+ if ((int)factory[MODCOUNT+1]->factory != -1)
{
Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
modules[MODCOUNT+1] = m;
else
{
log(DEFAULT,"Unable to load %s",modfile);
- snprintf(MODERR,MAXBUF,"Factory function failed!");
+ snprintf(MODERR,MAXBUF,"Factory function failed: Probably missing init_module() entrypoint.");
return false;
}
}
int InspIRCd::Run()
{
/* Until THIS point, ServerInstance == NULL */
-
+
this->Res = new DNS();
LoadAllModules(this);
/* Just in case no modules were loaded - fix for bug #101 */
this->BuildISupport();
- printf("\nInspIRCd is now running!\n");
-
- if (!Config->nofork)
+ if (!stats->BoundPortCount)
{
- fclose(stdout);
- fclose(stderr);
- fclose(stdin);
+ printf("\nI couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
+ Exit(ERROR);
}
/* Add the listening sockets used for client inbound connections
* to the socket engine
*/
+ log(DEBUG,"%d listeners",stats->BoundPortCount);
for (unsigned long count = 0; count < stats->BoundPortCount; count++)
- SE->AddFd(Config->openSockfd[count],true,X_LISTEN);
+ {
+ log(DEBUG,"Add listener: %d",Config->openSockfd[count]);
+ if (!SE->AddFd(Config->openSockfd[count],true,X_LISTEN))
+ {
+ printf("\nEH? Could not add listener to socketengine. You screwed up, aborting.\n");
+ Exit(ERROR);
+ }
+ }
+
+ if (!Config->nofork)
+ {
+ fclose(stdout);
+ fclose(stderr);
+ fclose(stdin);
+ }
+
+ printf("\nInspIRCd is now running!\n");
this->WritePID(Config->PID);
int main(int argc, char** argv)
{
-
- unsigned char addr[] = {0xCC,0xAA,0xCC,0xAA};
- unsigned char mask[] = {0xCC,0xAA,0xC0,0xAA};
-
- printf("%d",MatchCIDRBits(addr, mask, 20));
-
- exit(0);
+ /* This is a MatchCIDR() test suite -
+ printf("Should be 0: %d\n",MatchCIDR("127.0.0.1","1.2.3.4/8"));
+ printf("Should be 1: %d\n",MatchCIDR("127.0.0.1","127.0.0.0/8"));
+ printf("Should be 1: %d\n",MatchCIDR("127.0.0.1","127.0.0.0/18"));
+ printf("Should be 0: %d\n",MatchCIDR("3ffe::0","2fc9::0/16"));
+ printf("Should be 1: %d\n",MatchCIDR("3ffe:1:3::0", "3ffe:1::0/32"));
+ exit(0); */
try
{