summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-14 20:48:43 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-14 20:48:43 +0000
commitbd12e3a4e6501496f6eeb7aeb5245162020d6e6c (patch)
tree348c5285d0706285038e92bfc46a6351a42ebbd5 /include
parentaf90868aa951ced0a86132421d20a5cde8cfdea9 (diff)
Extban rework: allow exceptions to override bans on join
Move all bans that prevent a user from joining the channel to OnCheckBan, then stack their return results to allow an exception to override a ban. This does not make join exceptions override any other exception like mute. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11222 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/channels.h20
-rw-r--r--include/modules.h22
2 files changed, 40 insertions, 2 deletions
diff --git a/include/channels.h b/include/channels.h
index 3ce349990..c833b344d 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -524,12 +524,14 @@ class CoreExport Channel : public Extensible
* a given user for this channel.
* @param u The user to match bans against
* @param type The type of extban to check
+ * @returns 1 = exempt, 0 = no match, -1 = banned
*/
- bool IsExtBanned(User *u, char type);
+ int GetExtBanStatus(User *u, char type);
/** Overloaded version to check whether a particular string is extbanned
+ * @returns 1 = exempt, 0 = no match, -1 = banned
*/
- bool IsExtBanned(const std::string &str, char type);
+ int GetExtBanStatus(const std::string &str, char type);
/** Clears the cached max bans value
*/
@@ -540,4 +542,18 @@ class CoreExport Channel : public Extensible
virtual ~Channel() { /* stub */ }
};
+static inline int banmatch_reduce(int v1, int v2)
+{
+ int a1 = abs(v1);
+ int a2 = abs(v2);
+ if (a1 > a2)
+ return v1;
+ else if (a2 > a1)
+ return v2;
+ else if (v1 > v2)
+ return v1;
+ // otherwise v2 > v1 or equal
+ return v2;
+}
+
#endif
diff --git a/include/modules.h b/include/modules.h
index b58cbbc20..9fc87ff63 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -223,6 +223,26 @@ do { \
} \
} while (0);
+#define FOREACH_RESULT_MAP(y,x,f) \
+do { \
+ EventHandlerIter safei; \
+ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
+ { \
+ safei = _i; \
+ ++safei; \
+ try \
+ { \
+ int MOD_RESULT = (*_i)->x ; \
+ f; \
+ } \
+ catch (CoreException& modexcept) \
+ { \
+ ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+ } \
+ _i = safei; \
+ } \
+} while(0);
+
/** Represents a non-local user.
* (in fact, any FD less than -1 does)
*/
@@ -1139,11 +1159,13 @@ class CoreExport Module : public Extensible
* @param u The user to check
* @param c The channel the user is on
* @param type The type of extended ban to check for.
+ * @returns 1 = exempt, 0 = no match, -1 = banned
*/
virtual int OnCheckExtBan(User *u, Channel *c, char type);
/** Called whenever checking whether or not a string is extbanned. NOTE: one OnCheckExtBan will also trigger a number of
* OnCheckStringExtBan events for seperate host/IP comnbinations.
+ * @returns 1 = exempt, 0 = no match, -1 = banned
*/
virtual int OnCheckStringExtBan(const std::string &s, Channel *c, char type);