summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2012-06-11 22:12:23 -0500
committerSir Poggles <sir.pogsalot@gmail.com>2012-06-12 22:49:29 -0700
commit5fd31ec5a6ba6021763b36d8d17d4665900623ab (patch)
tree89eca1da78b7f334dd40bc5abd170819de973263
parentdca6a7821efbfd1e6c2987dfa1d2b9f72d1db1be (diff)
users: introduce OnSetClientIP hook.
This hook is called whenever a client's IP is modified.
-rw-r--r--include/modules.h8
-rw-r--r--src/modules.cpp1
-rw-r--r--src/users.cpp2
3 files changed, 10 insertions, 1 deletions
diff --git a/include/modules.h b/include/modules.h
index b428a5f8d..7cd6bbeab 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -116,7 +116,7 @@ struct ModResult {
* and numerical comparisons in preprocessor macros if they wish to support
* multiple versions of InspIRCd in one file.
*/
-#define INSPIRCD_VERSION_API 1
+#define INSPIRCD_VERSION_API 2
/**
* This #define allows us to call a method in all
@@ -339,6 +339,7 @@ enum Implementation
I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent,
+ I_OnSetClientIP,
I_END
};
@@ -1288,6 +1289,11 @@ class CoreExport Module : public classbase, public usecountbase
* @param line The raw line to send; modifiable, if empty no line will be returned.
*/
virtual void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line);
+
+ /** Called whenever a User's ip changes.
+ * @param user The user whose ip changed.
+ */
+ virtual void OnSetClientIP(User *user);
};
diff --git a/src/modules.cpp b/src/modules.cpp
index ccd78a8f0..8306ff6af 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -176,6 +176,7 @@ ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { return MO
void Module::OnHookIO(StreamSocket*, ListenSocket*) { }
ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
void Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, std::string&) { }
+void Module::OnSetClientIP(User *) { }
ModuleManager::ModuleManager() : ModCount(0)
{
diff --git a/src/users.cpp b/src/users.cpp
index f858660e4..73eb84137 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1013,6 +1013,8 @@ bool User::SetClientIP(irc::sockets::sockaddrs *sa)
{
memcpy(&client_sa, sa, sizeof(irc::sockets::sockaddrs));
+ FOREACH_MOD(I_OnSetClientIP, OnSetClientIP(this));
+
return true;
}