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