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 (InspIRCd* Instance, Module* Creator, bool& lock)
29 : Command(Instance, Creator, "LOCKSERV", "o", 0), locked(lock)
34 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
37 user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server);
38 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
39 /* Dont send to the network */
44 class CommandUnlockserv : public Command
50 CommandUnlockserv (InspIRCd* Instance, Module* Creator, bool &lock)
51 : Command(Instance, Creator, "UNLOCKSERV", "o", 0), locked(lock)
56 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
59 user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server);
60 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
61 /* Dont send to the network */
66 class ModuleLockserv : public Module
70 CommandLockserv lockcommand;
71 CommandUnlockserv unlockcommand;
73 virtual void ResetLocked()
79 ModuleLockserv(InspIRCd* Me) : Module(Me), lockcommand(Me, this, locked), unlockcommand(Me, this, locked)
82 ServerInstance->AddCommand(&lockcommand);
83 ServerInstance->AddCommand(&unlockcommand);
84 Implementation eventlist[] = { I_OnUserRegister, I_OnRehash, I_OnCheckReady };
85 ServerInstance->Modules->Attach(eventlist, this, 3);
88 virtual ~ModuleLockserv()
93 virtual void OnRehash(User* user)
98 virtual ModResult OnUserRegister(User* user)
102 ServerInstance->Users->QuitUser(user, "Server is temporarily closed. Please try again later.");
105 return MOD_RES_PASSTHRU;
108 virtual ModResult OnCheckReady(User* user)
110 return locked ? MOD_RES_DENY : MOD_RES_PASSTHRU;
113 virtual Version GetVersion()
115 return Version("$Id$", VF_VENDOR, API_VERSION);
119 MODULE_INIT(ModuleLockserv)