]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Hold reference to the associated ConfigTag inside ConnectClass
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 17 Oct 2009 02:40:16 +0000 (02:40 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 17 Oct 2009 02:40:16 +0000 (02:40 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11880 e03df62e-2008-0410-955e-edbf42e46eb7

include/users.h
src/configreader.cpp
src/modules/m_conn_umodes.cpp
src/modules/m_ident.cpp
src/users.cpp

index a898d58130d18b7f58c752473d51e319c09afc8c..fbeba1bb9fa4fe938f6d4030749218041414bf3b 100644 (file)
@@ -59,11 +59,13 @@ enum RegistrationState {
 /* Required forward declaration */
 class Channel;
 class UserResolver;
+class ConfigTag;
 
 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
  */
 struct CoreExport ConnectClass : public refcountbase
 {
+       reference<ConfigTag> config;
        /** Type of line, either CC_ALLOW or CC_DENY
         */
        char type;
@@ -129,10 +131,10 @@ struct CoreExport ConnectClass : public refcountbase
 
        /** Create a new connect class with no settings.
         */
-       ConnectClass(char type, const std::string& mask);
+       ConnectClass(ConfigTag* tag, char type, const std::string& mask);
        /** Create a new connect class with inherited settings.
         */
-       ConnectClass(char type, const std::string& mask, const ConnectClass& parent);
+       ConnectClass(ConfigTag* tag, char type, const std::string& mask, const ConnectClass& parent);
        
        /** Update the settings in this block to match the given block */
        void Update(const ConnectClass* newSettings);
index 6157b4d4b7249370bc306d1cdceaa50f62de0604..10fea3effa9b3f7d0dbf7104c65d0f6f82453d58 100644 (file)
@@ -389,8 +389,8 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                                throw CoreException("Two connect classes cannot have the same mask (" + mask + ")");
 
                        ConnectClass* me = parent ? 
-                               new ConnectClass(type, mask, *parent) :
-                               new ConnectClass(type, mask);
+                               new ConnectClass(tag, type, mask, *parent) :
+                               new ConnectClass(tag, type, mask);
 
                        if (!name.empty())
                                me->name = name;
index 2ad8ab87629c5be3b44f9b04398cc251e183d9de..0fcd73fe92493c2fd17b60d13f09c3d82e114d1f 100644 (file)
 
 class ModuleModesOnConnect : public Module
 {
- private:
-
-       ConfigReader *Conf;
-
  public:
        ModuleModesOnConnect()  {
-
-               Conf = new ConfigReader;
                Implementation eventlist[] = { I_OnUserConnect, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 2);
                // for things like +x on connect, important, otherwise we have to resort to config order (bleh) -- w00t
@@ -32,15 +26,8 @@ class ModuleModesOnConnect : public Module
        }
 
 
-       virtual void OnRehash(User* user)
-       {
-               delete Conf;
-               Conf = new ConfigReader;
-       }
-
        virtual ~ModuleModesOnConnect()
        {
-               delete Conf;
        }
 
        virtual Version GetVersion()
@@ -59,41 +46,33 @@ class ModuleModesOnConnect : public Module
                                sizeof(ServerInstance->Config->DisabledUModes));
                memset(ServerInstance->Config->DisabledUModes, 0, 64);
 
-               for (int j = 0; j < Conf->Enumerate("connect"); j++)
+               ConfigTag* tag = user->MyClass->config;
+               std::string ThisModes = tag->getString("modes");
+               if (!ThisModes.empty())
                {
-                       std::string hostn = Conf->ReadValue("connect","allow",j);
-                       /* XXX: Fixme: does not respect port, limit, etc */
-                       if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn, ascii_case_insensitive_map)) || (InspIRCd::Match(user->host,hostn, ascii_case_insensitive_map)))
-                       {
-                               std::string ThisModes = Conf->ReadValue("connect","modes",j);
-                               if (!ThisModes.empty())
-                               {
-                                       std::string buf;
-                                       std::stringstream ss(ThisModes);
-
-                                       std::vector<std::string> tokens;
+                       std::string buf;
+                       std::stringstream ss(ThisModes);
 
-                                       // split ThisUserModes into modes and mode params
-                                       while (ss >> buf)
-                                               tokens.push_back(buf);
+                       std::vector<std::string> tokens;
 
-                                       std::vector<std::string> modes;
-                                       modes.push_back(user->nick);
-                                       modes.push_back(tokens[0]);
+                       // split ThisUserModes into modes and mode params
+                       while (ss >> buf)
+                               tokens.push_back(buf);
 
-                                       if (tokens.size() > 1)
-                                       {
-                                               // process mode params
-                                               for (unsigned int k = 1; k < tokens.size(); k++)
-                                               {
-                                                       modes.push_back(tokens[k]);
-                                               }
-                                       }
+                       std::vector<std::string> modes;
+                       modes.push_back(user->nick);
+                       modes.push_back(tokens[0]);
 
-                                       ServerInstance->Parser->CallHandler("MODE", modes, user);
+                       if (tokens.size() > 1)
+                       {
+                               // process mode params
+                               for (unsigned int k = 1; k < tokens.size(); k++)
+                               {
+                                       modes.push_back(tokens[k]);
                                }
-                               break;
                        }
+
+                       ServerInstance->Parser->CallHandler("MODE", modes, user);
                }
 
                memcpy(ServerInstance->Config->DisabledUModes, save, 64);
index 0ba9e6e3a6de398400c30c50dc381385bfc7d5d2..56fa47db8bae4c1e66d9a3aeac8ef837a4f6249c 100644 (file)
@@ -276,12 +276,10 @@ class IdentRequestSocket : public EventHandler
 class ModuleIdent : public Module
 {
        int RequestTimeout;
-       ConfigReader *Conf;
        SimpleExtItem<IdentRequestSocket> ext;
  public:
        ModuleIdent() : ext("ident_socket", this)
        {
-               Conf = new ConfigReader;
                OnRehash(NULL);
                Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnUserDisconnect };
                ServerInstance->Modules->Attach(eventlist, this, 4);
@@ -289,7 +287,6 @@ class ModuleIdent : public Module
 
        ~ModuleIdent()
        {
-               delete Conf;
        }
 
        virtual Version GetVersion()
@@ -299,28 +296,18 @@ class ModuleIdent : public Module
 
        virtual void OnRehash(User *user)
        {
-               delete Conf;
-               Conf = new ConfigReader;
+               ConfigReader Conf;
 
-               RequestTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
+               RequestTimeout = Conf.ReadInteger("ident", "timeout", 0, true);
                if (!RequestTimeout)
                        RequestTimeout = 5;
        }
 
        virtual ModResult OnUserRegister(User *user)
        {
-               for (int j = 0; j < Conf->Enumerate("connect"); j++)
-               {
-                       std::string hostn = Conf->ReadValue("connect","allow",j);
-                       /* XXX: Fixme: does not respect port, limit, etc */
-                       if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn, ascii_case_insensitive_map)) || (InspIRCd::Match(user->host,hostn, ascii_case_insensitive_map)))
-                       {
-                               bool useident = Conf->ReadFlag("connect", "useident", "yes", j);
-
-                               if (!useident)
-                                       return MOD_RES_PASSTHRU;
-                       }
-               }
+               ConfigTag* tag = user->MyClass->config;
+               if (!tag->getBool("useident", true))
+                       return MOD_RES_PASSTHRU;
 
                /* User::ident is currently the username field from USER; with m_ident loaded, that
                 * should be preceded by a ~. The field is actually IdentMax+2 characters wide. */
index 4b668697779c5be9034be6d9dc2fc903bd5c1183..324edbfdbd0f0590649598ce789c05cff54ab3ff 100644 (file)
@@ -1801,15 +1801,15 @@ const std::string FakeUser::GetFullRealHost()
        return nick;
 }
 
-ConnectClass::ConnectClass(char t, const std::string& mask)
-       : type(t), name("unnamed"), registration_timeout(0), host(mask),
+ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
+       : config(tag), type(t), name("unnamed"), registration_timeout(0), host(mask),
        pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0),
        recvqmax(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
 {
 }
 
-ConnectClass::ConnectClass(char t, const std::string& mask, const ConnectClass& parent)
-       : type(t), name("unnamed"),
+ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, const ConnectClass& parent)
+       : config(tag), type(t), name("unnamed"),
        registration_timeout(parent.registration_timeout), host(mask),
        pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash),
        softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax),