1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #include "configreader.h"
16 #include "commands/cmd_die.h"
17 #include "exitcodes.h"
19 extern "C" command_t* init_command(InspIRCd* Instance)
21 return new cmd_die(Instance);
26 CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
28 if (!strcmp(parameters[0],ServerInstance->Config->diepass))
30 ServerInstance->Log(SPARSE, "/DIE command from %s!%s@%s, terminating in %d seconds...", user->nick, user->ident, user->host, ServerInstance->Config->DieDelay);
32 /* This would just be WriteOpers(), but as we just sleep() and then die then the write buffers never get flushed.
33 * so we iterate the oper list, writing the message and immediately trying to flush their write buffer.
36 for (std::vector<userrec*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++)
40 if (IS_LOCAL(a) && (a->modes[UM_SERVERNOTICE]))
42 a->WriteServ("NOTICE %s :*** DIE command from %s!%s@%s, terminating...", a->nick, a->nick, a->ident, a->host);
47 if (ServerInstance->Config->DieDelay)
48 sleep(ServerInstance->Config->DieDelay);
50 InspIRCd::Exit(EXIT_STATUS_DIE);
54 ServerInstance->Log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host);
55 ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);