1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Allows locking of the server to stop all incoming connections till unlocked again */
19 * 988 <nick> <servername> :Closed for new connections
20 * 989 <nick> <servername> :Open for new connections
24 class CommandLockserv : public Command
28 CommandLockserv(Module* Creator, bool& lock) : Command(Creator, "LOCKSERV", 0), locked(lock)
30 flags_needed = 'o'; syntax.clear();
33 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
36 user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server.c_str());
37 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
38 /* Dont send to the network */
43 class CommandUnlockserv : public Command
49 CommandUnlockserv(Module* Creator, bool &lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
51 flags_needed = 'o'; syntax.clear();
54 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
57 user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server.c_str());
58 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
59 /* Dont send to the network */
64 class ModuleLockserv : public Module
68 CommandLockserv lockcommand;
69 CommandUnlockserv unlockcommand;
71 virtual void ResetLocked()
77 ModuleLockserv() : lockcommand(this, locked), unlockcommand(this, locked)
80 ServerInstance->AddCommand(&lockcommand);
81 ServerInstance->AddCommand(&unlockcommand);
82 Implementation eventlist[] = { I_OnUserRegister, I_OnRehash, I_OnCheckReady };
83 ServerInstance->Modules->Attach(eventlist, this, 3);
86 virtual ~ModuleLockserv()
91 virtual void OnRehash(User* user)
96 virtual ModResult OnUserRegister(User* user)
100 ServerInstance->Users->QuitUser(user, "Server is temporarily closed. Please try again later.");
103 return MOD_RES_PASSTHRU;
106 virtual ModResult OnCheckReady(User* user)
108 return locked ? MOD_RES_DENY : MOD_RES_PASSTHRU;
111 virtual Version GetVersion()
113 return Version("Allows locking of the server to stop all incoming connections till unlocked again", VF_VENDOR);
117 MODULE_INIT(ModuleLockserv)