]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_lockserv.cpp
Merge pull request #1162 from SaberUK/insp20+fix-deinstall
[user/henk/code/inspircd.git] / src / modules / m_lockserv.cpp
index cc2e253081999d596eb151be0df82e9b2e464e60..4983ae16abe3afa01eaa7022feca4fe7c2a51f7c 100644 (file)
@@ -34,15 +34,20 @@ class CommandLockserv : public Command
 public:
        CommandLockserv(Module* Creator, bool& lock) : Command(Creator, "LOCKSERV", 0), locked(lock)
        {
-               flags_needed = 'o'; syntax.clear();
+               flags_needed = 'o';
        }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
+               if (locked)
+               {
+                       user->WriteServ("NOTICE %s :The server is already locked.", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                locked = true;
                user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server.c_str());
-               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
-               /* Dont send to the network */
+               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
 };
@@ -55,15 +60,20 @@ private:
 public:
        CommandUnlockserv(Module* Creator, bool &lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
        {
-               flags_needed = 'o'; syntax.clear();
+               flags_needed = 'o';
        }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
+               if (!locked)
+               {
+                       user->WriteServ("NOTICE %s :The server isn't locked.", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                locked = false;
                user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server.c_str());
-               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
-               /* Dont send to the network */
+               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
 };
@@ -77,12 +87,16 @@ private:
 
 public:
        ModuleLockserv() : lockcommand(this, locked), unlockcommand(this, locked)
+       {
+       }
+
+       void init()
        {
                locked = false;
-               ServerInstance->AddCommand(&lockcommand);
-               ServerInstance->AddCommand(&unlockcommand);
+               ServerInstance->Modules->AddService(lockcommand);
+               ServerInstance->Modules->AddService(unlockcommand);
                Implementation eventlist[] = { I_OnUserRegister, I_OnRehash, I_OnCheckReady };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        virtual ~ModuleLockserv()