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, std::string& lock) : Command(Creator, "LOCKSERV", 0, 1), locked(lock)
35 allow_empty_last_param = false;
39 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
43 user->WriteNotice("The server is already locked.");
47 locked = parameters.empty() ? "Server is temporarily closed. Please try again later." : parameters[0];
48 user->WriteNumeric(988, user->server->GetName(), "Closed for new connections");
49 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
54 class CommandUnlockserv : public Command
59 CommandUnlockserv(Module* Creator, std::string& lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
64 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
68 user->WriteNotice("The server isn't locked.");
73 user->WriteNumeric(989, user->server->GetName(), "Open for new connections");
74 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
79 class ModuleLockserv : public Module
82 CommandLockserv lockcommand;
83 CommandUnlockserv unlockcommand;
86 ModuleLockserv() : lockcommand(this, locked), unlockcommand(this, locked)
90 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
92 // Emergency way to unlock
97 ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
101 ServerInstance->Users->QuitUser(user, locked);
104 return MOD_RES_PASSTHRU;
107 ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
109 return !locked.empty() ? MOD_RES_DENY : MOD_RES_PASSTHRU;
112 Version GetVersion() CXX11_OVERRIDE
114 return Version("Allows locking of the server to stop all incoming connections until unlocked again", VF_VENDOR);
118 MODULE_INIT(ModuleLockserv)