]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_channames.cpp
Update wiki links to use HTTPS and point to the correct pages.
[user/henk/code/inspircd.git] / src / modules / m_channames.cpp
index 92774edff7575230ebb350ef1f1d784471851d37..325e8fee11735c46f24f6790d82a9f7a8f233f21 100644 (file)
@@ -55,12 +55,15 @@ class ModuleChannelNames : public Module
        bool badchan;
 
  public:
-       ModuleChannelNames() : rememberer(ServerInstance->IsChannel)
+       ModuleChannelNames() : rememberer(ServerInstance->IsChannel), badchan(false)
+       {
+       }
+
+       void init()
        {
                ServerInstance->IsChannel = &myhandler;
-               badchan = false;
                Implementation eventlist[] = { I_OnRehash, I_OnUserKick };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                OnRehash(NULL);
        }
 
@@ -86,18 +89,32 @@ class ModuleChannelNames : public Module
                                ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
                        }
                        const UserMembList* users = c->GetUsers();
-                       for(UserMembCIter j = users->begin(); j != users->end(); ++j)
+                       for(UserMembCIter j = users->begin(); j != users->end(); )
+                       {
                                if (IS_LOCAL(j->first))
-                                       c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid");
+                               {
+                                       // KickUser invalidates the iterator
+                                       UserMembCIter it = j++;
+                                       c->KickUser(ServerInstance->FakeClient, it->first, "Channel name no longer valid");
+                               }
+                               else
+                                       ++j;
+                       }
                }
                badchan = false;
        }
 
        virtual void OnRehash(User* user)
        {
-               ConfigReader Conf;
-               std::string denyToken = Conf.ReadValue("channames", "denyrange", 0);
-               std::string allowToken = Conf.ReadValue("channames", "allowrange", 0);
+               ConfigTag* tag = ServerInstance->Config->ConfValue("channames");
+               std::string denyToken = tag->getString("denyrange");
+               std::string allowToken = tag->getString("allowrange");
+
+               if (!denyToken.compare(0, 2, "0-"))
+                       denyToken[0] = '1';
+               if (!allowToken.compare(0, 2, "0-"))
+                       allowToken[0] = '1';
+
                allowedmap.set();
 
                irc::portparser denyrange(denyToken, false);