]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_hostchange.cpp
Update copyright headers.
[user/henk/code/inspircd.git] / src / modules / m_hostchange.cpp
index 4c9b24140cbb442201d4cdbcfb16f6f465184ff4..365d0bcadf6344a8ee22116bfa318abeb34e26c4 100644 (file)
@@ -1,9 +1,13 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2005-2007 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2013, 2018-2021 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2005-2007, 2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -34,7 +38,7 @@ class HostRule
                // Add the user's nickname to their hostname.
                HCA_ADDNICK,
 
-               // Set the user's hostname to the specific value. 
+               // Set the user's hostname to the specific value.
                HCA_SET
        };
 
@@ -76,7 +80,7 @@ class HostRule
 
        bool Matches(LocalUser* user) const
        {
-               if (!ports.empty() && !ports.count(user->GetServerPort()))
+               if (!ports.empty() && !ports.count(user->server_sa.port()))
                        return false;
 
                if (InspIRCd::MatchCIDR(user->MakeHost(), mask))
@@ -102,7 +106,7 @@ typedef std::vector<HostRule> HostRules;
 class ModuleHostChange : public Module
 {
 private:
-       std::bitset<UCHAR_MAX> hostmap;
+       std::bitset<UCHAR_MAX + 1> hostmap;
        HostRules hostrules;
 
        std::string CleanName(const std::string& name)
@@ -136,7 +140,7 @@ private:
 
                        insp::flat_set<int> ports;
                        const std::string portlist = tag->getString("ports");
-                       if (!ports.empty())
+                       if (!portlist.empty())
                        {
                                irc::portparser portrange(portlist, false);
                                while (int port = portrange.GetToken())
@@ -168,11 +172,13 @@ private:
                        }
                        else
                        {
-                               throw ModuleException(action + " is an invalid <hostchange:action> type, at " + tag->getTagLocation()); 
+                               throw ModuleException(action + " is an invalid <hostchange:action> type, at " + tag->getTagLocation());
                        }
                }
 
-               const std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
+               ConfigTag* tag = ServerInstance->Config->ConfValue("hostname");
+               const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
+
                hostmap.reset();
                for (std::string::const_iterator iter = hmap.begin(); iter != hmap.end(); ++iter)
                        hostmap.set(static_cast<unsigned char>(*iter));
@@ -181,7 +187,7 @@ private:
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides rule-based masking of user hostnames", VF_VENDOR);
+               return Version("Allows the server administrator to define custom rules for applying hostnames to users.", VF_VENDOR);
        }
 
        void OnUserConnect(LocalUser* user) CXX11_OVERRIDE