summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-30 01:03:54 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-30 01:03:54 +0000
commit5fc268b7509f20cbf1243b99f2669033b93db00e (patch)
treed6b7c7387487843b6daf06c4a8fac2df6f3dcba5
parent5b62682223d7ba433df468ff39253b02cd580f34 (diff)
Added I_OnPreUserConnect, I_OnUserModeAdd, and I_OnUserModeAdd events
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2596 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/modules.h26
-rw-r--r--src/modes.cpp10
-rw-r--r--src/users.c48
3 files changed, 44 insertions, 40 deletions
diff --git a/include/modules.h b/include/modules.h
index f7354f4e2..a82f5cd56 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -532,6 +532,16 @@ class CoreExport Module
*/
virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { return EVENT_CONTINUE; }
+ /** Called after a user has been introduced, but before any type
+ * of checking has been done (akills, defcon, s*lines, etc)
+ * return EVENT_STOP here to allow the user to get by untouched,
+ * or kill them then return EVENT_STOP to tell Anope the user no
+ * longer exists
+ * @param u The user
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnPreUserConnect(User *u) { return EVENT_CONTINUE; }
+
/** Called when a new user connects to the network.
* @param u The connecting user.
*/
@@ -949,6 +959,16 @@ class CoreExport Module
*/
virtual void OnUserModeUnset(User *u, UserModeName Name) { }
+ /** Called when a channel mode is introducted into Anope
+ * @param cm The mode
+ */
+ virtual void OnChannelModeAdd(ChannelMode *cm) { }
+
+ /** Called when a user mode is introducted into Anope
+ * @param um The mode
+ */
+ virtual void OnUserModeAdd(UserMode *um) { }
+
};
@@ -975,8 +995,8 @@ enum Implementation
I_OnDeleteHostCore, I_OnFindHostCore, I_OnInsertHostCore,
/* Users */
- I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, I_OnJoinChannel,
- I_OnPrePartChannel, I_OnPartChannel,
+ I_OnPreUserConnect, I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel,
+ I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel,
/* OperServ */
I_OnDefconLevel,
@@ -986,7 +1006,7 @@ enum Implementation
I_OnPreDatabaseExpire, I_OnDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnEncryptInPlace, I_OnEncryptCheckLen, I_OnDecrypt, I_OnCheckPassword,
- I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset,
+ I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
I_END
};
diff --git a/src/modes.cpp b/src/modes.cpp
index 10fce2d6f..652c94f0c 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -32,6 +32,11 @@ bool ModeManager::AddUserMode(char Mode, UserMode *um)
bool ret = ModeManager::UserModesByChar.insert(std::make_pair(Mode, um)).second;
if (ret)
ret = ModeManager::UserModesByName.insert(std::make_pair(um->Name, um)).second;
+
+ if (ret)
+ {
+ FOREACH_MOD(I_OnUserModeAdd, OnUserModeAdd(um));
+ }
return ret;
}
@@ -47,6 +52,11 @@ bool ModeManager::AddChannelMode(char Mode, ChannelMode *cm)
bool ret = ModeManager::ChannelModesByChar.insert(std::make_pair(Mode, cm)).second;
if (ret)
ret = ModeManager::ChannelModesByName.insert(std::make_pair(cm->Name, cm)).second;
+
+ if (ret)
+ {
+ FOREACH_MOD(I_OnChannelModeAdd, OnChannelModeAdd(cm));
+ }
return ret;
}
diff --git a/src/users.c b/src/users.c
index a92cd5461..8a30cd739 100644
--- a/src/users.c
+++ b/src/users.c
@@ -706,39 +706,13 @@ User *do_nick(const char *source, const char *nick, const char *username, const
user->hostip = NULL;
}
- /* Now we check for akills/s*lines/sessions after a user class has been created
- * this is because some ircds (like Unreal) do not send any type of message
- * to the servers once a (SVS)KILL has been done, which previously
- * resulted in memory leaks for users that did not exist, and possibly
- * multiple users on the same nick
- *
- * This also caused session limits to incorrectly be decremented if
- * a user connected two times in a row (the user class from the first
- * connect still existed) resulting in their limit to be decremented
- * incorrectly.
- *
- * Hopefully this will fix these problems - Adam
- */
-
- /* We used to ignore the ~ which a lot of ircd's use to indicate no
- * identd response. That caused channel bans to break, so now we
- * just take what the server gives us. People are still encouraged
- * to read the RFCs and stop doing anything to usernames depending
- * on the result of an identd lookup.
- */
-
- /* First check for AKILLs. */
- /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are
- * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/
- * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice
- * comes in from the ircd.
- **/
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreUserConnect, OnPreUserConnect(user));
+ if (MOD_RESULT == EVENT_STOP)
+ return;
+
check_akill(nick, username, host, vhost, ipbuf);
- /**
- * DefCon AKILL system, if we want to akill all connecting user's here's where to do it
- * then force check_akill again on them...
- */
if (is_sync(findserver(servlist, server)) && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server))
{
strlcpy(mask, "*@", sizeof(mask));
@@ -751,9 +725,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const
check_akill(nick, username, host, vhost, ipbuf);
}
- /* As with akill checks earlier, we can't not add the user record, as the user may be exempt from bans.
- * Instead, we'll just wait for the IRCd to tell us they are gone.
- */
if (ircd->sgline)
check_sgline(nick, realname);
@@ -763,11 +734,14 @@ User *do_nick(const char *source, const char *nick, const char *username, const
if (ircd->szline && ircd->nickip)
check_szline(nick, ipbuf);
- FOREACH_MOD(I_OnUserConnect, OnUserConnect(user));
-
- /* Now check for session limits */
if (LimitSessions && !is_ulined(server))
add_session(nick, host, ipbuf);
+
+ /* Only call I_OnUserConnect if the user still exists */
+ if (finduser(nick))
+ {
+ FOREACH_MOD(I_OnUserConnect, OnUserConnect(user));
+ }
} else {
/* An old user changing nicks. */
if (ircd->ts6)