]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_xmlsocket.cpp
httpd connection close fixes (these need to be backported to 1.1 at some point?)...
[user/henk/code/inspircd.git] / src / modules / m_xmlsocket.cpp
index 2e4b17fc6e8012e355c8a21a7d62b49a8d08bf35..ea84851725798b46335da9aa53b280e4c624de15 100644 (file)
@@ -30,9 +30,15 @@ class ModuleXMLSocket : public Module
                ServerInstance->Modules->Attach(eventlist, this, 6);
        }
 
-       bool isin(const std::string &hostandport, const std::vector<std::string> &portlist)
+       bool isin(const std::string &host, int port, const std::vector<std::string> &portlist)
        {
-               return std::find(portlist.begin(), portlist.end(), hostandport) != portlist.end();
+               if (std::find(portlist.begin(), portlist.end(), "*:" + ConvToStr(port)) != portlist.end())
+                       return true;
+
+               if (std::find(portlist.begin(), portlist.end(), ":" + ConvToStr(port)) != portlist.end())
+                       return true;
+
+               return std::find(portlist.begin(), portlist.end(), host + ":" + ConvToStr(port)) != portlist.end();
        }
 
        virtual void OnRehash(User* user, const std::string &param)
@@ -51,6 +57,7 @@ class ModuleXMLSocket : public Module
                                // Get the port we're meant to be listening on with SSL
                                std::string port = Conf->ReadValue("bind", "port", i);
                                std::string addr = Conf->ReadValue("bind", "address", i);
+
                                irc::portparser portrange(port, false);
                                long portno = -1;
                                while ((portno = portrange.GetToken()))
@@ -59,12 +66,12 @@ class ModuleXMLSocket : public Module
                                        {
                                                listenports.push_back(addr + ":" + ConvToStr(portno));
                                                for (size_t j = 0; j < ServerInstance->Config->ports.size(); j++)
-                                                       if ((ServerInstance->Config->ports[i]->GetPort() == portno) && (ServerInstance->Config->ports[i]->GetIP() == addr))
+                                                       if ((ServerInstance->Config->ports[j]->GetPort() == portno) && (ServerInstance->Config->ports[j]->GetIP() == addr))
                                                                ServerInstance->Config->ports[j]->SetDescription("xml");
                                        }
                                        catch (ModuleException &e)
                                        {
-                                               ServerInstance->Logs->Log("m_xmlsocket",DEFAULT, "m_xmlsocket.so: FAILED to enable XMLSocket on port %d: %s. Maybe you have another similar module loaded?", portno, e.GetReason());
+                                               ServerInstance->Logs->Log("m_xmlsocket",DEFAULT, "m_xmlsocket.so: FAILED to enable XMLSocket on port %ld: %s. Maybe you have another similar module loaded?", portno, e.GetReason());
                                        }
                                }
                        }
@@ -107,7 +114,7 @@ class ModuleXMLSocket : public Module
 
        virtual void OnHookUserIO(User* user, const std::string &targetip)
        {
-               if (!user->io && isin(targetip+":"+ConvToStr(user->GetPort()),listenports))
+               if (!user->io && isin(targetip,user->GetPort(),listenports))
                {
                        /* Hook the user with our module */
                        user->io = this;