]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/inspircd.cpp
1d9aca35facc569b4f183b375bd84d1bd91f013e
[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         chan_hash* old_chans = this->chanlist;
169
170         this->clientlist = new user_hash();
171         this->chanlist = new chan_hash();
172
173         for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
174                 this->clientlist->insert(*n);
175
176         delete old_users;
177
178         for (chan_hash::const_iterator n = old_chans->begin(); n != old_chans->end(); n++)
179                 this->chanlist->insert(*n);
180
181         delete old_chans;
182 }
183
184 void InspIRCd::CloseLog()
185 {
186         if (this->Logger)
187                 this->Logger->Close();
188 }
189
190 void InspIRCd::SetSignals()
191 {
192 #ifndef WIN32
193         signal(SIGALRM, SIG_IGN);
194         signal(SIGHUP, InspIRCd::SetSignal);
195         signal(SIGPIPE, SIG_IGN);
196         signal(SIGCHLD, SIG_IGN);
197 #endif
198         signal(SIGTERM, InspIRCd::SetSignal);
199 }
200
201 void InspIRCd::QuickExit(int status)
202 {
203         exit(0);
204 }
205
206 bool InspIRCd::DaemonSeed()
207 {
208 #ifdef WINDOWS
209         printf_c("InspIRCd Process ID: \033[1;32m%lu\033[0m\n", GetCurrentProcessId());
210         return true;
211 #else
212         signal(SIGTERM, InspIRCd::QuickExit);
213
214         int childpid;
215         if ((childpid = fork ()) < 0)
216                 return false;
217         else if (childpid > 0)
218         {
219                 /* We wait here for the child process to kill us,
220                  * so that the shell prompt doesnt come back over
221                  * the output.
222                  * Sending a kill with a signal of 0 just checks
223                  * if the child pid is still around. If theyre not,
224                  * they threw an error and we should give up.
225                  */
226                 while (kill(childpid, 0) != -1)
227                         sleep(1);
228                 exit(0);
229         }
230         setsid ();
231         umask (007);
232         printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid());
233
234         signal(SIGTERM, InspIRCd::SetSignal);
235
236         rlimit rl;
237         if (getrlimit(RLIMIT_CORE, &rl) == -1)
238         {
239                 this->Log(DEFAULT,"Failed to getrlimit()!");
240                 return false;
241         }
242         else
243         {
244                 rl.rlim_cur = rl.rlim_max;
245                 if (setrlimit(RLIMIT_CORE, &rl) == -1)
246                         this->Log(DEFAULT,"setrlimit() failed, cannot increase coredump size.");
247         }
248
249         return true;
250 #endif
251 }
252
253 void InspIRCd::WritePID(const std::string &filename)
254 {
255         std::string fname = (filename.empty() ? "inspircd.pid" : filename);
256         if (*(fname.begin()) != '/')
257         {
258                 std::string::size_type pos;
259                 std::string confpath = this->ConfigFileName;
260                 if ((pos = confpath.rfind("/")) != std::string::npos)
261                 {
262                         /* Leaves us with just the path */
263                         fname = confpath.substr(0, pos) + std::string("/") + fname;
264                 }
265         }
266         std::ofstream outfile(fname.c_str());
267         if (outfile.is_open())
268         {
269                 outfile << getpid();
270                 outfile.close();
271         }
272         else
273         {
274                 printf("Failed to write PID-file '%s', exiting.\n",fname.c_str());
275                 this->Log(DEFAULT,"Failed to write PID-file '%s', exiting.",fname.c_str());
276                 Exit(EXIT_STATUS_PID);
277         }
278 }
279
280 InspIRCd::InspIRCd(int argc, char** argv)
281         : ModCount(0),
282           GlobalCulls(this),
283
284          /* Functor initialisation. Note that the ordering here is very important. */
285          HandleProcessUser(this),
286          HandleIsNick(this),
287          HandleIsIdent(this),
288          HandleFindDescriptor(this),
289          HandleFloodQuitUser(this),
290
291          /* Functor pointer initialisation. Must match the order of the list above */
292          ProcessUser(&HandleProcessUser),
293          IsNick(&HandleIsNick),
294          IsIdent(&HandleIsIdent),
295          FindDescriptor(&HandleFindDescriptor),
296          FloodQuitUser(&HandleFloodQuitUser)
297
298 {
299
300         int found_ports = 0;
301         FailedPortList pl;
302         int do_version = 0, do_nofork = 0, do_debug = 0, do_nolog = 0, do_root = 0;    /* flag variables */
303         char c = 0;
304
305         modules.resize(255);
306         factory.resize(255);
307         memset(&server, 0, sizeof(server));
308         memset(&client, 0, sizeof(client));
309
310         SocketEngineFactory* SEF = new SocketEngineFactory();
311         SE = SEF->Create(this);
312         delete SEF;
313
314         this->s_signal = 0;
315
316         this->unregistered_count = 0;
317
318         this->clientlist = new user_hash();
319         this->chanlist = new chan_hash();
320
321         this->Config = new ServerConfig(this);
322
323         this->Config->argv = argv;
324         this->Config->argc = argc;
325
326         if (chdir(Config->GetFullProgDir().c_str()))
327         {
328                 printf("Unable to change to my directory: %s\nAborted.", strerror(errno));
329                 exit(0);
330         }
331
332         this->Config->opertypes.clear();
333         this->Config->operclass.clear();
334         this->SNO = new SnomaskManager(this);
335         this->TIME = this->OLDTIME = this->startup_time = time(NULL);
336         this->time_delta = 0;
337         this->next_call = this->TIME + 3;
338         srand(this->TIME);
339
340         *this->LogFileName = 0;
341         strlcpy(this->ConfigFileName, CONFIG_FILE, MAXBUF);
342
343         struct option longopts[] =
344         {
345                 { "nofork",     no_argument,            &do_nofork,     1       },
346                 { "logfile",    required_argument,      NULL,           'f'     },
347                 { "config",     required_argument,      NULL,           'c'     },
348                 { "debug",      no_argument,            &do_debug,      1       },
349                 { "nolog",      no_argument,            &do_nolog,      1       },
350                 { "runasroot",  no_argument,            &do_root,       1       },
351                 { "version",    no_argument,            &do_version,    1       },
352                 { 0, 0, 0, 0 }
353         };
354
355         while ((c = getopt_long_only(argc, argv, ":f:", longopts, NULL)) != -1)
356         {
357                 switch (c)
358                 {
359                         case 'f':
360                                 /* Log filename was set */
361                                 strlcpy(LogFileName, optarg, MAXBUF);
362                         break;
363                         case 'c':
364                                 /* Config filename was set */
365                                 strlcpy(ConfigFileName, optarg, MAXBUF);
366                         break;
367                         case 0:
368                                 /* getopt_long_only() set an int variable, just keep going */
369                         break;
370                         default:
371                                 /* Unknown parameter! DANGER, INTRUDER.... err.... yeah. */
372                                 printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile <filename>] [--runasroot] [--version] [--config <config>]\n", argv[0]);
373                                 Exit(EXIT_STATUS_ARGV);
374                         break;
375                 }
376         }
377
378         if (do_version)
379         {
380                 printf("\n%s r%s\n", VERSION, REVISION);
381                 Exit(EXIT_STATUS_NOERROR);
382         }
383
384 #ifdef WIN32
385
386         // Handle forking
387         if(!do_nofork)
388         {
389                 DWORD ExitCode = WindowsForkStart(this);
390                 if(ExitCode)
391                         Exit(ExitCode);
392         }
393
394         // Set up winsock
395         WSADATA wsadata;
396         WSAStartup(MAKEWORD(2,0), &wsadata);
397
398         ChangeWindowsSpecificPointers(this);
399 #endif
400         if (!ServerConfig::FileExists(this->ConfigFileName))
401         {
402                 printf("ERROR: Cannot open config file: %s\nExiting...\n", this->ConfigFileName);
403                 this->Log(DEFAULT,"Unable to open config file %s", this->ConfigFileName);
404                 Exit(EXIT_STATUS_CONFIG);
405         }
406
407         printf_c("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
408         printf_c("(C) InspIRCd Development Team.\033[0m\n\n");
409         printf_c("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special, pippijn, peavey, Burlex\033[0m\n");
410         printf_c("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
411
412         /* Set the finished argument values */
413         Config->nofork = do_nofork;
414         Config->forcedebug = do_debug;
415         Config->writelog = !do_nolog;
416
417         strlcpy(Config->MyExecutable,argv[0],MAXBUF);
418
419         if (!this->OpenLog(argv, argc))
420         {
421                 printf("ERROR: Could not open logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno));
422                 Exit(EXIT_STATUS_LOG);
423         }
424
425         this->stats = new serverstats();
426         this->Timers = new TimerManager(this);
427         this->Parser = new CommandParser(this);
428         this->XLines = new XLineManager(this);
429         Config->ClearStack();
430         Config->Read(true, NULL);
431
432         if (!do_root)
433                 this->CheckRoot();
434         else
435         {
436                 printf("* WARNING * WARNING * WARNING * WARNING * WARNING * \n\n");
437                 printf("YOU ARE RUNNING INSPIRCD AS ROOT. THIS IS UNSUPPORTED\n");
438                 printf("AND IF YOU ARE HACKED, CRACKED, SPINDLED OR MUTILATED\n");
439                 printf("OR ANYTHING ELSE UNEXPECTED HAPPENS TO YOU OR YOUR\n");
440                 printf("SERVER, THEN IT IS YOUR OWN FAULT. IF YOU DID NOT MEAN\n");
441                 printf("TO START INSPIRCD AS ROOT, HIT CTRL+C NOW AND RESTART\n");
442                 printf("THE PROGRAM AS A NORMAL USER. YOU HAVE BEEN WARNED!\n");
443                 printf("\nInspIRCd starting in 20 seconds, ctrl+c to abort...\n");
444                 sleep(20);
445         }
446
447         this->SetSignals();
448
449         if (!Config->nofork)
450         {
451                 if (!this->DaemonSeed())
452                 {
453                         printf("ERROR: could not go into daemon mode. Shutting down.\n");
454                         Log(DEFAULT,"ERROR: could not go into daemon mode. Shutting down.");
455                         Exit(EXIT_STATUS_FORK);
456                 }
457         }
458
459         SE->RecoverFromFork();
460
461         this->Modes = new ModeParser(this);
462         this->AddServerName(Config->ServerName);
463         CheckDie();
464         int bounditems = BindPorts(true, found_ports, pl);
465
466         for(int t = 0; t < 255; t++)
467                 Config->global_implementation[t] = 0;
468
469         memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
470
471         printf("\n");
472
473         this->Res = new DNS(this);
474
475         this->LoadAllModules();
476         /* Just in case no modules were loaded - fix for bug #101 */
477         this->BuildISupport();
478         InitializeDisabledCommands(Config->DisabledCommands, this);
479
480         if ((Config->ports.size() == 0) && (found_ports > 0))
481         {
482                 printf("\nERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
483                 Log(DEFAULT,"ERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?");
484                 Exit(EXIT_STATUS_BIND);
485         }
486
487         if (Config->ports.size() != (unsigned int)found_ports)
488         {
489                 printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports);
490                 printf("The following port(s) failed to bind:\n");
491                 int j = 1;
492                 for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
493                 {
494                         printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second);
495                 }
496         }
497 #ifndef WINDOWS
498         if (!Config->nofork)
499         {
500                 if (kill(getppid(), SIGTERM) == -1)
501                 {
502                         printf("Error killing parent process: %s\n",strerror(errno));
503                         Log(DEFAULT,"Error killing parent process: %s",strerror(errno));
504                 }
505         }
506
507         if (isatty(0) && isatty(1) && isatty(2))
508         {
509                 /* We didn't start from a TTY, we must have started from a background process -
510                  * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont
511                  * close stdin/stdout
512                  */
513                 if (!do_nofork)
514                 {
515                         fclose(stdin);
516                         fclose(stderr);
517                         fclose(stdout);
518                 }
519                 else
520                 {
521                         Log(DEFAULT,"Keeping pseudo-tty open as we are running in the foreground.");
522                 }
523         }
524 #else
525         WindowsIPC = new IPC(this);
526         if(!Config->nofork)
527         {
528                 WindowsForkKillOwner(this);
529                 FreeConsole();
530         }
531 #endif
532
533
534         /*
535          * Initialise UID. XXX, we need to read SID from config, and use it instead of 000.
536          * For an explanation as to exactly how this works, and why it works this way, see GetUID().
537          *   -- w00t
538          */
539         int i;
540
541
542         /* Generate SID */
543         size_t sid = 0;
544         for (const char* x = Config->ServerName; *x; ++x)
545                 sid = 5 * sid + *x;
546         for (const char* y = Config->ServerDesc; *y; ++y)
547                 sid = 5 * sid + *y;
548         sid = sid % 999;
549         current_uid[0] = sid / 100 + 48;
550         current_uid[1] = sid / 10 + 48;
551         current_uid[2] = sid % 10 + 48;
552
553         /* Initialise UID */
554         for(i = 3; i < UUID_LENGTH - 1; i++)
555                 current_uid[i] = 'A';
556
557         printf("\nInspIRCd is now running!\n");
558         Log(DEFAULT,"Startup complete.");
559
560         this->WritePID(Config->PID);
561 }
562
563 void InspIRCd::DoOneIteration(bool process_module_sockets)
564 {
565 #ifndef WIN32
566         static rusage ru;
567 #else
568         static time_t uptime;
569         static struct tm * stime;
570         static char window_title[100];
571 #endif
572
573         /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
574          * Once per loop iteration is pleanty.
575          */
576         OLDTIME = TIME;
577         TIME = time(NULL);
578
579         /* Run background module timers every few seconds
580          * (the docs say modules shouldnt rely on accurate
581          * timing using this event, so we dont have to
582          * time this exactly).
583          */
584         if (TIME != OLDTIME)
585         {
586                 if (TIME < OLDTIME)
587                         WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
588                 if ((TIME % 3600) == 0)
589                 {
590                         this->RehashUsersAndChans();
591                         FOREACH_MOD_I(this, I_OnGarbageCollect, OnGarbageCollect());
592                 }
593                 Timers->TickTimers(TIME);
594                 this->DoBackgroundUserStuff(TIME);
595
596                 if ((TIME % 5) == 0)
597                 {
598                         XLines->expire_lines();
599                         FOREACH_MOD_I(this,I_OnBackgroundTimer,OnBackgroundTimer(TIME));
600                         Timers->TickMissedTimers(TIME);
601                 }
602 #ifndef WIN32
603                 /* Same change as in cmd_stats.cpp, use RUSAGE_SELF rather than '0' -- Om */
604                 if (!getrusage(RUSAGE_SELF, &ru))
605                 {
606                         gettimeofday(&this->stats->LastSampled, NULL);
607                         this->stats->LastCPU = ru.ru_utime;
608                 }
609 #else
610                 WindowsIPC->Check();
611
612                 if(Config->nofork)
613                 {
614                         uptime = Time() - startup_time;
615                         stime = gmtime(&uptime);
616                         snprintf(window_title, 100, "InspIRCd - %u clients, %u accepted connections - Up %u days, %.2u:%.2u:%.2u",
617                                 LocalUserCount(), stats->statsAccept, stime->tm_yday, stime->tm_hour, stime->tm_min, stime->tm_sec);
618                         SetConsoleTitle(window_title);
619                 }
620 #endif
621         }
622
623         /* Call the socket engine to wait on the active
624          * file descriptors. The socket engine has everything's
625          * descriptors in its list... dns, modules, users,
626          * servers... so its nice and easy, just one call.
627          * This will cause any read or write events to be
628          * dispatched to their handlers.
629          */
630         this->SE->DispatchEvents();
631
632         /* if any users was quit, take them out */
633         this->GlobalCulls.Apply();
634
635         /* If any inspsockets closed, remove them */
636         this->InspSocketCull();
637
638         if (this->s_signal)
639         {
640                 this->SignalHandler(s_signal);
641                 this->s_signal = 0;
642         }
643
644 }
645
646 void InspIRCd::InspSocketCull()
647 {
648         for (std::map<InspSocket*,InspSocket*>::iterator x = SocketCull.begin(); x != SocketCull.end(); ++x)
649         {
650                 SE->DelFd(x->second);
651                 x->second->Close();
652                 delete x->second;
653         }
654         SocketCull.clear();
655 }
656
657 int InspIRCd::Run()
658 {
659         while (true)
660         {
661                 DoOneIteration(true);
662         }
663         /* This is never reached -- we hope! */
664         return 0;
665 }
666
667 /**********************************************************************************/
668
669 /**
670  * An ircd in four lines! bwahahaha. ahahahahaha. ahahah *cough*.
671  */
672
673 int main(int argc, char** argv)
674 {
675         SI = new InspIRCd(argc, argv);
676         mysig = &SI->s_signal;
677         SI->Run();
678         delete SI;
679         return 0;
680 }
681
682 /* this returns true when all modules are satisfied that the user should be allowed onto the irc server
683  * (until this returns true, a user will block in the waiting state, waiting to connect up to the
684  * registration timeout maximum seconds)
685  */
686 bool InspIRCd::AllModulesReportReady(userrec* user)
687 {
688         if (!Config->global_implementation[I_OnCheckReady])
689                 return true;
690
691         for (int i = 0; i <= this->GetModuleCount(); i++)
692         {
693                 if (Config->implement_lists[i][I_OnCheckReady])
694                 {
695                         int res = modules[i]->OnCheckReady(user);
696                         if (!res)
697                                 return false;
698                 }
699         }
700         return true;
701 }
702
703 int InspIRCd::GetModuleCount()
704 {
705         return this->ModCount;
706 }
707
708 time_t InspIRCd::Time(bool delta)
709 {
710         if (delta)
711                 return TIME + time_delta;
712         return TIME;
713 }
714
715 int InspIRCd::SetTimeDelta(int delta)
716 {
717         int old = time_delta;
718         time_delta = delta;
719         this->Log(DEBUG, "Time delta set to %d (was %d)", time_delta, old);
720         return old;
721 }
722
723 void InspIRCd::AddLocalClone(userrec* user)
724 {
725         clonemap::iterator x = local_clones.find(user->GetIPString());
726         if (x != local_clones.end())
727                 x->second++;
728         else
729                 local_clones[user->GetIPString()] = 1;
730 }
731
732 void InspIRCd::AddGlobalClone(userrec* user)
733 {
734         clonemap::iterator y = global_clones.find(user->GetIPString());
735         if (y != global_clones.end())
736                 y->second++;
737         else
738                 global_clones[user->GetIPString()] = 1;
739 }
740
741 int InspIRCd::GetTimeDelta()
742 {
743         return time_delta;
744 }
745
746 void InspIRCd::SetSignal(int signal)
747 {
748         *mysig = signal;
749 }
750