summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/example.conf3
-rw-r--r--data/mysql/tables.sql1
-rw-r--r--docs/Changes.conf2
-rw-r--r--docs/IRCD12
-rw-r--r--include/channels.h56
-rw-r--r--include/extern.h16
-rw-r--r--include/language.h29
-rw-r--r--include/modes.h20
-rw-r--r--include/modules.h14
-rw-r--r--include/regchannel.h63
-rw-r--r--include/services.h35
-rw-r--r--include/sockets.h12
-rw-r--r--include/users.h4
-rw-r--r--modules/core/cs_clearusers.cpp14
-rw-r--r--modules/core/cs_forbid.cpp10
-rw-r--r--modules/core/cs_info.cpp3
-rw-r--r--modules/core/cs_mode.cpp306
-rw-r--r--modules/core/cs_set.cpp2
-rw-r--r--modules/core/cs_set_persist.cpp4
-rw-r--r--modules/core/db_plain.cpp75
-rw-r--r--modules/core/os_defcon.cpp2
-rw-r--r--modules/extra/db_mysql.cpp50
-rw-r--r--modules/extra/m_xmlrpc_main.cpp38
-rw-r--r--modules/protocol/bahamut.cpp1
-rw-r--r--modules/protocol/inspircd11.cpp1
-rw-r--r--modules/protocol/inspircd12.cpp1
-rw-r--r--modules/protocol/inspircd20.cpp1
-rw-r--r--modules/protocol/ratbox.cpp25
-rw-r--r--modules/protocol/unreal32.cpp25
-rw-r--r--src/actions.cpp21
-rw-r--r--src/bots.cpp32
-rw-r--r--src/channels.cpp820
-rw-r--r--src/chanserv.cpp160
-rw-r--r--src/config.cpp2
-rw-r--r--src/language.cpp46
-rw-r--r--src/misc.cpp80
-rw-r--r--src/modes.cpp136
-rw-r--r--src/operserv.cpp13
-rw-r--r--src/regchannel.cpp186
-rw-r--r--src/sockets.cpp74
-rw-r--r--src/users.cpp25
-rw-r--r--src/wildcard.cpp72
42 files changed, 1226 insertions, 1266 deletions
diff --git a/data/example.conf b/data/example.conf
index 1216e163b..777e28748 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -639,6 +639,7 @@ log
*
* chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey
* chanserv/list chanserv/suspend chanserv/topic chanserv/status
+ * chanserv/mode
*
* chanserv/saset/bantype chanserv/saset/description chanserv/saset/email chanserv/saset/entrymsg
* chanserv/saset/founder chanserv/saset/keeptopic chanserv/saset/opnotice
@@ -1044,7 +1045,7 @@ chanserv
* The core modules to load for ChanServ. This is a space separated list that corresponds
* to the base names of the modules for ChanServ. This directive is optional, but highly recommended.
*/
- modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_entrymsg cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone"
+ modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_entrymsg cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode"
/*
* The default options for newly registered channels. Note that changing these options
diff --git a/data/mysql/tables.sql b/data/mysql/tables.sql
index fb9b7335a..e165e94ad 100644
--- a/data/mysql/tables.sql
+++ b/data/mysql/tables.sql
@@ -111,6 +111,7 @@ CREATE TABLE IF NOT EXISTS `anope_cs_info` (
`mlock_on` text NOT NULL,
`mlock_off` text NOT NULL,
`mlock_params` text NOT NULL,
+ `mlock_params_off` text NOT NULL,
`entry_message` text NOT NULL,
`memomax` smallint(5) unsigned NOT NULL DEFAULT '0',
`botnick` varchar(255) NOT NULL DEFAULT '',
diff --git a/docs/Changes.conf b/docs/Changes.conf
index 792477f12..def316054 100644
--- a/docs/Changes.conf
+++ b/docs/Changes.conf
@@ -1,7 +1,7 @@
Anope Version 1.9.4
-------------------
memoserv:modules added ms_ignore
-chanserv:modules added cs_clone
+chanserv:modules added cs_clone and cs_mode
Anope Version 1.9.3
------------------
diff --git a/docs/IRCD b/docs/IRCD
index 7e7c4e163..ce44d893f 100644
--- a/docs/IRCD
+++ b/docs/IRCD
@@ -106,18 +106,10 @@ How To Add IRCd Support
23) TS6: Does the IRCd support TS6? Use 1 for yes, 0 for no.
- 24) Channel CIDR: Set to 1 if channel bans, excepts and invites
- support CIDR masks. Expected syntax: *!*@ip/mask.
- When set to 1, anope will only parse strict CIDR masks.
- IRCd's that try to correct invalid CIDR's (like nefarious)
- will need a custom implementation in the core.
- Contact the anope Dev Team if this is the case.
- Set to 0 if CIDR's are not supported by your IRCd.
-
- 25) Global TLD Prefix: Prefix used to send global messages, should probably
+ 24) Global TLD Prefix: Prefix used to send global messages, should probably
be "$"
- 26) Max Modes: The max number of mode changes we can send in one line
+ 25) Max Modes: The max number of mode changes we can send in one line
3) Modes
diff --git a/include/channels.h b/include/channels.h
index 54a85426b..cf4d97df3 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -64,13 +64,12 @@ enum ChannelFlags
class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
{
+ public:
+ typedef std::multimap<ChannelModeName, Anope::string> ModeList;
private:
/** A map of channel modes with their parameters set on this channel
*/
- std::map<ChannelModeName, Anope::string> Params;
-
- /* Modes set on the channel */
- Flags<ChannelModeName, CMODE_END * 2> modes;
+ ModeList modes;
public:
/** Default constructor
@@ -87,10 +86,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
ChannelInfo *ci; /* Corresponding ChannelInfo */
time_t creation_time; /* When channel was created */
- EList *bans;
- EList *excepts;
- EList *invites;
-
/* List of users in the channel */
CUserList users;
@@ -146,16 +141,18 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
bool HasUserStatus(User *u, ChannelModeName Name) const;
- /** See if the channel has any modes at all
- * @return true or false
- */
- inline bool HasModes() const { return modes.FlagCount(); }
-
/** See if a channel has a mode
* @param Name The mode name
- * @return true or false
+ * @return The number of modes set
+ * @param param The optional mode param
*/
- bool HasMode(ChannelModeName Name) const;
+ size_t HasMode(ChannelModeName Name, const Anope::string &param = "");
+
+ /** Get a list of modes on a channel
+ * @param Name A mode name to get the list of
+ * @return a pair of iterators for the beginning and end of the list
+ */
+ std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName Name);
/** Set a mode internally on a channel, this is not sent out to the IRCd
* @param cm The mode
@@ -205,30 +202,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true);
- /** Clear all the modes from the channel
- * @param bi The client unsetting the modes
- * @param internal Only remove the modes internally
- */
- void ClearModes(BotInfo *bi = NULL, bool internal = false);
-
- /** Clear all the bans from the channel
- * @param bi The client unsetting the modes
- * @param internal Only remove the modes internally
- */
- void ClearBans(BotInfo *bi = NULL, bool internal = false);
-
- /** Clear all the excepts from the channel
- * @param bi The client unsetting the modes
- * @param internal Only remove the modes internally
- */
- void ClearExcepts(BotInfo *bi = NULL, bool internal = false);
-
- /** Clear all the invites from the channel
- * @param bi The client unsetting the modes
- * @param internal Only remove the modes internally
- */
- void ClearInvites(BotInfo *bi = NULL, bool internal = false);
-
/** Get a param from the channel
* @param Name The mode
* @param Target a string to put the param into
@@ -236,11 +209,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
bool GetParam(ChannelModeName Name, Anope::string &Target) const;
- /** Check if a mode is set and has a param
- * @param Name The mode
- */
- bool HasParam(ChannelModeName Name) const;
-
/** Set a string of modes on the channel
* @param bi The client setting the modes
* @param EnforceMLock Should mlock be enforced on this mode change
diff --git a/include/extern.h b/include/extern.h
index b8bcb5be3..bd951ee5e 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -75,18 +75,6 @@ E void MassChannelModes(BotInfo *bi, const Anope::string &modes);
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
-E Entry *entry_create(const Anope::string &mask);
-E Entry *entry_add(EList *list, const Anope::string &mask);
-E void entry_delete(EList *list, Entry *e);
-E EList *list_create();
-E int entry_match(Entry *e, const Anope::string &nick, const Anope::string &user, const Anope::string &host, uint32 ip);
-E int entry_match_mask(Entry *e, const Anope::string &mask, uint32 ip);
-E Entry *elist_match(EList *list, const Anope::string &nick, const Anope::string &user, const Anope::string &host, uint32 ip);
-E Entry *elist_match_mask(EList *list, const Anope::string &mask, uint32 ip);
-E Entry *elist_match_user(EList *list, User *u);
-E Entry *elist_find_mask(EList *list, const Anope::string &mask);
-E long get_memuse(EList *list);
-
inline BotInfo *whosends(ChannelInfo *ci)
{
if (!ci || !ci->bi || !ci->c || !ci->botflags.HasFlag(BS_SYMBIOSIS) || !ci->c->FindUser(ci->bi))
@@ -272,9 +260,7 @@ E bool str_is_cidr(const Anope::string &str, uint32 &ip, uint32 &mask, Anope::st
/**** modes.cpp ****/
/* Number of generic modes we support */
E unsigned GenericChannelModes, GenericUserModes;
-E Flags<ChannelModeName, CMODE_END * 2> DefMLockOn;
-E Flags<ChannelModeName, CMODE_END * 2> DefMLockOff;
-E std::map<ChannelModeName, Anope::string> DefMLockParams;
+E std::multimap<ChannelModeName, ModeLock> def_mode_locks;
E void SetDefaultMLock(ServerConfig *config);
/**** nickserv.c ****/
diff --git a/include/language.h b/include/language.h
index 0b1c60f2c..634b840dd 100644
--- a/include/language.h
+++ b/include/language.h
@@ -274,7 +274,6 @@ enum LanguageString
CHAN_LEVEL_INVITE,
CHAN_LEVEL_AKICK,
CHAN_LEVEL_SET,
- CHAN_LEVEL_CLEAR,
CHAN_LEVEL_UNBAN,
CHAN_LEVEL_OPDEOP,
CHAN_LEVEL_ACCESS_LIST,
@@ -300,6 +299,7 @@ enum LanguageString
CHAN_LEVEL_BANME,
CHAN_LEVEL_BAN,
CHAN_LEVEL_TOPIC,
+ CHAN_LEVEL_MODE,
CHAN_LEVEL_INFO,
CHAN_LEVEL_AUTOOWNER,
CHAN_LEVEL_OWNER,
@@ -555,13 +555,8 @@ enum LanguageString
CHAN_UNBANNED,
CHAN_UNBANNED_OTHER,
CHAN_TOPIC_SYNTAX,
- CHAN_CLEAR_SYNTAX,
- CHAN_CLEARED_BANS,
- CHAN_CLEARED_EXCEPTS,
- CHAN_CLEARED_MODES,
- CHAN_CLEARED_OPS,
+ CHAN_CLEARUSERS_SYNTAX,
CHAN_CLEARED_USERS,
- CHAN_CLEARED_INVITES,
CHAN_CLONED,
CHAN_CLONED_ACCESS,
CHAN_CLONED_AKICK,
@@ -597,6 +592,15 @@ enum LanguageString
CHAN_DEOWNER_SYNTAX,
CHAN_KICK_SYNTAX,
CHAN_BAN_SYNTAX,
+ CHAN_MODE_SYNTAX,
+ CHAN_MODE_LOCK_UNKNOWN,
+ CHAN_MODE_LOCK_MISSING_PARAM,
+ CHAN_MODE_LOCK_NONE,
+ CHAN_MODE_LOCK_HEADER,
+ CHAN_MODE_LOCKED,
+ CHAN_MODE_NOT_LOCKED,
+ CHAN_MODE_UNLOCKED,
+ CHAN_MODE_LIST_FMT,
MEMO_HAVE_NEW_MEMO,
MEMO_HAVE_NEW_MEMOS,
MEMO_TYPE_READ_LAST,
@@ -931,9 +935,6 @@ enum LanguageString
OPER_OLINE_SYNTAX,
OPER_OLINE_SUCCESS,
OPER_OLINE_IRCOP,
- OPER_CLEARMODES_SYNTAX,
- OPER_CLEARMODES_DONE,
- OPER_CLEARMODES_ALL_DONE,
OPER_KICK_SYNTAX,
OPER_SVSNICK_SYNTAX,
OPER_SVSNICK_NEWNICK,
@@ -1266,7 +1267,7 @@ enum LanguageString
CHAN_HELP_CMD_AKICK,
CHAN_HELP_CMD_DROP,
CHAN_HELP_CMD_BAN,
- CHAN_HELP_CMD_CLEAR,
+ CHAN_HELP_CMD_CLEARUSERS,
CHAN_HELP_CMD_DEVOICE,
CHAN_HELP_CMD_GETKEY,
CHAN_HELP_CMD_INFO,
@@ -1287,6 +1288,7 @@ enum LanguageString
CHAN_HELP_CMD_PROTECT,
CHAN_HELP_CMD_DEOP,
CHAN_HELP_CMD_CLONE,
+ CHAN_HELP_CMD_MODE,
CHAN_HELP,
CHAN_HELP_EXPIRES,
CHAN_HELP_REGISTER,
@@ -1358,9 +1360,10 @@ enum LanguageString
CHAN_HELP_KICK,
CHAN_HELP_BAN,
CHAN_HELP_TOPIC,
- CHAN_HELP_CLEAR,
+ CHAN_HELP_CLEARUSERS,
CHAN_HELP_GETKEY,
CHAN_HELP_CLONE,
+ CHAN_HELP_MODE,
CHAN_SERVADMIN_HELP,
CHAN_SERVADMIN_HELP_DROP,
CHAN_SERVADMIN_HELP_SET_NOEXPIRE,
@@ -1403,7 +1406,6 @@ enum LanguageString
OPER_HELP_CMD_STAFF,
OPER_HELP_CMD_MODE,
OPER_HELP_CMD_KICK,
- OPER_HELP_CMD_CLEARMODES,
OPER_HELP_CMD_AKILL,
OPER_HELP_CMD_SNLINE,
OPER_HELP_CMD_SQLINE,
@@ -1442,7 +1444,6 @@ enum LanguageString
OPER_HELP_MODE,
OPER_HELP_UMODE,
OPER_HELP_OLINE,
- OPER_HELP_CLEARMODES,
OPER_HELP_KICK,
OPER_HELP_SVSNICK,
OPER_HELP_AKILL,
diff --git a/include/modes.h b/include/modes.h
index 299d1a2db..ce0281cd0 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -185,17 +185,17 @@ class CoreExport ChannelModeList : public ChannelMode
*/
virtual bool IsValid(const Anope::string &mask) const { return true; }
- /** Add the mask to the channel, this should be overridden
+ /** Called when a mask is added to a channel
* @param chan The channel
* @param mask The mask
*/
- virtual void AddMask(Channel *chan, const Anope::string &mask) { }
+ virtual void OnAdd(Channel *chan, const Anope::string &mask) { }
- /** Delete the mask from the channel, this should be overridden
+ /** Called when a mask is removed from a channel
* @param chan The channel
* @param mask The mask
*/
- virtual void DelMask(Channel *chan, const Anope::string &mask) { }
+ virtual void OnDel(Channel *chan, const Anope::string &mask) { }
};
@@ -254,9 +254,9 @@ class CoreExport ChannelModeBan : public ChannelModeList
public:
ChannelModeBan(char modeChar) : ChannelModeList(CMODE_BAN, "CMODE_BAN", modeChar) { }
- void AddMask(Channel *chan, const Anope::string &mask);
+ void OnAdd(Channel *chan, const Anope::string &mask);
- void DelMask(Channel *chan, const Anope::string &mask);
+ void OnDel(Channel *chan, const Anope::string &mask);
};
/** Channel mode +e
@@ -266,9 +266,9 @@ class CoreExport ChannelModeExcept : public ChannelModeList
public:
ChannelModeExcept(char modeChar) : ChannelModeList(CMODE_EXCEPT, "CMODE_EXCEPT", modeChar) { }
- void AddMask(Channel *chan, const Anope::string &mask);
+ void OnAdd(Channel *chan, const Anope::string &mask);
- void DelMask(Channel *chan, const Anope::string &mask);
+ void OnDel(Channel *chan, const Anope::string &mask);
};
/** Channel mode +I
@@ -278,9 +278,9 @@ class CoreExport ChannelModeInvex : public ChannelModeList
public:
ChannelModeInvex(char modeChar) : ChannelModeList(CMODE_INVITEOVERRIDE, "CMODE_INVITEOVERRIDE", modeChar) { }
- void AddMask(Channel *chan, const Anope::string &mask);
+ void OnAdd(Channel *chan, const Anope::string &mask);
- void DelMask(Channel *chan, const Anope::string &mask);
+ void OnDel(Channel *chan, const Anope::string &mask);
};
diff --git a/include/modules.h b/include/modules.h
index 481b5180b..be5c14447 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -991,20 +991,18 @@ class CoreExport Module : public Extensible
virtual void OnUserModeAdd(UserMode *um) { }
/** Called when a mode is about to be mlocked
- * @param ci The channel
- * @param Name The mode being mlocked
- * @param status true if its being mlocked +, false for -
- * @param param The param, if there is one and if status is true
+ * @param ci The channel the mode is being locked on
+ * @param lock The mode lock
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
- virtual EventReturn OnMLock(ChannelInfo *ci, ChannelModeName Name, bool status, const Anope::string &param) { return EVENT_CONTINUE; }
+ virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) { return EVENT_CONTINUE; }
/** Called when a mode is about to be unlocked
- * @param ci The channel
- * @param Name The mode being mlocked
+ * @param ci The channel the mode is being unlocked from
+ * @param mode The mode being unlocked
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
- virtual EventReturn OnUnMLock(ChannelInfo *ci, ChannelModeName Name) { return EVENT_CONTINUE; }
+ virtual EventReturn OnUnMLock(ChannelInfo *ci, ChannelMode *mode, const Anope::string &param) { return EVENT_CONTINUE; }
/** Called after a module is loaded
* @param u The user loading the module, can be NULL
diff --git a/include/regchannel.h b/include/regchannel.h
index 1300b9cf4..dd47a88fc 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -62,15 +62,26 @@ enum ChannelInfoFlag
CI_END
};
+struct ModeLock
+{
+ bool set;
+ ChannelModeName name;
+ Anope::string param;
+ Anope::string setter;
+ time_t created;
+
+ ModeLock(bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime) : set(s), name(n), param(p), setter(se), created(c) { }
+};
+
class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, CI_END>
{
private:
- std::map<ChannelModeName, Anope::string> Params; /* Map of parameters by mode name for mlock */
+ typedef std::multimap<ChannelModeName, ModeLock> ModeList;
+ private:
std::vector<ChanAccess *> access; /* List of authorized users */
std::vector<AutoKick *> akick; /* List of users to kickban */
std::vector<BadWord *> badwords; /* List of badwords */
- Flags<ChannelModeName, CMODE_END * 2> mlock_on; /* Modes mlocked on */
- Flags<ChannelModeName, CMODE_END * 2> mlock_off; /* Modes mlocked off */
+ ModeList mode_locks;
public:
/** Default constructor
@@ -241,51 +252,51 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
void LoadMLock();
/** Check if a mode is mlocked
- * @param Name The mode
+ * @param mode The mode
+ * @param An optional param
* @param status True to check mlock on, false for mlock off
* @return true on success, false on fail
*/
- bool HasMLock(ChannelModeName Name, bool status) const;
+ bool HasMLock(ChannelMode *mode, const Anope::string &param, bool status) const;
/** Set a mlock
- * @param Name The mode
+ * @param mode The mode
* @param status True for mlock on, false for mlock off
* @param param An optional param arg for + mlocked modes
+ * @param setter Who is setting the mlock
+ * @param created When the mlock was created
* @return true on success, false on failure (module blocking)
*/
- bool SetMLock(ChannelModeName Name, bool status, const Anope::string &param = "");
+ bool SetMLock(ChannelMode *mode, bool status, const Anope::string &param = "", const Anope::string &setter = "", time_t created = Anope::CurTime);
/** Remove a mlock
- * @param Name The mode
- * @return true on success, false on failure (module blcoking)
+ * @param mode The mode
+ * @param param The param of the mode, required if it is a list or status mode
+ * @return true on success, false on failure
*/
- bool RemoveMLock(ChannelModeName Name);
+ bool RemoveMLock(ChannelMode *mode, const Anope::string &param = "");
/** Clear all mlocks on the channel
*/
void ClearMLock();
- /** Get the number of mlocked modes for this channel
- * @param status true for mlock on, false for mlock off
- * @return The number of mlocked modes
- */
- size_t GetMLockCount(bool status) const;
-
- /** Get a param from the channel
- * @param Name The mode
- * @param Target a string to put the param into
- * @return true on success
+ /** Get all of the mlocks for this channel
+ * @return The mlocks
*/
- bool GetParam(ChannelModeName Name, Anope::string &Target) const;
+ const std::multimap<ChannelModeName, ModeLock> &GetMLock() const;
- /** Check if a mode is set and has a param
- * @param Name The mode
+ /** Get a list of modes on a channel
+ * @param Name The mode name to get a list of
+ * @return a pair of iterators for the beginning and end of the list
*/
- bool HasParam(ChannelModeName Name) const;
+ std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName Name);
- /** Clear all the params from the channel
+ /** Get details for a specific mlock
+ * @param name The mode name
+ * @param An optional param to match with
+ * @return The MLock, if any
*/
- void ClearParams();
+ ModeLock *GetMLock(ChannelModeName name, const Anope::string &param = "");
/** Check whether a user is permitted to be on this channel
* @param u The user
diff --git a/include/services.h b/include/services.h
index 38abf931f..4d2401883 100644
--- a/include/services.h
+++ b/include/services.h
@@ -453,9 +453,6 @@ struct IRCDVar
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
int sglineenforce;
int ts6; /* ircd is TS6 */
- int cidrchanbei; /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15)
- * 0 for no support, 1 for strict cidr support, anything else
- * for ircd specific support (nefarious only cares about first /mask) */
const char *globaltldprefix; /* TLD prefix used for Global */
unsigned maxmodes; /* Max modes to send per line */
};
@@ -636,7 +633,6 @@ enum ChannelAccess
CA_AUTOVOICE,
CA_OPDEOP, /* ChanServ commands OP and DEOP */
CA_ACCESS_LIST,
- CA_CLEAR,
CA_NOJOIN, /* Maximum */
CA_ACCESS_CHANGE,
CA_MEMO,
@@ -662,6 +658,7 @@ enum ChannelAccess
CA_BANME,
CA_BAN,
CA_TOPIC,
+ CA_MODE,
CA_INFO,
CA_AUTOOWNER,
CA_OWNER,
@@ -756,7 +753,7 @@ struct LevelInfo
enum EntryType
{
ENTRYTYPE_NONE,
- ENTRYTYPE_CIDR4,
+ ENTRYTYPE_CIDR,
ENTRYTYPE_NICK_WILD,
ENTRYTYPE_NICK,
ENTRYTYPE_USER_WILD,
@@ -767,17 +764,27 @@ enum EntryType
class Entry : public Flags<EntryType>
{
+ Anope::string mask;
+
public:
- Entry *next, *prev;
- uint32 cidr_ip; /* IP mask for CIDR matching */
- uint32 cidr_mask; /* Netmask for CIDR matching */
- Anope::string nick, user, host, mask;
-};
+ unsigned char cidr_len;
+ Anope::string nick, user, host;
-struct EList
-{
- Entry *entries;
- int32 count;
+ /** Constructor
+ * @param _host A full nick!ident@host/cidr mask
+ */
+ Entry(const Anope::string &_host);
+
+ /** Get the banned mask for this entry
+ * @return The mask
+ */
+ const Anope::string GetMask();
+
+ /** Check if this entry matches a user
+ * @param u The user
+ * @return true on match
+ */
+ bool Matches(User *u) const;
};
/*************************************************************************/
diff --git a/include/sockets.h b/include/sockets.h
index a24e346d7..c9e5bfed0 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -80,6 +80,18 @@ union CoreExport sockaddrs
void ntop(int type, const void *src);
};
+class CoreExport cidr
+{
+ sockaddrs addr;
+ Anope::string cidr_ip;
+ unsigned char cidr_len;
+ public:
+ cidr(const Anope::string &ip);
+ cidr(const Anope::string &ip, unsigned char len);
+ Anope::string mask() const;
+ bool match(sockaddrs &other);
+};
+
class SocketException : public CoreException
{
public:
diff --git a/include/users.h b/include/users.h
index 6aed13548..d9f47792f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -139,6 +139,10 @@ class CoreExport User : public Extensible
*/
Anope::string GetMask() const;
+ /** Get the full display mask (nick!vident@vhost/chost)
+ */
+ Anope::string GetDisplayedMask() const;
+
/** Updates the realname of the user record.
*/
void SetRealname(const Anope::string &realname);
diff --git a/modules/core/cs_clearusers.cpp b/modules/core/cs_clearusers.cpp
index 55c6f684e..028c7e5d6 100644
--- a/modules/core/cs_clearusers.cpp
+++ b/modules/core/cs_clearusers.cpp
@@ -28,15 +28,9 @@ class CommandCSClearUsers : public Command
ChannelInfo *ci = c ? c->ci : NULL;
Anope::string modebuf;
- ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER);
- ChannelMode *admin = ModeManager::FindChannelModeByName(CMODE_PROTECT);
- ChannelMode *op = ModeManager::FindChannelModeByName(CMODE_OP);
- ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP);
- ChannelMode *voice = ModeManager::FindChannelModeByName(CMODE_VOICE);
-
if (!c)
u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str());
- else if (!check_access(u, ci, CA_CLEAR))
+ else if (!check_access(u, ci, CA_FOUNDER))
u->SendMessage(ChanServ, ACCESS_DENIED);
Anope::string buf = "CLEAR USERS command from " + u->nick + " (" + u->Account()->display + ")";
@@ -55,18 +49,18 @@ class CommandCSClearUsers : public Command
bool OnHelp(User *u, const Anope::string &subcommand)
{
- u->SendMessage(ChanServ, CHAN_HELP_CLEAR);
+ u->SendMessage(ChanServ, CHAN_HELP_CLEARUSERS);
return true;
}
void OnSyntaxError(User *u, const Anope::string &subcommand)
{
- SyntaxError(ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
+ SyntaxError(ChanServ, u, "CLEAR", CHAN_CLEARUSERS_SYNTAX);
}
void OnServHelp(User *u)
{
- u->SendMessage(ChanServ, CHAN_HELP_CMD_CLEAR);
+ u->SendMessage(ChanServ, CHAN_HELP_CMD_CLEARUSERS);
}
};
diff --git a/modules/core/cs_forbid.cpp b/modules/core/cs_forbid.cpp
index ef55439b2..25fd90868 100644
--- a/modules/core/cs_forbid.cpp
+++ b/modules/core/cs_forbid.cpp
@@ -63,12 +63,16 @@ class CommandCSForbid : public Command
ci->forbidby = u->nick;
ci->forbidreason = reason;
- if ((c = findchan(ci->name)))
+ if ((c = ci->c))
{
/* Before banning everyone, it might be prudent to clear +e and +I lists..
* to prevent ppl from rejoining.. ~ Viper */
- c->ClearExcepts();
- c->ClearInvites();
+ std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> modes = c->GetModeList(CMODE_EXCEPT);
+ for (; modes.first != modes.second; ++modes.first)
+ c->RemoveMode(NULL, CMODE_EXCEPT, modes.first->second);
+ modes = c->GetModeList(CMODE_INVITEOVERRIDE);
+ for (; modes.first != modes.second; ++modes.first)
+ c->RemoveMode(NULL, CMODE_INVITEOVERRIDE, modes.first->second);
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp
index d9c507505..0df02ff43 100644
--- a/modules/core/cs_info.cpp
+++ b/modules/core/cs_info.cpp
@@ -66,7 +66,8 @@ class CommandCSInfo : public Command
u->SendMessage(ChanServ, CHAN_INFO_TIME_REGGED, do_strftime(ci->time_registered).c_str());
u->SendMessage(ChanServ, CHAN_INFO_LAST_USED, do_strftime(ci->last_use