]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_vhost.cpp
Replace [cC]olour with [cC]olor
[user/henk/code/inspircd.git] / src / modules / m_vhost.cpp
index 130a8acc51667a1de256bb13763d96e16fab2e5b..704e769b3311f66fe06145c5bbc1a100959eb4e1 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
 class CommandVhost : public Command
 {
  public:
-       CommandVhost (InspIRCd* Instance) : Command(Instance,"VHOST", 0, 2)
+       CommandVhost(Module* Creator) : Command(Creator,"VHOST", 2)
        {
-               this->source = "m_vhost.so";
                syntax = "<username> <password>";
        }
 
-       CmdResult Handle (const char** parameters, int pcnt, User *user)
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
-               ConfigReader *Conf = new ConfigReader(ServerInstance);
-
-               for (int index = 0; index < Conf->Enumerate("vhost"); index++)
+               ConfigTagList tags = ServerInstance->Config->ConfTags("vhost");
+               for(ConfigIter i = tags.first; i != tags.second; ++i)
                {
-                       std::string mask = Conf->ReadValue("vhost","host",index);
-                       std::string username = Conf->ReadValue("vhost","user",index);
-                       std::string pass = Conf->ReadValue("vhost","pass",index);
+                       ConfigTag* tag = i->second;
+                       std::string mask = tag->getString("host");
+                       std::string username = tag->getString("user");
+                       std::string pass = tag->getString("pass");
+                       std::string hash = tag->getString("hash");
 
-                       if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
+                       if (parameters[0] == username && !ServerInstance->PassCompare(user, pass, parameters[1], hash))
                        {
                                if (!mask.empty())
                                {
-                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
+                                       user->WriteServ("NOTICE "+user->nick+" :Setting your VHost: " + mask);
                                        user->ChangeDisplayedHost(mask.c_str());
-                                       delete Conf;
-                                       return CMD_LOCALONLY;
+                                       return CMD_SUCCESS;
                                }
                        }
                }
 
                user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
-               delete Conf;
                return CMD_FAILURE;
        }
 };
@@ -57,17 +55,14 @@ class CommandVhost : public Command
 class ModuleVHost : public Module
 {
  private:
+       CommandVhost cmd;
 
-       CommandVhost* mycommand;
-        
  public:
-       ModuleVHost(InspIRCd* Me) : Module(Me)
+       ModuleVHost() : cmd(this)
        {
-               mycommand = new CommandVhost(ServerInstance);
-               ServerInstance->AddCommand(mycommand);
-
+               ServerInstance->AddCommand(&cmd);
        }
-       
+
        virtual ~ModuleVHost()
        {
        }
@@ -75,9 +70,9 @@ class ModuleVHost : public Module
 
        virtual Version GetVersion()
        {
-               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
+               return Version("Provides masking of user hostnames via traditional /VHOST command",VF_VENDOR);
        }
-       
+
 };
 
 MODULE_INIT(ModuleVHost)