summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/inspircd.conf.example1
-rw-r--r--src/modules/m_hostchange.cpp24
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 @@
#<hostchange mask="*@fbi.gov" action="addnick">
#<hostchange mask="*r00t@*" action="suffix">
#<hostchange mask="a@b.com" action="set" value="blah.blah.blah">
+#<hostchange mask="localhost" ports="7000,7001,7005-7007" action="set" value="blahblah.foo">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# 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<std::string,Host*> 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")