From a59d08fffd3dc8a9850ce34c9928fb6382b9b37f Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 18 Oct 2009 16:01:33 +0000 Subject: Remove VF_SERVICEPROVIDER, prevent heap allocation of ConfigReader git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11904 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_vhost.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/modules/m_vhost.cpp') diff --git a/src/modules/m_vhost.cpp b/src/modules/m_vhost.cpp index a8f7b98e6..18c2a1eb0 100644 --- a/src/modules/m_vhost.cpp +++ b/src/modules/m_vhost.cpp @@ -27,29 +27,28 @@ class CommandVhost : public Command CmdResult Handle (const std::vector ¶meters, User *user) { - ConfigReader *Conf = new ConfigReader; - - for (int index = 0; index < Conf->Enumerate("vhost"); index++) + for (int index = 0;; index++) { - std::string mask = Conf->ReadValue("vhost","host",index); - std::string username = Conf->ReadValue("vhost","user",index); - std::string pass = Conf->ReadValue("vhost","pass",index); - std::string hash = Conf->ReadValue("vhost","hash",index); + ConfigTag* tag = ServerInstance->Config->ConfValue("vhost", index); + if (!tag) + break; + 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].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.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_SUCCESS; } } } user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password."); - delete Conf; return CMD_FAILURE; } }; -- cgit v1.2.3