]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/inspircd.cpp
Add options:maxtargets that was somehow omitted, fixes bug #400 (Reported by DarkStorm)
[user/henk/code/inspircd.git] / src / inspircd.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "configreader.h"
16 #include <signal.h>
17
18 #ifndef WIN32
19         #include <dirent.h>
20         #include <unistd.h>
21         #include <sys/resource.h>
22         #include <dlfcn.h>
23         #include <getopt.h>
24
25         /* Some systems don't define RUSAGE_SELF. This should fix them. */
26         #ifndef RUSAGE_SELF
27                 #define RUSAGE_SELF 0
28         #endif
29 #endif
30
31 #include <exception>
32 #include <fstream>
33 #include "modules.h"
34 #include "mode.h"
35 #include "xline.h"
36 #include "socketengine.h"
37 #include "inspircd_se_config.h"
38 #include "socket.h"
39 #include "typedefs.h"
40 #include "command_parse.h"
41 #include "exitcodes.h"
42 #include "caller.h"
43
44 using irc::sockets::insp_ntoa;
45 using irc::sockets::insp_inaddr;
46 using irc::sockets::insp_sockaddr;
47
48 InspIRCd* SI = NULL;
49 int* mysig = NULL;
50
51
52 /* Burlex: Moved from exitcodes.h -- due to duplicate symbols */
53 const char* ExitCodes[] =
54 {
55                 "No error", /* 0 */
56                 "DIE command", /* 1 */
57                 "execv() failed", /* 2 */
58                 "Internal error", /* 3 */
59                 "Config file error", /* 4 */
60                 "Logfile error", /* 5 */
61                 "POSIX fork failed", /* 6 */
62                 "Bad commandline parameters", /* 7 */
63                 "No ports could be bound", /* 8 */
64                 "Can't write PID file", /* 9 */
65                 "SocketEngine could not initialize", /* 10 */
66                 "Refusing to start up as root", /* 11 */
67                 "Found a <die> tag!", /* 12 */
68                 "Couldn't load module on startup", /* 13 */
69                 "Could not create windows forked process", /* 14 */
70                 "Received SIGTERM", /* 15 */
71 };
72
73 void InspIRCd::Cleanup()
74 {
75         std::vector<std::string> mymodnames;
76         int MyModCount = this->GetModuleCount();
77
78         if (Config)
79         {
80                 for (unsigned int i = 0; i < Config->ports.size(); i++)
81                 {
82                         /* This calls the constructor and closes the listening socket */
83                         delete Config->ports[i];
84                 }
85
86                 Config->ports.clear();
87         }
88
89         /* Close all client sockets, or the new process inherits them */
90         for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
91         {
92                 (*i)->SetWriteError("Server shutdown");
93                 (*i)->CloseSocket();
94         }
95
96         /* We do this more than once, so that any service providers get a
97          * chance to be unhooked by the modules using them, but then get
98          * a chance to be removed themsleves.
99          */
100         for (int tries = 0; tries < 3; tries++)
101         {
102                 MyModCount = this->GetModuleCount();
103                 mymodnames.clear();
104
105                 if (MyModCount)
106                 {
107                         /* Unload all modules, so they get a chance to clean up their listeners */
108                         for (int j = 0; j <= MyModCount; j++)
109                                 mymodnames.push_back(Config->module_names[j]);
110
111                         for (int k = 0; k <= MyModCount; k++)
112                                 this->UnloadModule(mymodnames[k].c_str());
113                 }
114         }
115
116         /* Close logging */
117         if (this->Logger)
118                 this->Logger->Close();
119
120         /* Cleanup Server Names */
121         for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
122                 delete (*itr);
123 }
124
125 void InspIRCd::Restart(const std::string &reason)
126 {
127         /* SendError flushes each client's queue,
128          * regardless of writeability state
129          */
130         this->SendError(reason);
131
132         this->Cleanup();
133
134         /* Figure out our filename (if theyve renamed it, we're boned) */
135         std::string me;
136
137 #ifdef WINDOWS
138         char module[MAX_PATH];
139         if (GetModuleFileName(NULL, module, MAX_PATH))
140                 me = module;
141 #else
142         me = Config->MyDir + "/inspircd";
143 #endif
144
145         if (execv(me.c_str(), Config->argv) == -1)
146         {
147                 /* Will raise a SIGABRT if not trapped */
148                 throw CoreException(std::string("Failed to execv()! error: ") + strerror(errno));
149         }
150 }
151
152 void InspIRCd::ResetMaxBans()
153 {
154         for (chan_hash::const_iterator i = chanlist->begin(); i != chanlist->end(); i++)
155                 i->second->ResetMaxBans();
156 }
157
158 /** Because hash_map doesnt free its buckets when we delete items (this is a 'feature')
159  * we must occasionally rehash the hash (yes really).
160  * We do this by copying the entries from the old hash to a new hash, causing all
161  * empty buckets to be weeded out of the hash. We dont do this on a timer, as its
162  * very expensive, so instead we do it when the user types /REHASH and expects a
163  * short delay anyway.
164  */
165 void InspIRCd::RehashUsersAndChans()
166 {
167         user_hash* old_users = this->clientlist;
168         user_hash* old_uuid  = this->uuidlist;
169         chan_hash* old_chans = this->chanlist;
170
171         this->clientlist = new user_hash();
172         this->uuidlist = new user_hash();
173         this->chanlist = new chan_hash();
174
175         for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
176                 this->clientlist->insert(*n);
177
178         delete old_users;
179
180         for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++)
181                 this->uuidlist->insert(*n);
182
183         delete old_uuid;
184
185         for (chan_hash::const_iterator n = old_chans->begin(); n != old_chans->end(); n++)
186                 this->chanlist->insert(*n);
187
188         delete old_chans;
189 }
190
191 void InspIRCd::CloseLog()
192 {
193         if (this->Logger)
194                 this->Logger->Close();
195 }
196
197 void InspIRCd::SetSignals()
198 {
199 #ifndef WIN32
200         signal(SIGALRM, SIG_IGN);
201         signal(SIGHUP, InspIRCd::SetSignal);
202         signal(SIGPIPE, SIG_IGN);
203         signal(SIGCHLD, SIG_IGN);
204 #endif
205         signal(SIGTERM, InspIRCd::SetSignal);
206 }
207
208 void InspIRCd::QuickExit(int status)
209 {
210         exit(0);
211 }
212
213 bool InspIRCd::DaemonSeed()
214 {
215 #ifdef WINDOWS
216         printf_c("InspIRCd Process ID: \033[1;32m%lu\033[0m\n", GetCurrentProcessId());
217         return true;
218 #else
219         signal(SIGTERM, InspIRCd::QuickExit);
220
221         int childpid;
222         if ((childpid = fork ()) < 0)
223                 return false;
224         else if (childpid > 0)
225         {
226                 /* We wait here for the child process to kill us,
227                  * so that the shell prompt doesnt come back over
228                  * the output.
229                  * Sending a kill with a signal of 0 just checks
230                  * if the child pid is still around. If theyre not,
231                  * they threw an error and we should give up.
232                  */
233                 while (kill(childpid, 0) != -1)
234                         sleep(1);
235                 exit(0);
236         }
237         setsid ();
238         umask (007);
239         printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid());
240
241         signal(SIGTERM, InspIRCd::SetSignal);
242
243         rlimit rl;
244         if (getrlimit(RLIMIT_CORE, &rl) == -1)
245         {
246                 this->Log(DEFAULT,"Failed to getrlimit()!");
247                 return false;
248         }
249         else
250         {
251                 rl.rlim_cur = rl.rlim_max;
252                 if (setrlimit(RLIMIT_CORE, &rl) == -1)
253                         this->Log(DEFAULT,"setrlimit() failed, cannot increase coredump size.");
254         }
255
256         return true;
257 #endif
258 }
259
260 void InspIRCd::WritePID(const std::string &filename)
261 {
262         std::string fname = (filename.empty() ? "inspircd.pid" : filename);
263         if (*(fname.begin()) != '/')
264         {
265                 std::string::size_type pos;
266                 std::string confpath = this->ConfigFileName;
267                 if ((pos = confpath.rfind("/")) != std::string::npos)
268                 {
269                         /* Leaves us with just the path */
270                         fname = confpath.substr(0, pos) + std::string("/") + fname;
271                 }
272         }
273         std::ofstream outfile(fname.c_str());
274         if (outfile.is_open())
275         {
276                 outfile << getpid();
277                 outfile.close();
278         }
279         else
280         {
281                 printf("Failed to write PID-file '%s', exiting.\n",fname.c_str());
282                 this->Log(DEFAULT,"Failed to write PID-file '%s', exiting.",fname.c_str());
283                 Exit(EXIT_STATUS_PID);
284         }
285 }
286
287 InspIRCd::InspIRCd(int argc, char** argv)
288         : ModCount(0),
289           GlobalCulls(this),
290
291          /* Functor initialisation. Note that the ordering here is very important. */
292          HandleProcessUser(this),
293          HandleIsNick(this),
294          HandleIsIdent(this),
295          HandleFindDescriptor(this),
296          HandleFloodQuitUser(this),
297
298          /* Functor pointer initialisation. Must match the order of the list above */
299          ProcessUser(&HandleProcessUser),
300          IsNick(&HandleIsNick),
301          IsIdent(&HandleIsIdent),
302          FindDescriptor(&HandleFindDescriptor),
303          FloodQuitUser(&HandleFloodQuitUser)
304
305 {
306
307         int found_ports = 0;
308         FailedPortList pl;
309         int do_version = 0, do_nofork = 0, do_debug = 0, do_nolog = 0, do_root = 0;    /* flag variables */
310         char c = 0;
311
312         modules.resize(255);
313         factory.resize(255);
314         memset(&server, 0, sizeof(server));
315         memset(&client, 0, sizeof(client));
316
317         SocketEngineFactory* SEF = new SocketEngineFactory();
318         SE = SEF->Create(this);
319         delete SEF;
320
321         this->s_signal = 0;
322
323         this->unregistered_count = 0;
324
325         this->clientlist = new user_hash();
326         this->uuidlist = new user_hash();
327         this->chanlist = new chan_hash();
328
329         this->Config = new ServerConfig(this);
330
331         this->Config->argv = argv;
332         this->Config->argc = argc;
333
334         if (chdir(Config->GetFullProgDir().c_str()))
335         {
336                 printf("Unable to change to my directory: %s\nAborted.", strerror(errno));
337                 exit(0);
338         }
339
340         this->Config->opertypes.clear();
341         this->Config->operclass.clear();
342         this->SNO = new SnomaskManager(this);
343         this->TIME = this->OLDTIME = this->startup_time = time(NULL);
344         this->time_delta = 0;
345         this->next_call = this->TIME + 3;
346         srand(this->TIME);
347
348         *this->LogFileName = 0;
349         strlcpy(this->ConfigFileName, CONFIG_FILE, MAXBUF);
350
351         struct option longopts[] =
352         {
353                 { "nofork",     no_argument,            &do_nofork,     1       },
354                 { "logfile",    required_argument,      NULL,           'f'     },
355                 { "config",     required_argument,      NULL,           'c'     },
356                 { "debug",      no_argument,            &do_debug,      1       },
357                 { "nolog",      no_argument,            &do_nolog,      1       },
358                 { "runasroot",  no_argument,            &do_root,       1       },
359                 { "version",    no_argument,            &do_version,    1       },
360                 { 0, 0, 0, 0 }
361         };
362
363         while ((c = getopt_long_only(argc, argv, ":f:", longopts, NULL)) != -1)
364         {
365                 switch (c)
366                 {
367                         case 'f':
368                                 /* Log filename was set */
369                                 strlcpy(LogFileName, optarg, MAXBUF);
370                         break;
371                         case 'c':
372                                 /* Config filename was set */
373                                 strlcpy(ConfigFileName, optarg, MAXBUF);
374                         break;
375                         case 0:
376                                 /* getopt_long_only() set an int variable, just keep going */
377                         break;
378                         default:
379                                 /* Unknown parameter! DANGER, INTRUDER.... err.... yeah. */
380                                 printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile <filename>] [--runasroot] [--version] [--config <config>]\n", argv[0]);
381                                 Exit(EXIT_STATUS_ARGV);
382                         break;
383                 }
384         }
385
386         if (do_version)
387         {
388                 printf("\n%s r%s\n", VERSION, REVISION);
389                 Exit(EXIT_STATUS_NOERROR);
390         }
391
392 #ifdef WIN32
393
394         // Handle forking
395         if(!do_nofork)
396         {
397                 DWORD ExitCode = WindowsForkStart(this);
398                 if(ExitCode)
399                         Exit(ExitCode);
400         }
401
402         // Set up winsock
403         WSADATA wsadata;
404         WSAStartup(MAKEWORD(2,0), &wsadata);
405
406         ChangeWindowsSpecificPointers(this);
407 #endif
408         if (!ServerConfig::FileExists(this->ConfigFileName))
409         {
410                 printf("ERROR: Cannot open config file: %s\nExiting...\n", this->ConfigFileName);
411                 this->Log(DEFAULT,"Unable to open config file %s", this->ConfigFileName);
412                 Exit(EXIT_STATUS_CONFIG);
413         }
414
415         printf_c("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
416         printf_c("(C) InspIRCd Development Team.\033[0m\n\n");
417         printf_c("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey, Burlex\033[0m\n");
418         printf_c("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
419
420         /* Set the finished argument values */
421         Config->nofork = do_nofork;
422         Config->forcedebug = do_debug;
423         Config->writelog = !do_nolog;
424
425         strlcpy(Config->MyExecutable,argv[0],MAXBUF);
426
427         if (!this->OpenLog(argv, argc))
428         {
429                 printf("ERROR: Could not open logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno));
430                 Exit(EXIT_STATUS_LOG);
431         }
432
433         this->stats = new serverstats();
434         this->Timers = new TimerManager(this);
435         this->Parser = new CommandParser(this);
436         this->XLines = new XLineManager(this);
437         Config->ClearStack();
438         Config->Read(true, NULL);
439
440         if (!do_root)
441                 this->CheckRoot();
442         else
443         {
444                 printf("* WARNING * WARNING * WARNING * WARNING * WARNING * \n\n");
445                 printf("YOU ARE RUNNING INSPIRCD AS ROOT. THIS IS UNSUPPORTED\n");
446                 printf("AND IF YOU ARE HACKED, CRACKED, SPINDLED OR MUTILATED\n");
447                 printf("OR ANYTHING ELSE UNEXPECTED HAPPENS TO YOU OR YOUR\n");
448                 printf("SERVER, THEN IT IS YOUR OWN FAULT. IF YOU DID NOT MEAN\n");
449                 printf("TO START INSPIRCD AS ROOT, HIT CTRL+C NOW AND RESTART\n");
450                 printf("THE PROGRAM AS A NORMAL USER. YOU HAVE BEEN WARNED!\n");
451                 printf("\nInspIRCd starting in 20 seconds, ctrl+c to abort...\n");
452                 sleep(20);
453         }
454
455         this->SetSignals();
456
457         if (!Config->nofork)
458         {
459                 if (!this->DaemonSeed())
460                 {
461                         printf("ERROR: could not go into daemon mode. Shutting down.\n");
462                         Log(DEFAULT,"ERROR: could not go into daemon mode. Shutting down.");
463                         Exit(EXIT_STATUS_FORK);
464                 }
465         }
466
467         SE->RecoverFromFork();
468
469         this->Modes = new ModeParser(this);
470         this->AddServerName(Config->ServerName);
471         CheckDie();
472         int bounditems = BindPorts(true, found_ports, pl);
473
474         for(int t = 0; t < 255; t++)
475                 Config->global_implementation[t] = 0;
476
477         memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
478
479         printf("\n");
480
481         this->Res = new DNS(this);
482
483         this->LoadAllModules();
484         /* Just in case no modules were loaded - fix for bug #101 */
485         this->BuildISupport();
486         InitializeDisabledCommands(Config->DisabledCommands, this);
487
488         if ((Config->ports.size() == 0) && (found_ports > 0))
489         {
490                 printf("\nERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
491                 Log(DEFAULT,"ERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?");
492                 Exit(EXIT_STATUS_BIND);
493         }
494
495         if (Config->ports.size() != (unsigned int)found_ports)
496         {
497                 printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports);
498                 printf("The following port(s) failed to bind:\n");
499                 int j = 1;
500                 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
501                 {
502                         printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second);
503                 }
504         }
505 #ifndef WINDOWS
506         if (!Config->nofork)
507         {
508                 if (kill(getppid(), SIGTERM) == -1)
509                 {
510                         printf("Error killing parent process: %s\n",strerror(errno));
511                         Log(DEFAULT,"Error killing parent process: %s",strerror(errno));
512                 }
513         }
514
515         if (isatty(0) && isatty(1) && isatty(2))
516         {
517                 /* We didn't start from a TTY, we must have started from a background process -
518                  * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont
519                  * close stdin/stdout
520                  */
521                 if (!do_nofork)
522                 {
523                         fclose(stdin);
524                         fclose(stderr);
525                         fclose(stdout);
526                 }
527                 else
528                 {
529                         Log(DEFAULT,"Keeping pseudo-tty open as we are running in the foreground.");
530                 }
531         }
532 #else
533         WindowsIPC = new IPC(this);
534         if(!Config->nofork)
535         {
536                 WindowsForkKillOwner(this);
537                 FreeConsole();
538         }
539 #endif
540
541
542         /*
543          * Initialise UID. XXX, we need to read SID from config, and use it instead of 000.
544          * For an explanation as to exactly how this works, and why it works this way, see GetUID().
545          *   -- w00t
546          */
547         int i;
548
549
550         /* Generate SID */
551         size_t sid = 0;
552         for (const char* x = Config->ServerName; *x; ++x)
553                 sid = 5 * sid + *x;
554         for (const char* y = Config->ServerDesc; *y; ++y)
555                 sid = 5 * sid + *y;
556         sid = sid % 999;
557         current_uid[0] = sid / 100 + 48;
558         current_uid[1] = ((sid / 10) % 10) + 48;
559         current_uid[2] = sid % 10 + 48;
560
561         /* Initialise UID */
562         for(i = 3; i < UUID_LENGTH - 1; i++)
563                 current_uid[i] = 'A';
564
565         printf("\nInspIRCd is now running!\n");
566         Log(DEFAULT,"Startup complete.");
567
568         this->WritePID(Config->PID);
569 }
570
571 void InspIRCd::DoOneIteration(bool process_module_sockets)
572 {
573 #ifndef WIN32
574         static rusage ru;
575 #else
576         static time_t uptime;
577         static struct tm * stime;
578         static char window_title[100];
579 #endif
580
581         /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
582          * Once per loop iteration is pleanty.
583          */
584         OLDTIME = TIME;
585         TIME = time(NULL);
586
587         /* Run background module timers every few seconds
588          * (the docs say modules shouldnt rely on accurate
589          * timing using this event, so we dont have to
590          * time this exactly).
591          */
592         if (TIME != OLDTIME)
593         {
594                 if (TIME < OLDTIME)
595                         WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
596                 if ((TIME % 3600) == 0)
597                 {
598                         this->RehashUsersAndChans();
599                         FOREACH_MOD_I(this, I_OnGarbageCollect, OnGarbageCollect());
600                 }
601                 Timers->TickTimers(TIME);
602                 this->DoBackgroundUserStuff(TIME);
603
604                 if ((TIME % 5) == 0)
605                 {
606                         XLines->expire_lines();
607                         FOREACH_MOD_I(this,I_OnBackgroundTimer,OnBackgroundTimer(TIME));
608                         Timers->TickMissedTimers(TIME);
609                 }
610 #ifndef WIN32
611                 /* Same change as in cmd_stats.cpp, use RUSAGE_SELF rather than '0' -- Om */
612                 if (!getrusage(RUSAGE_SELF, &ru))
613                 {
614                         gettimeofday(&this->stats->LastSampled, NULL);
615                         this->stats->LastCPU = ru.ru_utime;
616                 }
617 #else
618                 WindowsIPC->Check();
619
620                 if(Config->nofork)
621                 {
622                         uptime = Time() - startup_time;
623                         stime = gmtime(&uptime);
624                         snprintf(window_title, 100, "InspIRCd - %u clients, %u accepted connections - Up %u days, %.2u:%.2u:%.2u",
625                                 LocalUserCount(), stats->statsAccept, stime->tm_yday, stime->tm_hour, stime->tm_min, stime->tm_sec);
626                         SetConsoleTitle(window_title);
627                 }
628 #endif
629         }
630
631         /* Call the socket engine to wait on the active
632          * file descriptors. The socket engine has everything's
633          * descriptors in its list... dns, modules, users,
634          * servers... so its nice and easy, just one call.
635          * This will cause any read or write events to be
636          * dispatched to their handlers.
637          */
638         this->SE->DispatchEvents();
639
640         /* if any users was quit, take them out */
641         this->GlobalCulls.Apply();
642
643         /* If any inspsockets closed, remove them */
644         this->InspSocketCull();
645
646         if (this->s_signal)
647         {
648                 this->SignalHandler(s_signal);
649                 this->s_signal = 0;
650         }
651
652 }
653
654 void InspIRCd::InspSocketCull()
655 {
656         for (std::map<InspSocket*,InspSocket*>::iterator x = SocketCull.begin(); x != SocketCull.end(); ++x)
657         {
658                 SE->DelFd(x->second);
659                 x->second->Close();
660                 delete x->second;
661         }
662         SocketCull.clear();
663 }
664
665 int InspIRCd::Run()
666 {
667         while (true)
668         {
669                 DoOneIteration(true);
670         }
671         /* This is never reached -- we hope! */
672         return 0;
673 }
674
675 /**********************************************************************************/
676
677 /**
678  * An ircd in four lines! bwahahaha. ahahahahaha. ahahah *cough*.
679  */
680
681 int main(int argc, char** argv)
682 {
683         SI = new InspIRCd(argc, argv);
684         mysig = &SI->s_signal;
685         SI->Run();
686         delete SI;
687         return 0;
688 }
689
690 /* this returns true when all modules are satisfied that the user should be allowed onto the irc server
691  * (until this returns true, a user will block in the waiting state, waiting to connect up to the
692  * registration timeout maximum seconds)
693  */
694 bool InspIRCd::AllModulesReportReady(userrec* user)
695 {
696         if (!Config->global_implementation[I_OnCheckReady])
697                 return true;
698
699         for (int i = 0; i <= this->GetModuleCount(); i++)
700         {
701                 if (Config->implement_lists[i][I_OnCheckReady])
702                 {
703                         int res = modules[i]->OnCheckReady(user);
704                         if (!res)
705                                 return false;
706                 }
707         }
708         return true;
709 }
710
711 int InspIRCd::GetModuleCount()
712 {
713         return this->ModCount;
714 }
715
716 time_t InspIRCd::Time(bool delta)
717 {
718         if (delta)
719                 return TIME + time_delta;
720         return TIME;
721 }
722
723 int InspIRCd::SetTimeDelta(int delta)
724 {
725         int old = time_delta;
726         time_delta = delta;
727         this->Log(DEBUG, "Time delta set to %d (was %d)", time_delta, old);
728         return old;
729 }
730
731 void InspIRCd::AddLocalClone(userrec* user)
732 {
733         clonemap::iterator x = local_clones.find(user->GetIPString());
734         if (x != local_clones.end())
735                 x->second++;
736         else
737                 local_clones[user->GetIPString()] = 1;
738 }
739
740 void InspIRCd::AddGlobalClone(userrec* user)
741 {
742         clonemap::iterator y = global_clones.find(user->GetIPString());
743         if (y != global_clones.end())
744                 y->second++;
745         else
746                 global_clones[user->GetIPString()] = 1;
747 }
748
749 int InspIRCd::GetTimeDelta()
750 {
751         return time_delta;
752 }
753
754 void InspIRCd::SetSignal(int signal)
755 {
756         *mysig = signal;
757 }
758