From fc8b284c2a3fcd3882c8d6c1eec4bd99f3e4c628 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 19 Aug 2007 20:52:57 +0000 Subject: Add to the m_hostchange module to implement feature in bug #363 git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7762 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/inspircd.conf.example | 1 + src/modules/m_hostchange.cpp | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index 11853b604..31d69d84c 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -1570,6 +1570,7 @@ # # # +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # httpd module: Provides http server support for InspIRCd diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index dc45a43d4..b2db6d004 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -25,6 +25,7 @@ class Host : public classbase public: std::string action; std::string newhost; + std::string ports; }; typedef std::map hostchanges_t; @@ -76,11 +77,13 @@ class ModuleHostChange : public Module hostchanges.clear(); for (int index = 0; index < Conf.Enumerate("hostchange"); index++) { - std::string mask = Conf.ReadValue("hostchange","mask",index); - std::string action = Conf.ReadValue("hostchange","action",index); - std::string newhost = Conf.ReadValue("hostchange","value",index); + std::string mask = Conf.ReadValue("hostchange", "mask", index); + std::string ports = Conf.ReadValue("hosthange", "ports", index); + std::string action = Conf.ReadValue("hostchange", "action", index); + std::string newhost = Conf.ReadValue("hostchange", "value", index); Host* x = new Host; x->action = action; + x->ports = ports; x->newhost = newhost; hostchanges[mask] = x; } @@ -100,6 +103,21 @@ class ModuleHostChange : public Module if (ServerInstance->MatchText(std::string(user->ident)+"@"+std::string(user->host),i->first)) { Host* h = (Host*)i->second; + + if (!i->second->ports.empty()) + { + irc::portparser portrange(i->second->ports, false); + long portno = -1; + bool foundany = false; + + while ((portno = portrange.GetToken())) + if (portno == user->GetPort()) + foundany = true; + + if (!foundany) + continue; + } + // host of new user matches a hostchange tag's mask std::string newhost; if (h->action == "set") -- cgit v1.2.3