2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2006-2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * 988 <nick> <servername> :Closed for new connections
25 * 989 <nick> <servername> :Open for new connections
28 class CommandLockserv : public Command
33 CommandLockserv(Module* Creator, bool& lock) : Command(Creator, "LOCKSERV", 0), locked(lock)
38 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
42 user->WriteNotice("The server is already locked.");
47 user->WriteNumeric(988, user->server->GetName(), "Closed for new connections");
48 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
53 class CommandUnlockserv : public Command
58 CommandUnlockserv(Module* Creator, bool &lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
63 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
67 user->WriteNotice("The server isn't locked.");
72 user->WriteNumeric(989, user->server->GetName(), "Open for new connections");
73 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
78 class ModuleLockserv : public Module
81 CommandLockserv lockcommand;
82 CommandUnlockserv unlockcommand;
85 ModuleLockserv() : lockcommand(this, locked), unlockcommand(this, locked)
89 void init() CXX11_OVERRIDE
94 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
96 // Emergency way to unlock
101 ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
105 ServerInstance->Users->QuitUser(user, "Server is temporarily closed. Please try again later.");
108 return MOD_RES_PASSTHRU;
111 ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
113 return locked ? MOD_RES_DENY : MOD_RES_PASSTHRU;
116 Version GetVersion() CXX11_OVERRIDE
118 return Version("Allows locking of the server to stop all incoming connections until unlocked again", VF_VENDOR);
122 MODULE_INIT(ModuleLockserv)