1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
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
30 CommandLockserv (InspIRCd* Instance, bool &lock)
31 : Command(Instance, "LOCKSERV", "o", 0), locked(lock)
33 this->source = "m_lockserv.so";
37 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
40 user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server);
41 ServerInstance->SNO->WriteToSnoMask('A', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
42 /* Dont send to the network */
47 class CommandUnlockserv : public Command
53 CommandUnlockserv (InspIRCd* Instance, bool &lock)
54 : Command(Instance, "UNLOCKSERV", "o", 0), locked(lock)
56 this->source = "m_lockserv.so";
60 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
63 user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server);
64 ServerInstance->SNO->WriteToSnoMask('A', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
65 /* Dont send to the network */
70 class ModuleLockserv : public Module
74 CommandLockserv* lockcommand;
75 CommandUnlockserv* unlockcommand;
77 virtual void ResetLocked()
83 ModuleLockserv(InspIRCd* Me) : Module(Me)
86 lockcommand = new CommandLockserv(ServerInstance, locked);
87 ServerInstance->AddCommand(lockcommand);
89 unlockcommand = new CommandUnlockserv(ServerInstance, locked);
90 ServerInstance->AddCommand(unlockcommand);
91 Implementation eventlist[] = { I_OnUserRegister, I_OnRehash, I_OnCheckReady };
92 ServerInstance->Modules->Attach(eventlist, this, 3);
95 virtual ~ModuleLockserv()
100 virtual void OnRehash(User* user, const std::string ¶meter)
105 virtual int OnUserRegister(User* user)
109 ServerInstance->Users->QuitUser(user, "Server is temporarily closed. Please try again later.");
115 virtual bool OnCheckReady(User* user)
120 virtual Version GetVersion()
122 return Version(1, 0, 0, 1, VF_VENDOR, API_VERSION);
126 MODULE_INIT(ModuleLockserv)