]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_lockserv.cpp
Some more text fixes and improvements (#1618).
[user/henk/code/inspircd.git] / src / modules / m_lockserv.cpp
index 7c1bb5bd35c902639907aa9f41a8ee4533115b15..5d049423d06b51133ef3aa696316de331e2a9c02 100644 (file)
  * 988 <nick> <servername> :Closed for new connections
  * 989 <nick> <servername> :Open for new connections
  */
+enum
+{
+       // InspIRCd-specific.
+       RPL_SERVLOCKON = 988,
+       RPL_SERVLOCKOFF = 989
+};
 
 class CommandLockserv : public Command
 {
@@ -36,7 +42,7 @@ class CommandLockserv : public Command
                flags_needed = 'o';
        }
 
-       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (!locked.empty())
                {
@@ -45,7 +51,7 @@ class CommandLockserv : public Command
                }
 
                locked = parameters.empty() ? "Server is temporarily closed. Please try again later." : parameters[0];
-               user->WriteNumeric(988, user->server->GetName(), "Closed for new connections");
+               user->WriteNumeric(RPL_SERVLOCKON, user->server->GetName(), "Closed for new connections");
                ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
@@ -61,7 +67,7 @@ class CommandUnlockserv : public Command
                flags_needed = 'o';
        }
 
-       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (locked.empty())
                {
@@ -70,7 +76,7 @@ class CommandUnlockserv : public Command
                }
 
                locked.clear();
-               user->WriteNumeric(989, user->server->GetName(), "Open for new connections");
+               user->WriteNumeric(RPL_SERVLOCKOFF, user->server->GetName(), "Open for new connections");
                ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
@@ -94,6 +100,12 @@ class ModuleLockserv : public Module
                        locked.clear();
        }
 
+       void OnModuleRehash(User* user, const std::string& param) CXX11_OVERRIDE
+       {
+               if (irc::equals(param, "lockserv") && !locked.empty())
+                       locked.clear();
+       }
+
        ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
        {
                if (!locked.empty())
@@ -111,7 +123,7 @@ class ModuleLockserv : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Allows locking of the server to stop all incoming connections until unlocked again", VF_VENDOR);
+               return Version("Provides the LOCKSERV and UNLOCKSERV commands to lock the server and block all incoming connections until unlocked again", VF_VENDOR);
        }
 };