1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 13:46:38 +02:00

Complete rewrite of everything associated with modes, this breaks saving and reading mlocked modes from the databases until the new databases are implemented

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2560 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Adam-
2009-10-13 21:26:38 +00:00
parent 1fd6685132
commit d3d64c27b1
50 changed files with 2493 additions and 3381 deletions
-57
View File
@@ -29,15 +29,7 @@ E char *uplink;
E IRCDVar *ircd;
E IRCDCAPAB *ircdcap;
E char *flood_mode_char_set;
E char *flood_mode_char_remove;
E int UseTSMODE; /* hack to get around bahamut clones that don't send TSMODE */
EI unsigned long umodes[128];
E char csmodes[128];
E CMMode cmmodes[128];
E CBMode cbmodes[128];
E CBModeInfo *cbmodeinfos;
E CUMode cumodes[128];
E char *IRCDModule;
E IRCDProto *ircdproto;
@@ -79,27 +71,11 @@ E void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, char *
E Channel *chanlist[1024];
E void add_ban(Channel * chan, const char *mask);
E void chan_adduser2(User * user, Channel * c);
E void add_invite(Channel * chan, const char *mask);
E void chan_delete(Channel * c);
E void del_ban(Channel * chan, const char *mask);
E void chan_set_key(Channel * chan, const char *value);
E void set_limit(Channel * chan, const char *value);
E void del_invite(Channel * chan, const char *mask);
E char *get_key(Channel * chan);
E char *get_limit(Channel * chan);
E Channel *chan_create(const char *chan, time_t ts);
E Channel *join_user_update(User * user, Channel * chan, const char *name, time_t chants);
E void add_exception(Channel * chan, const char *mask);
E void del_exception(Channel * chan, const char *mask);
E char *get_flood(Channel * chan);
E void set_flood(Channel * chan, const char *value);
E char *get_redirect(Channel * chan);
E void set_redirect(Channel * chan, const char *value);
E void get_channel_stats(long *nrec, long *memuse);
E Channel *findchan(const char *chan);
E Channel *firstchan();
@@ -151,7 +127,6 @@ E long get_memuse(EList *list);
/**** chanserv.c ****/
E ChannelInfo *chanlists[256];
E CSModeUtil csmodeutils[];
E LevelInfo levelinfo[];
E void get_chanserv_stats(long *nrec, long *memuse);
@@ -190,14 +165,6 @@ E int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen);
E AutoKick *is_stuck(ChannelInfo * ci, const char *mask);
E void stick_mask(ChannelInfo * ci, AutoKick * akick);
E void stick_all(ChannelInfo * ci);
E char *cs_get_flood(ChannelInfo * ci);
E void cs_set_flood(ChannelInfo * ci, const char *value);
E char *cs_get_key(ChannelInfo * ci);
E void cs_set_key(ChannelInfo * ci, const char *value);
E char *cs_get_limit(ChannelInfo * ci);
E void cs_set_limit(ChannelInfo * ci, const char *value);
E char *cs_get_redirect(ChannelInfo * ci);
E void cs_set_redirect(ChannelInfo * ci, const char *value);
E int levelinfo_maxwidth;
E ChannelInfo *makechan(const char *chan);
@@ -481,29 +448,7 @@ E void pmodule_ircd_proto(IRCDProto *);
E void pmodule_ircd_var(IRCDVar * ircdvar);
E void pmodule_ircd_cap(IRCDCAPAB * cap);
E void pmodule_ircd_version(const char *version);
E void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos);
E void pmodule_ircd_cumodes(CUMode modes[128]);
E void pmodule_ircd_flood_mode_char_set(const char *mode);
E void pmodule_ircd_flood_mode_char_remove(const char *mode);
E void pmodule_ircd_cbmodes(CBMode modes[128]);
E void pmodule_ircd_cmmodes(CMMode modes[128]);
E void pmodule_ircd_csmodes(char mode[128]);
E void pmodule_ircd_useTSMode(int use);
E void pmodule_invis_umode(int mode);
E void pmodule_oper_umode(int mode);
E void pmodule_invite_cmode(int mode);
E void pmodule_secret_cmode(int mode);
E void pmodule_private_cmode(int mode);
E void pmodule_key_mode(int mode);
E void pmodule_limit_mode(int mode);
E int anope_get_secret_mode();
E int anope_get_invite_mode();
E int anope_get_key_mode();
E int anope_get_limit_mode();
E int anope_get_private_mode();
E int anope_get_invis_mode();
E int anope_get_oper_mode();
/**** language.c ****/
@@ -735,8 +680,6 @@ E void SetOperType(NickCore *nc);
E SList akills, sglines, sqlines, szlines;
E int DefConModesSet;
E uint32 DefConModesOn;
E uint32 DefConModesOff;
E ChannelInfo DefConModesCI;
E void operserv(User *u, char *buf);
-7
View File
@@ -1112,13 +1112,6 @@ int destroyMessage(Message *m); /* destroy a Message*/
MDE bool moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */
/*************************************************************************/
/* Some IRCD protocol module support functions */
/** Update the protect deatials, could be either protect or admin etc.. */
MDE void updateProtectDetails(const char *level_info_protect_word, const char *level_info_protectme_word, const char *fant_protect_add, const char *fant_protect_del, const char *level_protect_word, const char *protect_set_mode, const char *protect_unset_mode);
MDE void updateOwnerDetails(const char *fant_owner_add, const char *fant_owner_del, const char *owner_set_mode, const char *owner_del_mode);
/************************************************************************/
#endif
+123 -8
View File
@@ -9,8 +9,13 @@
*
*/
#include "services.h"
class CoreExport ChannelInfo : public Extensible
{
private:
std::map<ChannelModeName, std::string> Params;
public:
ChannelInfo()
{
@@ -23,8 +28,7 @@ class CoreExport ChannelInfo : public Extensible
bantype = akickcount = 0;
levels = NULL;
akick = NULL;
mlock_on = mlock_off = mlock_limit = 0;
mlock_key = mlock_flood = mlock_redirect = entry_message = NULL;
entry_message = NULL;
c = NULL;
bi = NULL;
botflags = 0;
@@ -63,17 +67,14 @@ class CoreExport ChannelInfo : public Extensible
uint16 akickcount;
AutoKick *akick; /* List of users to kickban */
uint32 mlock_on, mlock_off; /* See channel modes below */
uint32 mlock_limit; /* 0 if no limit */
char *mlock_key; /* NULL if no key */
char *mlock_flood; /* NULL if no +f */
char *mlock_redirect; /* NULL if no +L */
std::bitset<128> mlock_on;
std::bitset<128> mlock_off;
char *entry_message; /* Notice sent on entering channel */
MemoInfo memos;
struct channel_ *c; /* Pointer to channel record (if *
Channel *c; /* Pointer to channel record (if *
* channel is currently in use) */
/* For BotServ */
@@ -175,4 +176,118 @@ class CoreExport ChannelInfo : public Extensible
while (access.begin() != access.end())
EraseAccess(0);
}
/** Check if a mode is mlocked
* @param Name The mode
* @param status True to check mlock on, false for mlock off
* @return true on success, false on fail
*/
const bool HasMLock(ChannelModeName Name, bool status)
{
if (status)
return mlock_on[(size_t)Name];
else
return mlock_off[(size_t)Name];
}
/** Set a mlock
* @param Name The mode
* @param status True for mlock on, false for mlock off
*/
void SetMLock(ChannelModeName Name, bool status)
{
size_t value = (size_t)Name;
if (status)
mlock_on[value] = true;
else
mlock_off[value] = true;
}
/** Remove a mlock
* @param Name The mode
* @param status True for mlock on, false for mlock off
*/
void RemoveMLock(ChannelModeName Name, bool status)
{
size_t value = (size_t)Name;
if (status)
mlock_on[value] = false;
else
mlock_off[value] = false;
}
/** Clear all mlocks on the channel
*/
void ClearMLock()
{
mlock_on.reset();
mlock_off.reset();
}
/** Set a channel mode param on the channel
* @param Name The mode
* @param param The param
* @param true on success
*/
bool SetParam(ChannelModeName Name, std::string Value)
{
return Params.insert(std::make_pair(Name, Value)).second;
}
/** Unset a param from the channel
* @param Name The mode
*/
void UnsetParam(ChannelModeName Name)
{
std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
if (it != Params.end())
{
Params.erase(it);
}
}
/** Get a param from the channel
* @param Name The mode
* @param Target a string to put the param into
* @return true on success
*/
const bool GetParam(ChannelModeName Name, std::string *Target)
{
std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
(*Target).clear();
if (it != Params.end())
{
*Target = it->second;
return true;
}
return false;
}
/** Check if a mode is set and has a param
* @param Name The mode
*/
const bool HasParam(ChannelModeName Name)
{
std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
if (it != Params.end())
{
return true;
}
return false;
}
/** Clear all the params from the channel
*/
void ClearParams()
{
Params.clear();
}
};
+469 -122
View File
@@ -237,6 +237,7 @@ extern int strncasecmp(const char *, const char *, size_t);
#include <list>
#include <vector>
#include <deque>
#include <bitset>
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
@@ -422,10 +423,9 @@ class CoreExport Extensible
/* forward declarations, mostly used by older code */
class User;
class ChannelInfo;
class Channel;
typedef struct server_ Server;
typedef struct channel_ Channel;
typedef struct c_elist EList;
typedef struct c_elist_entry Entry;
typedef struct memo_ Memo;
@@ -438,14 +438,43 @@ typedef struct sxline_ SXLine;
typedef struct hostcore_ HostCore;
typedef struct newsitem_ NewsItem;
typedef struct exception_ Exception;
typedef struct cbmode_ CBMode;
typedef struct cbmodeinfo_ CBModeInfo;
typedef struct cmmode_ CMMode;
typedef struct csmode_ CSMode;
typedef struct cumode_ CUMode;
typedef struct csmodeutil_ CSModeUtil;
typedef struct session_ Session;
enum UserModeName
{
UMODE_BEGIN,
/* Usermodes */
UMODE_SERV_ADMIN, UMODE_BOT, UMODE_CO_ADMIN, UMODE_FILTER, UMODE_HIDEOPER, UMODE_NETADMIN,
UMODE_REGPRIV, UMODE_PROTECTED, UMODE_NO_CTCP, UMODE_WEBTV, UMODE_WHOIS, UMODE_ADMIN, UMODE_DEAF,
UMODE_GLOBOPS, UMODE_HELPOP, UMODE_INVIS, UMODE_OPER, UMODE_PRIV, UMODE_GOD, UMODE_REGISTERED,
UMODE_SNOMASK, UMODE_VHOST, UMODE_WALLOPS, UMODE_CLOAK, UMODE_SSL, UMODE_CALLERID,
UMODE_END
};
enum ChannelModeName
{
CMODE_BEGIN,
/* Channel modes */
CMODE_BLOCKCOLOR, CMODE_FLOOD, CMODE_INVITE, CMODE_KEY, CMODE_LIMIT, CMODE_MODERATED, CMODE_NOEXTERNAL,
CMODE_PRIVATE, CMODE_REGISTERED, CMODE_SECRET, CMODE_TOPIC, CMODE_AUDITORIUM, CMODE_SSL, CMODE_ADMINONLY,
CMODE_NOCTCP, CMODE_FILTER, CMODE_NOKNOCK, CMODE_REDIRECT, CMODE_REGMODERATED, CMODE_NONICK, CMODE_OPERONLY,
CMODE_NOKICK, CMODE_REGISTEREDONLY, CMODE_STRIPCOLOR, CMODE_NONOTICE, CMODE_NOINVITE, CMODE_ALLINVITE,
CMODE_BLOCKCAPS, CMODE_PERM,
/* b/e/I */
CMODE_BAN, CMODE_EXCEPT,
CMODE_INVITEOVERRIDE,
/* v/h/o/a/q */
CMODE_VOICE, CMODE_HALFOP, CMODE_OP,
CMODE_PROTECT, CMODE_OWNER,
CMODE_END
};
#include "bots.h"
#include "opertype.h"
@@ -460,35 +489,22 @@ struct ircdvars_ {
const char *name; /* Name of the IRCd command */
const char *pseudoclient_mode; /* Mode used by BotServ Bots */
int max_symbols; /* Chan Max Symbols */
const char *modestoremove; /* Channel Modes to remove */
const char *botchanumode; /* Modes set when botserv joins a channel */
int svsnick; /* Supports SVSNICK */
int vhost; /* Supports vhost */
int owner; /* Supports Owner */
const char *ownerset; /* Mode to set for owner */
const char *ownerunset; /* Mode to unset for a owner */
const char *adminset; /* Mode to set for admin */
const char *adminunset; /* Mode to unset for admin */
const char *modeonunreg; /* Mode on Unregister */
int sgline; /* Supports SGline */
int sqline; /* Supports SQline */
int szline; /* Supports SZline */
int halfop; /* Supports HalfOp */
int numservargs; /* Number of Server Args */
int join2set; /* Join 2 Set Modes */
int join2msg; /* Join 2 Message */
int except; /* exception +e */
int topictsforward; /* TS on Topics Forward */
int topictsbackward; /* TS on Topics Backward */
uint32 protectedumode; /* What is the Protected Umode */
int admin; /* Has Admin */
int chansqline; /* Supports Channel Sqlines */
int quitonkill; /* IRCD sends QUIT when kill */
int svsmode_unban; /* svsmode can be used to unban */
int protect; /* Has protect modes */
int reversekickcheck; /* Can reverse ban check */
int chanreg; /* channel mode +r for register */
uint32 regmode; /* Mode to use for +r */
int vident; /* Supports vidents */
int svshold; /* Supports svshold */
int tsonmode; /* Timestamp on mode changes */
@@ -497,28 +513,18 @@ struct ircdvars_ {
int umode; /* change user modes */
int nickvhost; /* Users vhost sent during NICK */
int chgreal; /* Change RealName */
uint32 noknock; /* Channel Mode for no knock */
uint32 adminmode; /* Admin Only Channel Mode */
uint32 defmlock; /* Default mlock modes */
uint32 vhostmode; /* Vhost mode */
int fmode; /* +f */
int Lmode; /* +L */
uint32 chan_fmode; /* Mode */
uint32 chan_lmode; /* Mode */
std::bitset<128> DefMLock; /* Default mlock modes */
int check_nick_id; /* On nick change check if they could be identified */
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
char *chanmodes; /* If the ircd sends CHANMODE in CAPAB this is where we store it */
int token; /* Does Anope support the tokens for the ircd */
int sjb64; /* Base 64 encode TIMESTAMP */
int invitemode; /* +I */
int sjoinbanchar; /* use single quotes to define it */
int sjoinexchar; /* use single quotes to define it */
int sjoininvchar; /* use single quotes to define it */
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
int sglineenforce;
const char *vhostchar; /* char used for vhosting */
int ts6; /* ircd is TS6 */
int supporthelper; /* +h helper umodes */
int p10; /* ircd is P10 */
char *nickchars; /* character set */
int cidrchanbei; /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15)
@@ -595,7 +601,6 @@ typedef struct {
} MemoInfo;
/*************************************************************************/
// For NickServ
@@ -784,17 +789,6 @@ struct badword_ {
/*************************************************************************/
/* ChanServ mode utilities commands */
struct csmodeutil_ {
const char *name; /* Name of the ChanServ command */
const char *bsname; /* Name of the BotServ fantasy command */
const char *mode; /* Mode (ie. +o) */
int32 notice; /* Notice flag (for the damn OPNOTICE) */
int level; /* Level required to use the command */
int levelself; /* Level required to use the command for himself */
};
typedef struct {
int what;
const char *name;
@@ -830,48 +824,18 @@ struct server_ {
#define SERVER_ISUPLINK 0x0004
/*************************************************************************/
#define CUS_OP 0x0001
#define CUS_VOICE 0x0002
#define CUS_HALFOP 0x0004 /* Halfop (+h) */
#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */
#define CUS_PROTECT 0x0010 /* Protected users (+a) */
/* #define CUS_DEOPPED 0x0080 */ /* Removed due to IRCd checking it */
/*************************************************************************/
#include "users.h"
struct cbmode_ {
uint32 flag; /* Long value that represents the mode */
uint16 flags; /* Flags applying to this mode (CBM_* below) */
/* Function to associate a value with the mode */
void (*setvalue) (Channel *chan, const char *value);
void (*cssetvalue) (ChannelInfo *ci, const char *value);
};
#define CBM_MINUS_NO_ARG 0x0001 /* No argument for unset */
#define CBM_NO_MLOCK 0x0002 /* Can't be MLOCKed */
#define CBM_NO_USER_MLOCK 0x0004 /* Can't be MLOCKed by non-opers */
struct cbmodeinfo_ {
char mode; /* The mode */
uint32 flag; /* Long value that represents the mode */
uint16 flags; /* CBM_* above */
/* Function to retrieve the value associated to the mode (optional) */
char * (*getvalue) (Channel *chan);
char * (*csgetvalue) (ChannelInfo *ci);
};
struct cmmode_ {
void (*addmask) (Channel *chan, const char *mask);
void (*delmask) (Channel *chan, const char *mask);
};
struct cumode_ {
int16 status; /* CUS_* below */
int16 flags; /* CUF_* below */
int (*is_valid) (User *user, Channel *chan, int servermode);
};
/* Channel user mode flags */
#define CUF_PROTECT_BOTSERV 0x0001
/* This structure stocks ban data since it must not be removed when
* user is kicked.
*/
@@ -918,7 +882,21 @@ struct c_userlist {
UserData *ud;
};
struct channel_ {
class CoreExport Channel
{
private:
/** A map of channel modes with their parameters set on this channel
*/
std::map<ChannelModeName, std::string> Params;
public:
Channel() { }
~Channel()
{
Params.clear();
}
Channel *next, *prev;
char name[CHANMAX];
ChannelInfo *ci; /* Corresponding ChannelInfo */
@@ -926,11 +904,8 @@ struct channel_ {
char *topic;
char topic_setter[NICKMAX]; /* Who set the topic */
time_t topic_time; /* When topic was set */
uint32 mode; /* Binary modes only */
uint32 limit; /* 0 if none */
char *key; /* NULL if none */
char *redirect; /* +L; NULL if none */
char *flood; /* +f; NULL if none */
std::bitset<128> modes;
EList *bans;
EList *excepts;
EList *invites;
@@ -946,6 +921,81 @@ struct channel_ {
int16 chanserv_modecount; /* Number of check_mode()'s this sec */
int16 bouncy_modes; /* Did we fail to set modes here? */
int16 topic_sync; /* Is the topic in sync? */
/**
* See if a channel has a mode
* @param Name The mode name
* @return true or false
*/
bool HasMode(ChannelModeName Name);
/**
* Set a mode on a channel
* @param Name The mode name
*/
void SetMode(ChannelModeName Name);
/**
* Set a mode on a channel
* @param Mode The mode
*/
void SetMode(char Mode);
/**
* Remove a mode from a channel
* @param Name The mode name
*/
void RemoveMode(ChannelModeName Name);
/**
* Remove a mode from a channel
* @param Mode The mode
*/
void RemoveMode(char Mode);
/** Clear all the modes from the channel
* @param client The client unsetting the modes
*/
void ClearModes(char *client = NULL);
/** Clear all the bans from the channel
* @param client The client unsetting the modes
*/
void ClearBans(char *client = NULL);
/** Clear all the excepts from the channel
* @param client The client unsetting the modes
*/
void ClearExcepts(char *client = NULL);
/** Clear all the invites from the channel
* @param client The client unsetting the modes
*/
void ClearInvites(char *client = NULL);
/** Set a channel mode param on the channel
* @param Name The mode
* @param param The param
* @param true on success
*/
bool SetParam(ChannelModeName Name, std::string &param);
/** Unset a param from the channel
* @param Name The mode
*/
void UnsetParam(ChannelModeName Name);
/** Get a param from the channel
* @param Name The mode
* @param Target a string to put the param into
* @return true on success
*/
const bool GetParam(ChannelModeName Name, std::string *Target);
/** Check if a mode is set and has a param
* @param Name The mode
*/
const bool HasParam(ChannelModeName Name);
};
struct c_elist {
@@ -1055,6 +1105,335 @@ struct exception_ {
* calculated at load time and never saved. */
};
/*************************************************************************/
/** The different types of modes
*/
enum ModeType
{
/* Regular mode */
MODE_REGULAR,
/* b/e/I */
MODE_LIST,
/* k/l etc */
MODE_PARAM,
/* v/h/o/a/q */
MODE_STATUS
};
/** This class is a user mode, all user modes use this/inherit from this
*/
class UserMode
{
public:
/* Mode name */
UserModeName Name;
/* The mode char */
char ModeChar;
/** Default constructor
* @param nName The mode name
* @param mMode A value representing the mode
*/
UserMode(UserModeName mName)
{
this->Name = mName;
}
/** Default destructor
*/
virtual ~UserMode() { }
};
/** This class is a channel mode, all channel modes use this/inherit from this
*/
class ChannelMode
{
public:
/* Mode name */
ChannelModeName Name;
/* Type of mode this is */
ModeType Type;
/* The mode char */
char ModeChar;
/** Default constructor
* @param mName The mode name
* @param mMode A value representing the mode
*/
ChannelMode(ChannelModeName mName)
{
this->Name = mName;
this->Type = MODE_REGULAR;
}
/** Default destructor
*/
virtual ~ChannelMode() { }
/** Can a user set this mode, used for mlock
* NOTE: User CAN be NULL, this is for checking if it can be locked with defcon
* @param u The user, or NULL
*/
virtual bool CanSet(User *u) { return true; }
};
/** This is a mode for lists, eg b/e/I. These modes should inherit from this
*/
class ChannelModeList : public ChannelMode
{
public:
/** Default constructor
* @param mName The mode name
*/
ChannelModeList(ChannelModeName mName) : ChannelMode(mName)
{
this->Type = MODE_LIST;
}
/** Default destructor
*/
virtual ~ChannelModeList() { }
/** Is the mask valid
* @param mask The mask
* @return true for yes, false for no
*/
virtual bool IsValid(const char *mask) { return true; }
/** Add the mask to the channel, this should be overridden
* @param chan The channel
* @param mask The mask
*/
virtual void AddMask(Channel *chan, const char *mask) { }
/** Delete the mask from the channel, this should be overridden
* @param chan The channel
* @param mask The mask
*/
virtual void DelMask(Channel *chan, const char *mask) { }
};
/** This is a mode with a paramater, eg +k/l. These modes should use/inherit from this
*/
class ChannelModeParam : public ChannelMode
{
public:
/** Default constructor
* @param mName The mode name
* @param mMode A value representing the mode
*/
ChannelModeParam(ChannelModeName mName) : ChannelMode(mName)
{
this->Type = MODE_PARAM;
MinusNoArg = false;
}
/** Default destructor
*/
virtual ~ChannelModeParam() { }
/* Should we send an arg when unsetting this mode? */
bool MinusNoArg;
/** Is the param valid
* @param value The param
* @return true for yes, false for no
*/
virtual bool IsValid(const char *value) { return true; }
};
/** This is a mode that is a channel status, eg +v/h/o/a/q.
*/
class ChannelModeStatus : public ChannelMode
{
public:
/** CUS_ values, see below
*/
int16 Status;
/* The symbol, eg @ % + */
char Symbol;
/** Default constructor
* @param mName The mode name
* @param mStatus A CUS_ value
*/
ChannelModeStatus(ChannelModeName mName, int16 mStatus, char mSymbol, bool mProtectBotServ = false) : ChannelMode(mName)
{
this->Type = MODE_STATUS;
this->Status = mStatus;
this->Symbol = mSymbol;
this->ProtectBotServ = mProtectBotServ;
}
/** Default destructor
*/
virtual ~ChannelModeStatus() { }
/* Should botserv protect itself with this mode? eg if someone -o's botserv it will +o */
bool ProtectBotServ;
};
/** This class manages modes, and has the ability to add channel and
* user modes to Anope to track internally
*/
class CoreExport ModeManager
{
public:
/* User modes */
static std::map<char, UserMode *> UserModesByChar;
static std::map<UserModeName, UserMode *> UserModesByName;
/* Channel modes */
static std::map<char, ChannelMode *> ChannelModesByChar;
static std::map<ChannelModeName, ChannelMode *> ChannelModesByName;
/* Although there are two different maps for UserModes and ChannelModes
* the pointers in each are the same. This is used to increase
* efficiency.
*/
/** Add a user mode to Anope
* @param Mode The mode
* @param um A UserMode or UserMode derived class
* @return true on success, false on error
*/
static bool AddUserMode(char Mode, UserMode *um);
/** Add a channel mode to Anope
* @param Mode The mode
* @param cm A ChannelMode or ChannelMode derived class
* @return true on success, false on error
*/
static bool AddChannelMode(char Mode, ChannelMode *cm);
/** Find a channel mode
* @param Mode The mode
* @return The mode class
*/
static ChannelMode *FindChannelModeByChar(char Mode);
/** Find a user mode
* @param Mode The mode
* @return The mode class
*/
static UserMode *FindUserModeByChar(char Mode);
/** Find a channel mode
* @param Mode The modename
* @return The mode class
*/
static ChannelMode *FindChannelModeByName(ChannelModeName Name);
/** Find a user mode
* @param Mode The modename
* @return The mode class
*/
static UserMode *FindUserModeByName(UserModeName Name);
/** Gets the channel mode char for a symbol (eg + returns v)
* @param Value The symbol
* @return The char
*/
static char GetStatusChar(char Value);
};
/** Channel mode +b
*/
class ChannelModeBan : public ChannelModeList
{
public:
ChannelModeBan() : ChannelModeList(CMODE_BAN) { }
void AddMask(Channel *chan, const char *mask);
void DelMask(Channel *chan, const char *mask);
};
/** Channel mode +e
*/
class ChannelModeExcept : public ChannelModeList
{
public:
ChannelModeExcept() : ChannelModeList(CMODE_EXCEPT) { }
void AddMask(Channel *chan, const char *mask);
void DelMask(Channel *chan, const char *mask);
};
/** Channel mode +I
*/
class ChannelModeInvite : public ChannelModeList
{
public:
ChannelModeInvite() : ChannelModeList(CMODE_INVITEOVERRIDE) { }
void AddMask(Channel *chan, const char *mask);
void DelMask(Channel *chan, const char *mask);
};
/** Channel mode +k (key)
*/
class ChannelModeKey : public ChannelModeParam
{
public:
ChannelModeKey() : ChannelModeParam(CMODE_KEY) { }
bool IsValid(const char *value);
};
/** Channel mode +f (flood)
*/
class ChannelModeFlood : public ChannelModeParam
{
public:
ChannelModeFlood() : ChannelModeParam(CMODE_FLOOD) { }
bool IsValid(const char *value);
};
/** This class is used for channel mode +A (Admin only)
* Only opers can mlock it
*/
class ChannelModeAdmin : public ChannelMode
{
public:
ChannelModeAdmin() : ChannelMode(CMODE_ADMINONLY) { }
/* Opers only */
bool CanSet(User *u);
};
/** This class is used for channel mode +O (Opers only)
* Only opers can mlock it
*/
class ChannelModeOper : public ChannelMode
{
public:
ChannelModeOper() : ChannelMode(CMODE_OPERONLY) { }
/* Opers only */
bool CanSet(User *u);
};
/** This class is used for channel mode +r (registered channel)
* No one may mlock r
*/
class ChannelModeRegistered : public ChannelMode
{
public:
ChannelModeRegistered() : ChannelMode(CMODE_REGISTERED) { }
/* No one mlocks +r */
bool CanSet(User *u);
};
/*************************************************************************/
struct session_ {
@@ -1064,19 +1443,6 @@ struct session_ {
int hits; /* Number of subsequent kills for a host */
};
/*************************************************************************/
typedef struct ircd_modes_ {
int user_invis;
int user_oper;
int chan_invite;
int chan_secret;
int chan_private;
int chan_key;
int chan_limit;
} IRCDModes;
/*************************************************************************/
/**
* DEFCON Defines
@@ -1182,24 +1548,6 @@ typedef struct ircd_modes_ {
#define BI_NICKSERV 0x0040
#define BI_GLOBAL 0x0080
#define CUS_OP 0x0001
#define CUS_VOICE 0x0002
#define CUS_HALFOP 0x0004 /* Halfop (+h) */
#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */
#define CUS_PROTECT 0x0010 /* Protected users (+a) */
/* #define CUS_DEOPPED 0x0080 */ /* Removed due to IRCd checking it */
#define MUT_DEOP 0
#define MUT_OP 1
#define MUT_DEVOICE 2
#define MUT_VOICE 3
#define MUT_DEHALFOP 4
#define MUT_HALFOP 5
#define MUT_DEPROTECT 6
#define MUT_PROTECT 7
#define MUT_DEOWNER 8
#define MUT_OWNER 9
/*************************************************************************/
/* CAPAB stuffs */
@@ -1338,7 +1686,6 @@ class CoreExport IRCDProto
virtual void ProcessUsermodes(User *, int, const char **) = 0;
virtual int IsNickValid(const char *) { return 1; }
virtual int IsChannelValid(const char *);
virtual int IsFloodModeParamValid(const char *) { return 0; }
virtual void SendNumeric(const char *source, int numeric, const char *dest, const char *fmt, ...);
/** Sends a message logging a user into an account, where ircds support such a feature.
+28 -1
View File
@@ -8,6 +8,7 @@
* $Id$
*
*/
struct u_chanlist {
struct u_chanlist *next, *prev;
Channel *chan;
@@ -41,7 +42,7 @@ class CoreExport User : public Extensible
Server *server; /* Server user is connected to */
time_t timestamp; /* Timestamp of the nick */
time_t my_signon; /* When did _we_ see the user? */
uint32 mode; /* See below */
std::bitset<128> modes;
NickCore *nc;
@@ -161,5 +162,31 @@ class CoreExport User : public Extensible
/** Update the last usermask stored for a user, and check to see if they are recognized
*/
void UpdateHost();
/** Check if the user has a mode
* @param Name Mode name
* @return true or false
*/
const bool HasMode(UserModeName Name) const;
/** Set a mode on the user
* @param Name The mode name
*/
void SetMode(UserModeName Name);
/* Set a mode on the user
* @param ModeChar The mode char
*/
void SetMode(char ModeChar);
/** Remove a mode from the user
* @param Name The mode name
*/
void RemoveMode(UserModeName Name);
/** Remove a mode from the user
* @param ModeChar The mode char
*/
void RemoveMode(char ModeChar);
};
-4
View File
@@ -4227,10 +4227,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-5
View File
@@ -4262,11 +4262,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gibt dir Gründer Staus in einen Channel
CHAN_HELP_CMD_PROTECT
PROTECT Schützt den angegebenen Nicknamen in einen Channel
CHAN_HELP_CMD_ADMIN
ADMIN Schützt den angegebenen Nicknamen in einen Channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Entfernt den Schutz des angegebenen Nicknamens
in einen Channel
CHAN_HELP_CMD_DEOP
DEOP Enfernt den OP-Status des angegebenen Nicknamens
in einen Channel
-4
View File
@@ -4075,10 +4075,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-4
View File
@@ -4198,10 +4198,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-4
View File
@@ -4259,10 +4259,6 @@ CHAN_HELP_CMD_OWNER
OWNER Vous donne votre accès owner sur un canal
CHAN_HELP_CMD_PROTECT
PROTECT Protège le pseudo spécifié sur un canal
CHAN_HELP_CMD_ADMIN
ADMIN Protège le pseudo spécifié sur un canal
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotège le pseudo donné sur un canal
CHAN_HELP_CMD_DEOP
DEOP Deop le pseudo spécifié sur un canal
-4
View File
@@ -4217,10 +4217,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-4
View File
@@ -4139,10 +4139,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-4
View File
@@ -4091,10 +4091,6 @@ CHAN_HELP_CMD_OWNER
OWNER Assegna lo stato di owner a un utente (+q)
CHAN_HELP_CMD_PROTECT
PROTECT Assegna lo stato di protezione a un utente (+a)
CHAN_HELP_CMD_ADMIN
ADMIN Protegge un nick su un canale
CHAN_HELP_CMD_DEADMIN
DEADMIN Sprotegge un nick su un canale
CHAN_HELP_CMD_DEOP
DEOP Toglie lo stato di operatore a un utente (-o)
-4
View File
@@ -4176,10 +4176,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
-6
View File
@@ -5199,12 +5199,6 @@ CHAN_HELP_CMD_OWNER
CHAN_HELP_CMD_PROTECT
PROTECT Chroni wskazan± osobê
CHAN_HELP_CMD_ADMIN
ADMIN Chroni wskazan± osobê
CHAN_HELP_CMD_DEADMIN
DEADMIN Wy³±cza ochronê wskazanej osoby
CHAN_HELP_CMD_DEOP
DEOP Odbiera wskazanej osobie uprawnienia operatora
-4
View File
@@ -4096,10 +4096,6 @@ CHAN_HELP_CMD_OWNER
OWNER Concede-lhe status de Owner no canal
CHAN_HELP_CMD_PROTECT
PROTECT Protege um determinado nick no canal
CHAN_HELP_CMD_ADMIN
ADMIN Protege um determinado nick no canal
CHAN_HELP_CMD_DEADMIN
DEADMIN Desprotege um determinado nick no canal
CHAN_HELP_CMD_DEOP
DEOP Retira o status de OP de um nick no canal
-4
View File
@@ -4158,10 +4158,6 @@ CHAN_HELP_CMD_OWNER
OWNER Запрос статуса владельца на канале
CHAN_HELP_CMD_PROTECT
PROTECT Установка режима защиты (+a) указанному нику на канале
CHAN_HELP_CMD_ADMIN
ADMIN Установка статуса администратора (+a) указанному нику на канале
CHAN_HELP_CMD_DEADMIN
DEADMIN Снятие режима администратора (-a) с указанного ника на канале
CHAN_HELP_CMD_DEOP
DEOP Снятие режима оператора (-o) с указанного ника на канале
-4
View File
@@ -4210,10 +4210,6 @@ CHAN_HELP_CMD_OWNER
OWNER Gives you owner status on channel
CHAN_HELP_CMD_PROTECT
PROTECT Protects a selected nick on a channel
CHAN_HELP_CMD_ADMIN
ADMIN Protects a selected nick on a channel
CHAN_HELP_CMD_DEADMIN
DEADMIN Deprotects a selected nick on a channel
CHAN_HELP_CMD_DEOP
DEOP Deops a selected nick on a channel
+2 -1
View File
@@ -2,7 +2,7 @@ OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o command.o comm
config.o datafiles.o encrypt.o hashcomp.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \
memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \
process.o protocol.o send.o servers.o sessions.o slist.o sockutil.o opertype.o users.o module.o modulemanager.o configreader.o \
wildcard.o nickcore.o nickalias.o timers.o
wildcard.o nickcore.o nickalias.o timers.o modes.o
INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \
../include/pseudo.h ../include/sysconf.h ../include/config.h \
@@ -33,6 +33,7 @@ services: $(OBJS)
$(MAKEBIN) $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS)
$(OBJS): Makefile
modes.o: modes.cpp $(INCLUDES)
timers.o: timers.cpp $(INCLUDES)
nickcore.o: nickcore.cpp $(INCLUDES)
nickalias.o: nickalias.cpp $(INCLUDES)
+18 -8
View File
@@ -772,12 +772,19 @@ void bot_join(ChannelInfo * ci)
}
}
std::string Limit;
int limit = 0;
if (ci->c->GetParam(CMODE_LIMIT, &Limit))
{
limit = atoi(Limit.c_str());
}
/* Should we be invited? */
if ((ci->c->mode & anope_get_invite_mode())
|| (ci->c->limit && ci->c->usercount >= ci->c->limit))
if (ci->c->HasMode(CMODE_INVITE)
|| (limit && ci->c->usercount >= limit))
ircdproto->SendNoticeChanops(NULL, ci->c->name,
"%s invited %s into the channel.",
ci->bi->nick, ci->bi->nick);
"%s invited %s into the channel.",
ci->bi->nick, ci->bi->nick);
}
ircdproto->SendJoin(ci->bi, ci->c->name, ci->c->creation_time);
ircdproto->SendBotOp(ci->bi->nick, ci->c->name);
@@ -877,7 +884,8 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
if (!u)
return;
if (ircd->protectedumode) {
if ((ModeManager::FindUserModeByName(UMODE_PROTECTED)))
{
if (is_protected(u) && (requester != u)) {
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s",
getstring(ACCESS_DENIED));
@@ -889,7 +897,8 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
&& (get_access(u, ci) >= get_access(requester, ci)))
return;
if (ircd->except) {
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
{
if (is_excepted(ci, u) == 1) {
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s",
getstring(BOT_EXCEPT));
@@ -953,7 +962,8 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
if (!u || !is_on_chan(ci->c, u))
return;
if (ircd->protectedumode) {
if ((ModeManager::FindUserModeByName(UMODE_PROTECTED)))
{
if (is_protected(u) && (requester != u)) {
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s",
getstring(ACCESS_DENIED));
@@ -1007,7 +1017,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode,
snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL)));
if (ircd->protectedumode) {
if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) {
if (is_protected(u) && *mode == '-' && (requester != u)) {
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s",
getstring(ACCESS_DENIED));
+512 -427
View File
File diff suppressed because it is too large Load Diff
+240 -344
View File
@@ -104,21 +104,6 @@ LevelInfo levelinfo[] = {
};
int levelinfo_maxwidth = 0;
CSModeUtil csmodeutils[] = {
{ "DEOP", "deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME },
{ "OP", "op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME },
{ "DEVOICE", "devoice", "-v", 0, CA_VOICE, CA_VOICEME },
{ "VOICE", "voice", "+v", 0, CA_VOICE, CA_VOICEME },
{ "DEHALFOP", "dehalfop", "-h", 0, CA_HALFOP, CA_HALFOPME },
{ "HALFOP", "halfop", "+h", 0, CA_HALFOP, CA_HALFOPME },
/* These get set later */
{ "DEPROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME },
{ "PROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME },
{ "DEOWNER", "", "", 0, ACCESS_FOUNDER, ACCESS_FOUNDER},
{ "OWNER", "", "", 0, ACCESS_FOUNDER, ACCESS_FOUNDER},
{ NULL }
};
/*************************************************************************/
void moduleAddChanServCmds() {
@@ -156,54 +141,68 @@ class ChanServTimer : public Timer
char *get_mlock_modes(ChannelInfo * ci, int complete)
{
static char res[BUFSIZE];
char *end, *value;
ChannelMode *cm;
ChannelModeParam *cmp;
std::map<char, ChannelMode *>::iterator it;
std::string param;
char *end = res;
memset(&res, '\0', sizeof(res));
end = res;
if (ci->mlock_on || ci->mlock_off) {
unsigned int n = 0;
CBModeInfo *cbmi = cbmodeinfos;
if (ci->mlock_on) {
if (ci->mlock_on.count() || ci->mlock_off.count())
{
if (ci->mlock_on.count())
{
*end++ = '+';
n++;
do {
if (ci->mlock_on & cbmi->flag)
*end++ = cbmi->mode;
} while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
cbmi = cbmodeinfos;
if (ci->HasMLock(cm->Name, true))
*end++ = it->first;
}
}
if (ci->mlock_off) {
if (ci->mlock_off.count())
{
*end++ = '-';
n++;
do {
if (ci->mlock_off & cbmi->flag)
*end++ = cbmi->mode;
} while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
cbmi = cbmodeinfos;
if (ci->HasMLock(cm->Name, false))
*end++ = it->first;
}
}
if (ci->mlock_on && complete) {
do {
if (cbmi->csgetvalue && (ci->mlock_on & cbmi->flag)) {
char *value = cbmi->csgetvalue(ci);
if (ci->mlock_on.count() && complete)
{
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
ci->GetParam(cmp->Name, &param);
if (!param.empty())
{
value = const_cast<char *>(param.c_str());
if (value) {
*end++ = ' ';
while (*value)
*end++ = *value++;
}
}
} while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1);
}
}
}
*end = 0;
return res;
}
@@ -216,6 +215,7 @@ void get_chanserv_stats(long *nrec, long *memuse)
long count = 0, mem = 0;
unsigned i, j;
ChannelInfo *ci;
std::string param;
for (i = 0; i < 256; i++) {
for (ci = chanlists[i]; ci; ci = ci->next) {
@@ -239,16 +239,16 @@ void get_chanserv_stats(long *nrec, long *memuse)
if (ci->akick[j].creator)
mem += strlen(ci->akick[j].creator) + 1;
}
if (ci->mlock_key)
mem += strlen(ci->mlock_key) + 1;
if (ircd->fmode) {
if (ci->mlock_flood)
mem += strlen(ci->mlock_flood) + 1;
}
if (ircd->Lmode) {
if (ci->mlock_redirect)
mem += strlen(ci->mlock_redirect) + 1;
}
if (ci->GetParam(CMODE_KEY, &param))
mem += param.length() + 1;
if (ci->GetParam(CMODE_FLOOD, &param))
mem += param.length() + 1;
if (ci->GetParam(CMODE_REDIRECT, &param))
mem += param.length() + 1;
if (ci->last_topic)
mem += strlen(ci->last_topic) + 1;
if (ci->entry_message)
@@ -477,12 +477,40 @@ void load_cs_dbase()
ci->akick = NULL;
}
SAFE(read_int32(&ci->mlock_on, f));
SAFE(read_int32(&ci->mlock_off, f));
SAFE(read_int32(&ci->mlock_limit, f));
SAFE(read_string(&ci->mlock_key, f));
SAFE(read_string(&ci->mlock_flood, f));
SAFE(read_string(&ci->mlock_redirect, f));
//SAFE(read_int32(&ci->mlock_on, f));
//SAFE(read_int32(&ci->mlock_off, f));
// Clearly this doesn't work
SAFE(read_int32(&tmp32, f));
SAFE(read_int32(&tmp32, f));
SAFE(read_int32(&tmp32, f));
if (tmp32)
{
std::ostringstream limit;
limit << tmp32;
ci->SetParam(CMODE_LIMIT, limit.str());
}
SAFE(read_string(&s, f));
if (s)
{
ci->SetParam(CMODE_KEY, std::string(s));
delete [] s;
}
SAFE(read_string(&s, f));
if (s)
{
ci->SetParam(CMODE_FLOOD, std::string(s));
delete [] s;
}
SAFE(read_string(&s, f));
if (s)
{
ci->SetParam(CMODE_REDIRECT, std::string(s));
delete [] s;
}
SAFE(read_int16(&tmp16, f));
if (tmp16) ci->memos.memos.resize(tmp16);
@@ -598,6 +626,7 @@ void save_cs_dbase()
unsigned i, j;
ChannelInfo *ci;
static time_t lastwarn = 0;
std::string param;
if (!(f = open_db(s_ChanServ, ChanDBName, "w", CHAN_VERSION)))
return;
@@ -661,12 +690,24 @@ void save_cs_dbase()
}
}
SAFE(write_int32(ci->mlock_on, f));
SAFE(write_int32(ci->mlock_off, f));
SAFE(write_int32(ci->mlock_limit, f));
SAFE(write_string(ci->mlock_key, f));
SAFE(write_string(ci->mlock_flood, f));
SAFE(write_string(ci->mlock_redirect, f));
//SAFE(write_int32(ci->mlock_on, f));
//SAFE(write_int32(ci->mlock_off, f));
// Clearly this doesnt work
SAFE(write_int32(NULL, f));
SAFE(write_int32(NULL, f));
ci->GetParam(CMODE_LIMIT, &param);
SAFE(write_int32(param.empty() ? NULL : atoi(param.c_str()), f));
ci->GetParam(CMODE_KEY, &param);
SAFE(write_string(param.empty() ? NULL : param.c_str(), f));
ci->GetParam(CMODE_FLOOD, &param);
SAFE(write_string(param.empty() ? NULL : param.c_str(), f));
ci->GetParam(CMODE_REDIRECT, &param);
SAFE(write_string(param.empty() ? NULL : param.c_str(), f));
SAFE(write_int16(ci->memos.memos.size(), f));
SAFE(write_int16(ci->memos.memomax, f));
for (j = 0; j < ci->memos.memos.size(); j++) {
@@ -730,16 +771,18 @@ void save_cs_dbase()
void check_modes(Channel * c)
{
char modebuf[64], argbuf[BUFSIZE], *end = modebuf, *end2 = argbuf;
uint32 modes = 0;
time_t t = time(NULL);
ChannelInfo *ci;
CBModeInfo *cbmi;
CBMode *cbm;
ChannelMode *cm;
ChannelModeParam *cmp;
char modebuf[64], argbuf[BUFSIZE], *end = modebuf, *end2 = argbuf, *value, *csvalue;
std::map<char, ChannelMode *>::iterator it;
std::string param, ciparam;
if (!c) {
if (debug) {
if (!c)
{
if (debug)
alog("debug: check_modes called with NULL values");
}
return;
}
@@ -747,148 +790,136 @@ void check_modes(Channel * c)
return;
/* Check for mode bouncing */
if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) {
ircdproto->SendGlobops(NULL,
"Warning: unable to set modes on channel %s. "
"Are your servers' U:lines configured correctly?",
c->name);
if (c->server_modecount >= 3 && c->chanserv_modecount >= 3)
{
ircdproto->SendGlobops(NULL, "Warning: unable to set modes on channel %s. Are your servers' U:lines configured correctly?", c->name);
alog("%s: Bouncy modes on channel %s", s_ChanServ, c->name);
c->bouncy_modes = 1;
return;
}
if (c->chanserv_modetime != time(NULL)) {
if (c->chanserv_modetime != time(NULL))
{
c->chanserv_modecount = 0;
c->chanserv_modetime = time(NULL);
c->chanserv_modetime = t;
}
c->chanserv_modecount++;
/* Check if the channel is registered; if not remove mode -r */
if (!(ci = c->ci)) {
if (ircd->regmode) {
if (c->mode & ircd->regmode) {
c->mode &= ~ircd->regmode;
ircdproto->SendMode(whosends(ci), c->name, "-r");
}
if (!(ci = c->ci))
{
if (c->HasMode(CMODE_REGISTERED))
{
c->RemoveMode(CMODE_REGISTERED);
ircdproto->SendMode(whosends(ci), c->name, "-r");
}
/* Channels that are not regged also need the defcon modes.. ~ Viper */
/* return; */
}
/* Initialize the modes-var to set all modes not set yet but which should
* be set as by mlock and defcon.
*/
if (ci)
modes = ~c->mode & ci->mlock_on;
if (DefConModesSet)
modes |= (~c->mode & DefConModesOn);
/* Initialize the buffers */
*end++ = '+';
cbmi = cbmodeinfos;
do {
if (modes & cbmi->flag) {
*end++ = cbmi->mode;
c->mode |= cbmi->flag;
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
/* If this channel does not have the mode and the mode is mlocked/defcon'd */
if (!c->HasMode(cm->Name) && (ci && ci->HasMLock(cm->Name, true)) || (DefConModesSet && DefConModesCI.HasMLock(cm->Name, true)))
{
*end++ = it->first;
c->SetMode(cm->Name);
/* Add the eventual parameter and modify the Channel structure */
if (cbmi->getvalue && cbmi->csgetvalue) {
char *value;
/* Check if it's a defcon or mlock mode */
if (DefConModesOn & cbmi->flag)
value = cbmi->csgetvalue(&DefConModesCI);
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
param.clear();
if (DefConModesSet && DefConModesCI.HasMLock(cm->Name, true))
DefConModesCI.GetParam(cmp->Name, &param);
else if (ci)
value = cbmi->csgetvalue(ci);
else {
value = NULL;
if (debug)
alog ("Warning: setting modes with unknown origin.");
}
ci->GetParam(cmp->Name, &param);
else
alog("Warning: Got no param for mode %c on channel %s but was expecting one", cmp->ModeChar, c->name);
cbm = &cbmodes[static_cast<int>(cbmi->mode)];
cbm->setvalue(c, value);
if (!param.empty())
{
value = const_cast<char *>(param.c_str());
if (value) {
*end2++ = ' ';
while (*value)
*end2++ = *value++;
}
}
} else if (cbmi->getvalue && cbmi->csgetvalue
&& ((ci && (ci->mlock_on & cbmi->flag))
|| (DefConModesOn & cbmi->flag))
&& (c->mode & cbmi->flag)) {
char *value = cbmi->getvalue(c);
char *csvalue;
}
/* If this is a param mode and its mlocked or defcon has it set negative */
else if (cm->Type == MODE_PARAM && c->HasMode(cm->Name) && (ci && ci->HasMLock(cm->Name, true) || (DefConModesSet && DefConModesCI.HasMLock(cm->Name, true))))
{
cmp = static_cast<ChannelModeParam *>(cm);
/* Check if it's a defcon or mlock mode */
if (DefConModesOn & cbmi->flag)
csvalue = cbmi->csgetvalue(&DefConModesCI);
c->GetParam(cmp->Name, &param);
if (DefConModesSet && DefConModesCI.HasMLock(cm->Name, true))
DefConModesCI.GetParam(cmp->Name, &ciparam);
else if (ci)
csvalue = cbmi->csgetvalue(ci);
else {
csvalue = NULL;
if (debug)
alog ("Warning: setting modes with unknown origin.");
}
ci->GetParam(cmp->Name, &ciparam);
else
alog("Warning: Got no param for mode %c on channel %s but was expecting one", cmp->ModeChar, c->name);
/* Lock and actual values don't match, so fix the mode */
if (value && csvalue && strcmp(value, csvalue)) {
*end++ = cbmi->mode;
if (!param.empty() && !ciparam.empty() && param != ciparam)
{
value = const_cast<char *>(param.c_str());
csvalue = const_cast<char *>(ciparam.c_str());
cbm = &cbmodes[static_cast<int>(cbmi->mode)];
cbm->setvalue(c, csvalue);
*end++ = it->first;
c->SetParam(cmp->Name, ciparam);
*end2++ = ' ';
while (*csvalue)
*end2++ = *csvalue++;
}
}
} while ((++cbmi)->flag != 0);
if (*(end - 1) == '+')
end--;
modes = 0;
if (ci) {
modes = c->mode & ci->mlock_off;
/* Make sure we don't remove a mode just set by defcon.. ~ Viper */
if (DefConModesSet)
modes &= ~(modes & DefConModesOn);
}
if (DefConModesSet)
modes |= c->mode & DefConModesOff;
if (modes) {
*end++ = '-';
cbmi = cbmodeinfos;
*end++ = '-';
do {
if (modes & cbmi->flag) {
*end++ = cbmi->mode;
c->mode &= ~cbmi->flag;
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
/* Add the eventual parameter and clean up the Channel structure */
if (cbmi->getvalue) {
cbm = &cbmodes[static_cast<int>(cbmi->mode)];
/* If the channel has the mode */
if (c->HasMode(cm->Name) && (ci && ci->HasMLock(cm->Name, false)) || (DefConModesSet && DefConModesCI.HasMLock(cm->Name, false)))
{
*end++ = it->first;
c->RemoveMode(cm->Name);
if (!(cbm->flags & CBM_MINUS_NO_ARG)) {
char *value = cbmi->getvalue(c);
/* Add the eventual parameter */
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
if (value) {
*end2++ = ' ';
while (*value)
*end2++ = *value++;
}
if (!cmp->MinusNoArg)
{
c->GetParam(cmp->Name, &param);
if (!param.empty())
{
value = const_cast<char *>(param.c_str());
*end2++ = ' ';
while (*value)
*end++ = *value++;
}
cbm->setvalue(c, NULL);
}
}
} while ((++cbmi)->flag != 0);
}
}
if (*(end - 1) == '-')
end--;
if (end == modebuf)
return;
@@ -903,12 +934,13 @@ void check_modes(Channel * c)
int check_valid_admin(User * user, Channel * chan, int servermode)
{
ChannelMode *cm;
if (!chan || !chan->ci)
return 1;
if (!ircd->admin) {
if (!(cm = ModeManager::FindChannelModeByName(CMODE_PROTECT)))
return 0;
}
/* They will be kicked; no need to deop, no need to update our internal struct too */
if (chan->ci->flags & CI_FORBIDDEN)
@@ -916,14 +948,14 @@ int check_valid_admin(User * user, Channel * chan, int servermode)
if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) {
notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ);
ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s",
ircd->adminunset, user->nick);
ircdproto->SendMode(whosends(chan->ci), chan->name, "-%s %s",
cm->ModeChar, user->nick);
return 0;
}
if (check_access(user, chan->ci, CA_AUTODEOP)) {
ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s",
ircd->adminunset, user->nick);
ircdproto->SendMode(whosends(chan->ci), chan->name, "-%s %s",
cm->ModeChar, user->nick);
return 0;
}
@@ -938,7 +970,7 @@ int check_valid_admin(User * user, Channel * chan, int servermode)
int check_valid_op(User * user, Channel * chan, int servermode)
{
char *tmp;
ChannelMode *owner, *protect, *halfop;
if (!chan || !chan->ci)
return 1;
@@ -946,34 +978,37 @@ int check_valid_op(User * user, Channel * chan, int servermode)
if (chan->ci->flags & CI_FORBIDDEN)
return 0;
owner = ModeManager::FindChannelModeByName(CMODE_OWNER);
protect = ModeManager::FindChannelModeByName(CMODE_PROTECT);
halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP);
if (servermode && !check_access(user, chan->ci, CA_AUTOOP)) {
notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ);
if (ircd->halfop) {
if (ircd->owner && ircd->protect) {
if (halfop)
{
if (owner && protect)
{
if (check_access(user, chan->ci, CA_AUTOHALFOP)) {
tmp = stripModePrefix(ircd->ownerunset);
ircdproto->SendMode(whosends(chan->ci), chan->name,
"%so%s %s %s %s", ircd->adminunset,
tmp, user->nick,
"-%so%s %s %s %s", protect->ModeChar,
owner->ModeChar, user->nick,
user->nick, user->nick);
delete [] tmp;
} else {
tmp = stripModePrefix(ircd->ownerunset);
ircdproto->SendMode(whosends(chan->ci), chan->name,
"%sho%s %s %s %s %s",
ircd->adminunset, tmp,
"-%sho%s %s %s %s %s",
protect->ModeChar,
owner->ModeChar,
user->nick, user->nick, user->nick,
user->nick);
delete [] tmp;
}
} else if (!ircd->owner && ircd->protect) {
} else if (!owner && protect) {
if (check_access(user, chan->ci, CA_AUTOHALFOP)) {
ircdproto->SendMode(whosends(chan->ci), chan->name,
"%so %s %s", ircd->adminunset,
"-%so %s %s", protect->ModeChar,
user->nick, user->nick);
} else {
ircdproto->SendMode(whosends(chan->ci), chan->name,
"%soh %s %s %s", ircd->adminunset,
"-%soh %s %s %s", protect->ModeChar,
user->nick, user->nick, user->nick);
}
} else {
@@ -993,14 +1028,12 @@ int check_valid_op(User * user, Channel * chan, int servermode)
}
if (check_access(user, chan->ci, CA_AUTODEOP)) {
if (ircd->halfop) {
if (ircd->owner && ircd->protect) {
tmp = stripModePrefix(ircd->ownerunset);
if (halfop) {
if (owner && protect) {
ircdproto->SendMode(whosends(chan->ci), chan->name,
"%sho%s %s %s %s %s", ircd->adminunset,
tmp, user->nick, user->nick,
"-%sho%s %s %s %s %s", protect->ModeChar,
owner->ModeChar, user->nick, user->nick,
user->nick, user->nick);
delete [] tmp;
} else {
ircdproto->SendMode(whosends(chan->ci), chan->name, "-ho %s %s",
user->nick, user->nick);
@@ -1083,18 +1116,16 @@ int check_should_halfop(User * user, char *chan)
int check_should_owner(User * user, char *chan)
{
char *tmp;
ChannelInfo *ci = cs_findchan(chan);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER);
if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
return 0;
if (((ci->flags & CI_SECUREFOUNDER) && is_real_founder(user, ci))
|| (!(ci->flags & CI_SECUREFOUNDER) && is_founder(user, ci))) {
tmp = stripModePrefix(ircd->ownerset);
ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick,
ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", cm->ModeChar, user->nick,
user->nick);
delete [] tmp;
return 1;
}
@@ -1105,17 +1136,15 @@ int check_should_owner(User * user, char *chan)
int check_should_protect(User * user, char *chan)
{
char *tmp;
ChannelInfo *ci = cs_findchan(chan);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT);
if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
return 0;
if (check_access(user, ci, CA_AUTOPROTECT)) {
tmp = stripModePrefix(ircd->adminset);
ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick,
ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", cm->ModeChar, user->nick,
user->nick);
delete [] tmp;
return 1;
}
@@ -1181,7 +1210,7 @@ int check_kick(User * user, const char *chan, time_t chants)
*
* UltimateIRCd 3.x at least informs channel staff when a joining user is matching an exempt.
*/
if (ircd->except && is_excepted(ci, user) == 1) {
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, user) == 1) {
return 0;
}
@@ -1460,10 +1489,13 @@ void cs_remove_nick(const NickCore * nc)
}
} else {
alog("%s: Deleting channel %s owned by deleted nick %s", s_ChanServ, ci->name, nc->display);
if (ircd->regmode) {
if ((ModeManager::FindChannelModeByName(CMODE_REGISTERED)))
{
/* Maybe move this to delchan() ? */
if ((ci->c) && (ci->c->mode & ircd->regmode)) {
ci->c->mode &= ~ircd->regmode;
if (ci->c && ci->c->HasMode(CMODE_REGISTERED))
{
ci->c->RemoveMode(CMODE_REGISTERED);
ircdproto->SendMode(whosends(ci), ci->name, "-r");
}
}
@@ -1752,16 +1784,6 @@ int delchan(ChannelInfo * ci)
if (ci->entry_message)
delete [] ci->entry_message;
if (ci->mlock_key)
delete [] ci->mlock_key;
if (ircd->fmode) {
if (ci->mlock_flood)
delete [] ci->mlock_flood;
}
if (ircd->Lmode) {
if (ci->mlock_redirect)
delete [] ci->mlock_redirect;
}
if (ci->last_topic)
delete [] ci->last_topic;
if (ci->forbidby)
@@ -1999,137 +2021,9 @@ int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen)
}
}
/*************************************************************************/
char *cs_get_flood(ChannelInfo * ci)
{
if (!ci) {
return NULL;
} else {
if (ircd->fmode)
return ci->mlock_flood;
else
return NULL;
}
}
/*************************************************************************/
char *cs_get_key(ChannelInfo * ci)
{
if (!ci) {
return NULL;
} else {
return ci->mlock_key;
}
}
/*************************************************************************/
char *cs_get_limit(ChannelInfo * ci)
{
static char limit[16];
if (!ci) {
return NULL;
}
if (ci->mlock_limit == 0)
return NULL;
snprintf(limit, sizeof(limit), "%lu",
static_cast<unsigned long>(ci->mlock_limit));
return limit;
}
/*************************************************************************/
char *cs_get_redirect(ChannelInfo * ci)
{
if (!ci) {
return NULL;
} else {
if (ircd->Lmode)
return ci->mlock_redirect;
else
return NULL;
}
}
/*************************************************************************/
void cs_set_flood(ChannelInfo * ci, const char *value)
{
if (!ci) {
return;
}
if (ci->mlock_flood)
delete [] ci->mlock_flood;
/* This looks ugly, but it works ;) */
if (ircdproto->IsFloodModeParamValid(value)) {
ci->mlock_flood = sstrdup(value);
} else {
ci->mlock_on &= ~ircd->chan_fmode;
ci->mlock_flood = NULL;
}
}
/*************************************************************************/
void cs_set_key(ChannelInfo * ci, const char *value)
{
if (!ci) {
return;
}
if (ci->mlock_key)
delete [] ci->mlock_key;
/* Don't allow keys with a coma */
if (value && *value != ':' && !strchr(value, ',')) {
ci->mlock_key = sstrdup(value);
} else {
ci->mlock_on &= ~anope_get_key_mode();
ci->mlock_key = NULL;
}
}
/*************************************************************************/
void cs_set_limit(ChannelInfo * ci, const char *value)
{
if (!ci) {
return;
}
ci->mlock_limit = value ? strtoul(value, NULL, 10) : 0;
if (ci->mlock_limit <= 0)
ci->mlock_on &= ~anope_get_limit_mode();
}
/*************************************************************************/
void cs_set_redirect(ChannelInfo * ci, const char *value)
{
if (!ci) {
return;
}
if (ci->mlock_redirect)
delete [] ci->mlock_redirect;
/* Don't allow keys with a coma */
if (value && *value == '#') {
ci->mlock_redirect = sstrdup(value);
} else {
ci->mlock_on &= ~ircd->chan_lmode;
ci->mlock_redirect = NULL;
}
}
int get_access_level(ChannelInfo * ci, NickAlias * na)
{
ChanAccess *access;
@@ -2150,13 +2044,15 @@ int get_access_level(ChannelInfo * ci, NickAlias * na)
const char *get_xop_level(int level)
{
ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP);
if (level < ACCESS_VOP) {
return "Err";
} else if (ircd->halfop && level < ACCESS_HOP) {
} else if (halfop && level < ACCESS_HOP) {
return "VOP";
} else if (!ircd->halfop && level < ACCESS_AOP) {
} else if (!halfop && level < ACCESS_AOP) {
return "VOP";
} else if (ircd->halfop && level < ACCESS_AOP) {
} else if (halfop && level < ACCESS_AOP) {
return "HOP";
} else if (level < ACCESS_SOP) {
return "AOP";
+1 -1
View File
@@ -112,7 +112,7 @@ class CommandCSAccess : public Command
/* We still allow LIST in xOP mode, but not others */
else if ((ci->flags & CI_XOP) && !is_list)
{
if (ircd->halfop)
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP_HOP, s_ChanServ);
else
notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP, s_ChanServ);
+2 -1
View File
@@ -229,7 +229,8 @@ class CommandCSAKick : public Command
}
/* Check excepts BEFORE we get this far */
if (ircd->except) {
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
{
if (is_excepted_mask(ci, mask) == 1) {
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan);
if (freemask)
+2 -2
View File
@@ -62,9 +62,9 @@ class CommandCSBan : public Command
* Dont ban/kick the user on channels where he is excepted
* to prevent services <-> server wars.
*/
} else if (ircd->except && is_excepted(ci, u2)) {
} else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) {
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
} else if (ircd->protectedumode && is_protected(u2)) {
} else if (is_protected(u2)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else {
const char *av[3];
+25 -82
View File
@@ -29,6 +29,11 @@ class CommandCSClear : public Command
ci::string what = params[1];
Channel *c = findchan(chan);
ChannelInfo *ci;
ChannelMode *owner, *admin;
std::string modebuf;
owner = ModeManager::FindChannelModeByName(CMODE_OWNER);
admin = ModeManager::FindChannelModeByName(CMODE_PROTECT);
if (c)
ci = c->ci;
@@ -38,90 +43,22 @@ class CommandCSClear : public Command
} else if (!u || !check_access(u, ci, CA_CLEAR)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (what == "bans") {
const char *av[2];
Entry *ban, *bnext;
if (c->bans && c->bans->count) {
for (ban = c->bans->entries; ban; ban = bnext) {
bnext = ban->next;
av[0] = "-b";
av[1] = ban->mask;
ircdproto->SendMode(whosends(ci), chan, "-b %s", ban->mask);
chan_set_modes(whosends(ci)->nick, c, 2, av, 0);
}
}
c->ClearBans();
notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan);
} else if (ircd->except && what == "excepts") {
const char *av[2];
Entry *except, *bnext;
} else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") {
c->ClearExcepts();
if (c->excepts && c->excepts->count) {
for (except = c->excepts->entries; except; except = bnext) {
bnext = except->next;
av[0] = "-e";
av[1] = except->mask;
ircdproto->SendMode(whosends(ci), chan, "-e %s", except->mask);
chan_set_modes(whosends(ci)->nick, c, 2, av, 0);
}
}
notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan);
} else if (ircd->invitemode && what == "invites") {
const char *av[2];
Entry *invite, *bnext;
} else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") {
c->ClearInvites();
if (c->invites && c->invites->count) {
for (invite = c->invites->entries; invite; invite = bnext) {
bnext = invite->next;
av[0] = "-I";
av[1] = invite->mask;
ircdproto->SendMode(whosends(ci), chan, "-I %s", invite->mask);
chan_set_modes(whosends(ci)->nick, c, 2, av, 0);
}
}
notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan);
} else if (what == "modes") {
const char *argv[2];
if (c->mode) {
/* Clear modes the bulk of the modes */
ircdproto->SendMode(whosends(ci), c->name, "%s",
ircd->modestoremove);
argv[0] = ircd->modestoremove;
chan_set_modes(whosends(ci)->nick, c, 1, argv, 0);
/* to prevent the internals from complaining send -k, -L, -f by themselves if we need
to send them - TSL */
if (c->key) {
ircdproto->SendMode(whosends(ci), c->name, "-k %s", c->key);
argv[0] = "-k";
argv[1] = c->key;
chan_set_modes(whosends(ci)->nick, c, 2, argv, 0);
}
if (ircd->Lmode && c->redirect) {
ircdproto->SendMode(whosends(ci), c->name, "-L %s",
c->redirect);
argv[0] = "-L";
argv[1] = c->redirect;
chan_set_modes(whosends(ci)->nick, c, 2, argv, 0);
}
if (ircd->fmode && c->flood) {
if (flood_mode_char_remove) {
ircdproto->SendMode(whosends(ci), c->name, "%s %s",
flood_mode_char_remove, c->flood);
argv[0] = flood_mode_char_remove;
argv[1] = c->flood;
chan_set_modes(whosends(ci)->nick, c, 2, argv, 0);
} else {
if (debug) {
alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
}
}
}
check_modes(c);
}
c->ClearModes();
check_modes(c);
notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan);
} else if (what == "ops") {
@@ -133,11 +70,17 @@ class CommandCSClear : public Command
if (ircd->svsmode_ucmode) {
av[0] = chan;
ircdproto->SendSVSModeChan(av[0], "-o", NULL);
if (ircd->owner) {
ircdproto->SendSVSModeChan(av[0], ircd->ownerunset, NULL);
if (owner) {
modebuf = '-';
modebuf += owner->ModeChar;
ircdproto->SendSVSModeChan(av[0], modebuf.c_str(), NULL);
}
if (ircd->protect || ircd->admin) {
ircdproto->SendSVSModeChan(av[0], ircd->adminunset, NULL);
if (admin) {
modebuf = '-';
modebuf += admin->ModeChar;
ircdproto->SendSVSModeChan(av[0], modebuf.c_str(), NULL);
}
for (cu = c->users; cu; cu = bnext) {
bnext = cu->next;
@@ -150,7 +93,7 @@ class CommandCSClear : public Command
continue;
snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ?
ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : ""));
&admin->ModeChar : ""), (isown ? &owner->ModeChar : ""));
if (ircdcap->tsmode) {
snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL)));
@@ -183,7 +126,7 @@ class CommandCSClear : public Command
continue;
snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ?
ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : ""));
&admin->ModeChar : ""), (isown ? &owner->ModeChar : ""));
/* We need to send the IRCd a nick for every mode.. - Viper */
snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""),
(isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : ""));
@@ -212,7 +155,7 @@ class CommandCSClear : public Command
}
}
notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan);
} else if (ircd->halfop && what == "hops") {
} else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") {
const char *av[4];
int ac;
char buf[BUFSIZE];
+2 -2
View File
@@ -59,9 +59,9 @@ class CommandCSDrop : public Command
if (ci->c)
{
if (ircd->regmode)
if (ModeManager::FindChannelModeByName(CMODE_REGISTERED))
{
ci->c->mode &= ~ircd->regmode;
ci->c->RemoveMode(CMODE_REGISTERED);
ircdproto->SendMode(whosends(ci), ci->name, "-r");
}
}
+2 -19
View File
@@ -29,7 +29,6 @@ class CommandCSForbid : public Command
const char *reason = params.size() > 1 ? params[1].c_str() : NULL;
Channel *c;
Entry *cur, *enext;
if (ForceForbidReason && !reason)
{
@@ -78,24 +77,8 @@ class CommandCSForbid : public Command
/* Before banning everyone, it might be prudent to clear +e and +I lists..
* to prevent ppl from rejoining.. ~ Viper */
if (ircd->except && c->excepts && c->excepts->count) {
for (cur = c->excepts->entries; cur; cur = enext) {
enext = cur->next;
av[0] = "-e";
av[1] = cur->mask;
ircdproto->SendMode(whosends(ci), chan, "-e %s", cur->mask);
chan_set_modes(whosends(ci)->nick, c, 2, av, 0);
}
}
if (ircd->invitemode && c->invites && c->invites->count) {
for (cur = c->invites->entries; cur; cur = enext) {
enext = cur->next;
av[0] = "-I";
av[1] = cur->mask;
ircdproto->SendMode(whosends(ci), chan, "-I %s", cur->mask);
chan_set_modes(whosends(ci)->nick, c, 2, av, 0);
}
}
c->ClearExcepts();
c->ClearInvites();
for (cu = c->users; cu; cu = nextu)
{
+3 -2
View File
@@ -26,6 +26,7 @@ class CommandCSGetKey : public Command
{
const char *chan = params[0].c_str();
ChannelInfo *ci;
std::string key;
ci = cs_findchan(chan);
@@ -35,13 +36,13 @@ class CommandCSGetKey : public Command
return MOD_CONT;
}
if (!ci->c || !ci->c->key)
if (!ci->c || !ci->c->GetParam(CMODE_KEY, &key))
{
notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan);
return MOD_CONT;
}
notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key);
notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, key.c_str());
return MOD_CONT;
}
+5 -2
View File
@@ -47,6 +47,7 @@ class CommandCSInfo : public Command
bool has_auspex = u->nc && u->nc->HasPriv("chanserv/auspex");
int show_all = 0;
time_t expt;
ChannelMode *cm;
ci = cs_findchan(chan);
@@ -80,10 +81,12 @@ class CommandCSInfo : public Command
tm = localtime(&ci->last_used);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(s_ChanServ, u, CHAN_INFO_LAST_USED, buf);
cm = ModeManager::FindChannelModeByName(CMODE_SECRET);
// XXX: yuck.
if (ci->last_topic &&
(show_all || (!(ci->mlock_on & anope_get_secret_mode())
&& (!ci->c || !(ci->c->mode & anope_get_secret_mode())))))
(show_all || (!ci->HasMLock(cm->Name, true))
&& (!ci->c || !(ci->c->HasMode(CMODE_SECRET)))))
{
notice_lang(s_ChanServ, u, CHAN_INFO_LAST_TOPIC, ci->last_topic);
notice_lang(s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY, ci->last_topic_setter);
+86 -52
View File
@@ -15,14 +15,24 @@
#include "module.h"
/* do_util: not a command, but does the job of other */
static CommandReturn do_util(User *u, CSModeUtil *util, const char *chan, const char *nick)
/** do_util: not a command, but does the job of others
* @param u The user doing the command
* @param cm A channel mode class
* @param chan The channel its being set on
* @param nick The nick the modes being set on
* @param set Is the mode being set or removed
* @param level The acecss level required to set this mode on someone else
* @param levelself The access level required to set this mode on yourself
* @param name The name, eg "OP" or "HALFOP"
* @param notice Flag required on a channel to send a notice
*/
static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const char *nick, bool set, int level, int levelself, const std::string &name, int32 notice)
{
const char *av[2];
Channel *c = findchan(chan);
ChannelInfo *ci;
User *u2;
char modebuf[3];
int is_same;
@@ -35,32 +45,34 @@ static CommandReturn do_util(User *u, CSModeUtil *util, const char *chan, const
if (c)
ci = c->ci;
if (!c) {
if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
} else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
else if (is_same ? !(u2 = u) : !(u2 = finduser(nick)))
notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
} else if (!is_on_chan(c, u2)) {
else if (!is_on_chan(c, u2))
notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
} else if (is_same ? !check_access(u, ci, util->levelself) :
!check_access(u, ci, util->level)) {
else if (is_same ? !check_access(u, ci, levelself) : !check_access(u, ci, level))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
&& (get_access(u2, ci) >= get_access(u, ci))) {
else if (!set && !is_same && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci)))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (*util->mode == '-' && is_protected(u2) && !is_same) {
else if (!set && is_protected(u2) && !is_same)
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else {
ircdproto->SendMode(whosends(ci), c->name, "%s %s", util->mode,
u2->nick);
else
{
snprintf(modebuf, sizeof(modebuf), "%c%c", (set ? '+' : '-'), cm->ModeChar);
av[0] = util->mode;
ircdproto->SendMode(whosends(ci), c->name, "%s %s", modebuf, u2->nick);
av[0] = modebuf;
av[1] = u2->nick;
chan_set_modes(s_ChanServ, c, 2, av, 3);
if (util->notice && ci->flags & util->notice)
if (notice && ci->flags & notice)
ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s",
util->name, u2->nick, u->nick);
name.c_str(), u2->nick, u->nick);
}
return MOD_CONT;
}
@@ -75,7 +87,9 @@ class CommandCSOp : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_OP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP);
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OPDEOP, CA_OPDEOPME, "OP", CI_OPNOTICE);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -100,7 +114,9 @@ class CommandCSDeOp : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_DEOP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP);
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OPDEOP, CA_OPDEOPME, "DEOP", CI_OPNOTICE);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -125,7 +141,9 @@ class CommandCSVoice : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_VOICE], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE);
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -150,7 +168,9 @@ class CommandCSDeVoice : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_DEVOICE], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE);
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -175,12 +195,14 @@ class CommandCSHalfOp : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
if (!ircd->halfop)
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_HALFOP);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, &csmodeutils[MUT_HALFOP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -205,12 +227,15 @@ class CommandCSDeHalfOp : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
if (!ircd->halfop)
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_HALFOP);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, &csmodeutils[MUT_DEHALFOP], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -235,12 +260,14 @@ class CommandCSProtect : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
if (!ircd->protect && !ircd->admin)
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, &csmodeutils[MUT_PROTECT], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -255,8 +282,6 @@ class CommandCSProtect : public Command
}
};
/*************************************************************************/
class CommandCSDeProtect : public Command
{
public:
@@ -266,12 +291,14 @@ class CommandCSDeProtect : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
if (!ircd->protect && !ircd->admin)
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, &csmodeutils[MUT_DEPROTECT], (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL));
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -286,8 +313,6 @@ class CommandCSDeProtect : public Command
}
};
/*************************************************************************/
class CommandCSOwner : public Command
{
public:
@@ -297,7 +322,14 @@ class CommandCSOwner : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_OWNER], (params.size() > 0 ? params[0].c_str() : NULL), NULL);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), NULL, true, ACCESS_FOUNDER, ACCESS_FOUNDER, "OWNER", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -312,8 +344,6 @@ class CommandCSOwner : public Command
}
};
/*************************************************************************/
class CommandCSDeOwner : public Command
{
public:
@@ -323,7 +353,14 @@ class CommandCSDeOwner : public Command
CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
return do_util(u, &csmodeutils[MUT_DEOWNER], (params.size() > 0 ? params[0].c_str() : NULL), NULL);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER);
if (!cm)
{
return MOD_CONT;
}
return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), NULL, false, ACCESS_FOUNDER, ACCESS_FOUNDER, "OWNER", 0);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -353,25 +390,19 @@ class CSModes : public Module
this->AddCommand(CHANSERV, new CommandCSVoice());
this->AddCommand(CHANSERV, new CommandCSDeVoice());
if (ircd->halfop)
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
{
this->AddCommand(CHANSERV, new CommandCSHalfOp());
this->AddCommand(CHANSERV, new CommandCSDeHalfOp());
}
if (ircd->protect)
if (ModeManager::FindChannelModeByName(CMODE_PROTECT))
{
this->AddCommand(CHANSERV, new CommandCSProtect());
this->AddCommand(CHANSERV, new CommandCSDeProtect());
}
if (ircd->admin)
{
this->AddCommand(CHANSERV, new CommandCSProtect());
this->AddCommand(CHANSERV, new CommandCSDeProtect());
}
if (ircd->owner)
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
{
this->AddCommand(CHANSERV, new CommandCSOwner());
this->AddCommand(CHANSERV, new CommandCSDeOwner());
@@ -379,24 +410,27 @@ class CSModes : public Module
}
void ChanServHelp(User *u)
{
if (ircd->owner) {
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
{
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OWNER);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOWNER);
}
if (ircd->protect) {
if (ModeManager::FindChannelModeByName(CMODE_PROTECT))
{
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_PROTECT);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEPROTECT);
} else if (ircd->admin) {
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ADMIN);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEADMIN);
}
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OP);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOP);
if (ircd->halfop) {
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
{
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HALFOP);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEHALFOP);
}
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOICE);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEVOICE);
}
+6 -5
View File
@@ -33,6 +33,7 @@ class CommandCSRegister : public Command
struct u_chaninfolist *uc;
char founderpass[PASSMAX];
char tmp_pass[PASSMAX];
ChannelMode *cm;
if (readonly)
{
@@ -83,7 +84,7 @@ class CommandCSRegister : public Command
ci->c = c;
ci->bantype = CSDefBantype;
ci->flags = CSDefFlags;
ci->mlock_on = ircd->defmlock;
ci->mlock_on = ircd->DefMLock;
ci->memos.memomax = MSMaxMemos;
ci->last_used = ci->time_registered;
ci->founder = u->nc;
@@ -116,10 +117,10 @@ class CommandCSRegister : public Command
/* Implement new mode lock */
check_modes(c);
/* On most ircds you do not receive the admin/owner mode till its registered */
if (ircd->admin)
ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->adminset, u->nick);
if (ircd->owner && ircd->ownerset)
ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->ownerset, u->nick);
if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER)))
ircdproto->SendMode(findbot(s_ChanServ), chan, "+%c %s", cm->ModeChar, u->nick);
else if ((cm = ModeManager::FindChannelModeByName(CMODE_PROTECT)))
ircdproto->SendMode(findbot(s_ChanServ), chan, "+%c %s", cm->ModeChar, u->nick);
FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci));
}
+56 -44
View File
@@ -190,27 +190,20 @@ class CommandCSSet : public Command
{
int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
unsigned char mode;
CBMode *cbm;
ChannelMode *cm;
ChannelModeParam *cmp;
if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) {
notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
return MOD_CONT;
}
/* Reinitialize everything */
if (ircd->chanreg) {
ci->mlock_on = ircd->regmode;
} else {
ci->mlock_on = 0;
}
ci->mlock_off = ci->mlock_limit = 0;
ci->mlock_key = NULL;
if (ircd->fmode) {
ci->mlock_flood = NULL;
}
if (ircd->Lmode) {
ci->mlock_redirect = NULL;
}
ci->ClearMLock();
if (ModeManager::FindChannelModeByName(CMODE_REGISTERED))
ci->SetMLock(CMODE_REGISTERED, true);
ci->ClearParams();
std::string params(modes ? modes : ""), param;
unsigned space = params.find(' ');
@@ -235,48 +228,67 @@ class CommandCSSet : public Command
continue;
}
if (static_cast<int>(mode) < 128 && (cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) {
if ((cbm->flags & CBM_NO_MLOCK)
|| ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) {
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR,
mode);
} else if (add) {
ci->mlock_on |= cbm->flag;
ci->mlock_off &= ~cbm->flag;
if (cbm->cssetvalue)
if ((cm = ModeManager::FindChannelModeByChar(mode)))
{
if (!cm->CanSet(u))
{
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, mode);
}
else if (add)
{
if (cm->Type == MODE_PARAM)
{
modeparams.GetToken(param);
cbm->cssetvalue(ci, param.c_str());
cmp = static_cast<ChannelModeParam *>(cm);
if (!modeparams.GetToken(param))
continue;
if (!cmp->IsValid(param.c_str()))
continue;
ci->SetParam(cmp->Name, param);
}
} else {
ci->mlock_off |= cbm->flag;
if (ci->mlock_on & cbm->flag) {
ci->mlock_on &= ~cbm->flag;
if (cbm->cssetvalue)
cbm->cssetvalue(ci, NULL);
ci->SetMLock(cm->Name, true);
ci->RemoveMLock(cm->Name, false);
}
else
{
ci->SetMLock(cm->Name, false);
if (ci->HasMLock(cm->Name, true))
{
ci->RemoveMLock(cm->Name, true);
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
ci->UnsetParam(cmp->Name);
}
}
}
} else {
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode);
}
else
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode);
} /* while (*modes) */
if (ircd->Lmode) {
if (ModeManager::FindChannelModeByName(CMODE_REDIRECT)) {
/* We can't mlock +L if +l is not mlocked as well. */
if ((ci->mlock_on & ircd->chan_lmode)
&& !(ci->mlock_on & anope_get_limit_mode())) {
ci->mlock_on &= ~ircd->chan_lmode;
delete [] ci->mlock_redirect;
if (ci->HasMLock(CMODE_REDIRECT, true) && !ci->HasMLock(CMODE_LIMIT, true))
{
ci->RemoveMLock(CMODE_REDIRECT, true);
ci->UnsetParam(CMODE_REDIRECT);
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED);
}
}
/* Some ircd we can't set NOKNOCK without INVITE */
/* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
if (ircd->noknock && ircd->knock_needs_i) {
if ((ci->mlock_on & ircd->noknock)
&& !(ci->mlock_on & anope_get_invite_mode())) {
ci->mlock_on &= ~ircd->noknock;
if (ModeManager::FindChannelModeByName(CMODE_NOKNOCK) && ircd->knock_needs_i) {
if (ci->HasMLock(CMODE_NOKNOCK, true) && !ci->HasMLock(CMODE_INVITE, true))
{
ci->RemoveMLock(CMODE_NOKNOCK, true);
notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED);
}
}
@@ -474,7 +486,7 @@ class CommandCSSet : public Command
} else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP)
|| CHECKLEV(CA_OPDEOPME)) {
access->level = ACCESS_AOP;
} else if (ircd->halfop) {
} else if (ModeManager::FindChannelModeByName(CMODE_HALFOP)) {
if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP)
|| CHECKLEV(CA_HALFOPME)) {
access->level = ACCESS_HOP;
+2 -2
View File
@@ -498,7 +498,7 @@ class CSXOP : public Module
this->SetType(CORE);
this->AddCommand(CHANSERV, new CommandCSAOP());
if (ircd->halfop)
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
this->AddCommand(CHANSERV, new CommandCSHOP());
this->AddCommand(CHANSERV, new CommandCSSOP());
this->AddCommand(CHANSERV, new CommandCSVOP());
@@ -507,7 +507,7 @@ class CSXOP : public Module
{
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SOP);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AOP);
if (ircd->halfop)
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HOP);
notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOP);
}
+22 -7
View File
@@ -26,12 +26,14 @@ class CommandOSChanList : public Command
{
const char *pattern = params.size() > 0 ? params[0].c_str() : NULL;
ci::string opt = params.size() > 1 ? params[1] : "";
int modes = 0;
std::list<ChannelModeName> Modes;
User *u2;
if (!opt.empty() && opt == "SECRET")
modes |= (anope_get_secret_mode() | anope_get_private_mode());
{
Modes.push_back(CMODE_SECRET);
Modes.push_back(CMODE_PRIVATE);
}
if (pattern && (u2 = finduser(pattern)))
{
@@ -41,8 +43,15 @@ class CommandOSChanList : public Command
for (uc = u2->chans; uc; uc = uc->next)
{
if (modes && !(uc->chan->mode & modes))
continue;
if (!Modes.empty())
{
for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
if (!uc->chan->HasMode(*it))
continue;
}
}
notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, uc->chan->name, uc->chan->usercount, chan_get_modes(uc->chan, 1, 1), uc->chan->topic ? uc->chan->topic : "");
}
}
@@ -59,8 +68,14 @@ class CommandOSChanList : public Command
{
if (pattern && !Anope::Match(c->name, pattern, false))
continue;
if (modes && !(c->mode & modes))
continue;
if (!Modes.empty())
{
for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
if (!c->HasMode(*it))
continue;
}
}
notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name, c->usercount, chan_get_modes(c, 1, 1), c->topic ? c->topic : "");
}
}
+21 -86
View File
@@ -29,7 +29,8 @@ class CommandOSClearModes : public Command
Channel *c;
int all = 0;
struct c_userlist *cu, *next;
Entry *entry, *nexte;
ChannelMode *cm;
std::string buf;
if (!(c = findchan(chan)))
{
@@ -88,7 +89,7 @@ class CommandOSClearModes : public Command
}
/* Clear mode +h */
if (ircd->halfop)
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
{
if (ircd->svsmode_ucmode)
ircdproto->SendSVSModeChan(c->name, "-h", NULL);
@@ -106,120 +107,54 @@ class CommandOSClearModes : public Command
}
/* Clear mode Owners */
if (ircd->owner)
if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER)))
{
buf = '-';
buf += cm->ModeChar;
if (ircd->svsmode_ucmode)
ircdproto->SendSVSModeChan(c->name, ircd->ownerunset, NULL);
ircdproto->SendSVSModeChan(c->name, buf.c_str(), NULL);
for (cu = c->users; cu; cu = next)
{
next = cu->next;
if (!chan_has_user_status(c, cu->user, CUS_OWNER))
continue;
argv[0] = ircd->ownerunset;
argv[0] = buf.c_str();
argv[1] = cu->user->nick;
if (!ircd->svsmode_ucmode)
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", ircd->ownerunset, cu->user->nick);
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", buf.c_str(), cu->user->nick);
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
}
/* Clear mode protected or admins */
if (ircd->protect || ircd->admin)
if ((cm = ModeManager::FindChannelModeByName(CMODE_PROTECT)))
{
buf = '-';
buf += cm->ModeChar;
if (ircd->svsmode_ucmode)
ircdproto->SendSVSModeChan(c->name, ircd->adminunset, NULL);
ircdproto->SendSVSModeChan(c->name, buf.c_str(), NULL);
for (cu = c->users; cu; cu = next)
{
next = cu->next;
if (!chan_has_user_status(c, cu->user, CUS_PROTECT))
continue;
argv[0] = ircd->adminunset;
argv[0] = buf.c_str();
argv[1] = cu->user->nick;
if (!ircd->svsmode_ucmode)
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", ircd->adminunset, cu->user->nick);
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", buf.c_str(), cu->user->nick);
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
}
}
if (c->mode)
{
/* Clear modes the bulk of the modes */
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s", ircd->modestoremove);
argv[0] = ircd->modestoremove;
chan_set_modes(s_OperServ, c, 1, argv, 0);
/* to prevent the internals from complaining send -k, -L, -f by themselves if we need
to send them - TSL */
if (c->key)
{
ircdproto->SendMode(findbot(s_OperServ), c->name, "-k %s", c->key);
argv[0] = "-k";
argv[1] = c->key;
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
if (ircd->Lmode && c->redirect)
{
ircdproto->SendMode(findbot(s_OperServ), c->name, "-L %s", c->redirect);
argv[0] = "-L";
argv[1] = c->redirect;
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
if (ircd->fmode && c->flood)
{
if (flood_mode_char_remove)
{
ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", flood_mode_char_remove, c->flood);
argv[0] = flood_mode_char_remove;
argv[1] = c->flood;
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
else
{
if (debug)
alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
}
}
}
c->ClearModes(s_OperServ);
/* Clear bans */
if (c->bans && c->bans->count)
{
for (entry = c->bans->entries; entry; entry = nexte)
{
nexte = entry->next;
argv[0] = "-b";
argv[1] = entry->mask;
ircdproto->SendMode(findbot(s_OperServ), c->name, "-b %s", entry->mask);
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
}
/* Clear excepts */
if (ircd->except && c->excepts && c->excepts->count)
{
for (entry = c->excepts->entries; entry; entry = nexte)
{
nexte = entry->next;
argv[0] = "-e";
argv[1] = entry->mask;
ircdproto->SendMode(findbot(s_OperServ), c->name, "-e %s", entry->mask);
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
}
/* Clear invites */
if (ircd->invitemode && c->invites && c->invites->count)
{
for (entry = c->invites->entries; entry; entry = nexte)
{
nexte = entry->next;
argv[0] = "-I";
argv[1] = entry->mask;
ircdproto->SendMode(findbot(s_OperServ), c->name, "-I %s", entry->mask);
chan_set_modes(s_OperServ, c, 2, argv, 0);
}
}
c->ClearBans(s_OperServ);
c->ClearExcepts(s_OperServ);
c->ClearInvites(s_OperServ);
}
if (all)
+20 -7
View File
@@ -26,12 +26,13 @@ class CommandOSUserList : public Command
{
const char *pattern = params.size() > 0 ? params[0].c_str() : NULL;
ci::string opt = params.size() > 1 ? params[1] : "";
Channel *c;
int modes = 0;
std::list<UserModeName> Modes;
if (!opt.empty() && opt == "INVISIBLE")
modes |= anope_get_invis_mode();
{
Modes.push_back(UMODE_INVIS);
}
if (pattern && (c = findchan(pattern)))
{
@@ -41,8 +42,14 @@ class CommandOSUserList : public Command
for (cu = c->users; cu; cu = cu->next)
{
if (modes && !(cu->user->mode & modes))
continue;
if (!Modes.empty())
{
for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
if (!cu->user->HasMode(*it))
continue;
}
}
notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, cu->user->nick, cu->user->GetIdent().c_str(), cu->user->GetDisplayedHost().c_str());
}
}
@@ -63,8 +70,14 @@ class CommandOSUserList : public Command
snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick, u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
if (!Anope::Match(mask, pattern, false))
continue;
if (modes && !(u2->mode & modes))
continue;
if (!Modes.empty())
{
for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
if (!u2->HasMode(*it))
continue;
}
}
}
notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick, u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
}
-127
View File
@@ -16,7 +16,6 @@
#include "extern.h"
IRCDProto *ircdproto;
IRCDModes ircd_modes;
/**
* Globals we want from the protocol file
@@ -24,13 +23,6 @@ IRCDModes ircd_modes;
IRCDVar *ircd;
IRCDCAPAB *ircdcap;
char *version_protocol;
CBModeInfo *cbmodeinfos;
CUMode cumodes[128];
char *flood_mode_char_set;
char *flood_mode_char_remove;
CBMode cbmodes[128];
CMMode cmmodes[128];
char csmodes[128];
int UseTSMODE;
void pmodule_ircd_proto(IRCDProto *proto)
@@ -68,126 +60,7 @@ void pmodule_ircd_version(const char *version)
version_protocol = sstrdup(version);
}
void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos)
{
cbmodeinfos = modeinfos;
}
void pmodule_ircd_cumodes(CUMode modes[128])
{
int i = 0;
for (i = 0; i < 128; i++) {
cumodes[i] = modes[i];
}
}
void pmodule_ircd_flood_mode_char_set(const char *mode)
{
flood_mode_char_set = sstrdup(mode);
}
void pmodule_ircd_flood_mode_char_remove(const char *mode)
{
flood_mode_char_remove = sstrdup(mode);
}
void pmodule_ircd_cbmodes(CBMode modes[128])
{
int i = 0;
for (i = 0; i < 128; i++) {
cbmodes[i] = modes[i];
}
}
void pmodule_ircd_cmmodes(CMMode modes[128])
{
int i = 0;
for (i = 0; i < 128; i++) {
cmmodes[i] = modes[i];
}
}
void pmodule_ircd_csmodes(char mode[128])
{
int i = 0;
for (i = 0; i < 128; i++) {
csmodes[i] = mode[i];
}
}
void pmodule_ircd_useTSMode(int use)
{
UseTSMODE = use;
}
/** mode stuff */
void pmodule_invis_umode(int mode)
{
ircd_modes.user_invis = mode;
}
void pmodule_oper_umode(int mode)
{
ircd_modes.user_oper = mode;
}
void pmodule_invite_cmode(int mode)
{
ircd_modes.chan_invite = mode;
}
void pmodule_secret_cmode(int mode)
{
ircd_modes.chan_secret = mode;
}
void pmodule_private_cmode(int mode)
{
ircd_modes.chan_private = mode;
}
void pmodule_key_mode(int mode)
{
ircd_modes.chan_key = mode;
}
void pmodule_limit_mode(int mode)
{
ircd_modes.chan_limit = mode;
}
int anope_get_invis_mode()
{
return ircd_modes.user_invis;
}
int anope_get_oper_mode()
{
return ircd_modes.user_oper;
}
int anope_get_invite_mode()
{
return ircd_modes.chan_invite;
}
int anope_get_secret_mode()
{
return ircd_modes.chan_secret;
}
int anope_get_private_mode()
{
return ircd_modes.chan_private;
}
int anope_get_key_mode()
{
return ircd_modes.chan_key;
}
int anope_get_limit_mode()
{
return ircd_modes.chan_limit;
}
+364
View File
@@ -0,0 +1,364 @@
/* Mode support
*
* (C) 2009 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* $Id$
*
*/
#include "services.h"
std::map<char, UserMode *> ModeManager::UserModesByChar;
std::map<UserModeName, UserMode *> ModeManager::UserModesByName;
/* Channel modes */
std::map<char, ChannelMode *> ModeManager::ChannelModesByChar;
std::map<ChannelModeName, ChannelMode *> ModeManager::ChannelModesByName;
/* Although there are two different maps for UserModes and ChannelModes
* the pointers in each are the same. This is used to increase
* efficiency.
*/
/** Add a user mode to Anope
* @param Mode The mode
* @param um A UserMode or UserMode derived class
* @return true on success, false on error
*/
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;
return ret;
}
/** Add a channel mode to Anope
* @param Mode The mode
* @param cm A ChannelMode or ChannelMode derived class
* @return true on success, false on error
*/
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;
return ret;
}
/** Find a channel mode
* @param Mode The mode
* @return The mode class
*/
ChannelMode *ModeManager::FindChannelModeByChar(char Mode)
{
std::map<char, ChannelMode *>::iterator it = ModeManager::ChannelModesByChar.find(Mode);
if (it != ModeManager::ChannelModesByChar.end())
{
return it->second;
}
return NULL;
}
/** Find a user mode
* @param Mode The mode
* @return The mode class
*/
UserMode *ModeManager::FindUserModeByChar(char Mode)
{
std::map<char, UserMode *>::iterator it = ModeManager::UserModesByChar.find(Mode);
if (it != ModeManager::UserModesByChar.end())
{
return it->second;
}
return NULL;
}
/** Find a channel mode
* @param Mode The modename
* @return The mode class
*/
ChannelMode *ModeManager::FindChannelModeByName(ChannelModeName Name)
{
std::map<ChannelModeName, ChannelMode *>::iterator it = ModeManager::ChannelModesByName.find(Name);
if (it != ModeManager::ChannelModesByName.end())
{
return it->second;
}
return NULL;
}
/** Find a user mode
* @param Mode The modename
* @return The mode class
*/
UserMode *ModeManager::FindUserModeByName(UserModeName Name)
{
std::map<UserModeName, UserMode *>::iterator it = ModeManager::UserModesByName.find(Name);
if (it != ModeManager::UserModesByName.end())
{
return it->second;
}
return NULL;
}
/** Gets the channel mode char for a symbol (eg + returns v)
* @param Value The symbol
* @return The char
*/
char ModeManager::GetStatusChar(char Value)
{
std::map<char, ChannelMode *>::iterator it;
ChannelMode *cm;
ChannelModeStatus *cms;
for (it = ModeManager::ChannelModesByChar.begin(); it != ModeManager::ChannelModesByChar.end(); ++it)
{
cm = it->second;
if (cm->Type == MODE_STATUS)
{
cms = static_cast<ChannelModeStatus *>(cm);
if (Value == cms->Symbol)
{
return it->first;
}
}
}
return 0;
}
/** Is the key valid
* @param value The key
* @return true or false
*/
bool ChannelModeKey::IsValid(const char *value)
{
if (value && *value != ':' && !strchr(value, ','))
return true;
return false;
}
/** Can admin only mode be set by the user
* @param u The user - can be NULL if defcon is checking
* @return true or false
*/
bool ChannelModeAdmin::CanSet(User *u)
{
if (u && is_oper(u))
return true;
return false;
}
/** Can oper only mode be set by the user
* @param u The user - can be NULL if defcon is checking
* @return true or false
*/
bool ChannelModeOper::CanSet(User *u)
{
if (u && is_oper(u))
return true;
return false;
}
/** Can the user set the registerd mode?
* No.
* @return false
*/
bool ChannelModeRegistered::CanSet(User *u)
{
return false;
}
/** Add a ban to the channel
* @param chan The channel
* @param mask The ban
*/
void ChannelModeBan::AddMask(Channel *chan, const char *mask)
{
Entry *ban;
/* check for NULL values otherwise we will segfault */
if (!chan || !mask)
{
if (debug)
alog("debug: add_ban called with NULL values");
return;
}
/* Check if the list already exists, if not create it.
* Create a new ban and add it to the list.. ~ Viper */
if (!chan->bans)
chan->bans = list_create();
ban = entry_add(chan->bans, mask);
if (!ban)
fatal("Creating new ban entry failed");
/* Check whether it matches a botserv bot after adding internally
* and parsing it through cidr support. ~ Viper */
if (s_BotServ && BSSmartJoin && chan->ci && chan->ci->bi
&& chan->usercount >= BSMinUsers)
{
BotInfo *bi = chan->ci->bi;
if (entry_match(ban, bi->nick, bi->user, bi->host, 0))
{
ircdproto->SendMode(bi, chan->name, "-b %s", mask);
entry_delete(chan->bans, ban);
return;
}
}
if (debug)
alog("debug: Added ban %s to channel %s", mask, chan->name);
}
/** Remove a ban from the channel
* @param chan The channel
* @param mask The ban
*/
void ChannelModeBan::DelMask(Channel *chan, const char *mask)
{
AutoKick *akick;
Entry *ban;
/* Sanity check as it seems some IRCD will just send -b without a mask */
if (!mask || !chan->bans || (chan->bans->count == 0))
return;
ban = elist_find_mask(chan->bans, mask);
if (ban)
{
entry_delete(chan->bans, ban);
if (debug)
alog("debug: Deleted ban %s from channel %s", mask,
chan->name);
}
if (chan->ci && (akick = is_stuck(chan->ci, mask)))
stick_mask(chan->ci, akick);
}
/** Add an except to the channel
* @param chan The channel
* @param mask The except
*/
void ChannelModeExcept::AddMask(Channel *chan, const char *mask)
{
Entry *exception;
if (!chan || !mask)
{
if (debug)
alog("debug: add_exception called with NULL values");
return;
}
/* Check if the list already exists, if not create it.
* Create a new exception and add it to the list.. ~ Viper */
if (!chan->excepts)
chan->excepts = list_create();
exception = entry_add(chan->excepts, mask);
if (!exception)
fatal("Creating new exception entry failed");
if (debug)
alog("debug: Added except %s to channel %s", mask, chan->name);
}
/** Remove an except from the channel
* @param chan The channel
* @param mask The except
*/
void ChannelModeExcept::DelMask(Channel *chan, const char *mask)
{
Entry *exception;
/* Sanity check as it seems some IRCD will just send -e without a mask */
if (!mask || !chan->excepts || (chan->excepts->count == 0))
return;
exception = elist_find_mask(chan->excepts, mask);
if (exception)
{
entry_delete(chan->excepts, exception);
if (debug)
alog("debug: Deleted except %s to channel %s", mask, chan->name);
}
}
/** Add an invex to the channel
* @param chan The channel
* @param mask The invex
*/
void ChannelModeInvite::AddMask(Channel *chan, const char *mask)
{
Entry *invite;
if (!chan || !mask)
{
if (debug)
alog("debug: add_invite called with NULL values");
return;
}
/* Check if the list already exists, if not create it.
* Create a new invite and add it to the list.. ~ Viper */
if (!chan->invites)
chan->invites = list_create();
invite = entry_add(chan->invites, mask);
if (!invite)
fatal("Creating new exception entry failed");
if (debug)
alog("debug: Added invite %s to channel %s", mask, chan->name);
}
/** Remove an invex from the channel
* @param chan The channel
* @param mask The index
*/
void ChannelModeInvite::DelMask(Channel *chan, const char *mask)
{
Entry *invite;
/* Sanity check as it seems some IRCD will just send -I without a mask */
if (!mask || !chan->invites || (chan->invites->count == 0))
return;
invite = elist_find_mask(chan->invites, mask);
if (invite)
{
entry_delete(chan->invites, invite);
if (debug)
alog("debug: Deleted invite %s to channel %s", mask,
chan->name);
}
}
-58
View File
@@ -732,64 +732,6 @@ bool moduleMinVersion(int major, int minor, int patch, int build)
return ret;
}
/**
* Allow ircd protocol files to update the protect level info tables.
**/
void updateProtectDetails(const char *level_info_protect_word,
const char *level_info_protectme_word,
const char *fant_protect_add, const char *fant_protect_del,
const char *level_protect_word, const char *protect_set_mode,
const char *protect_unset_mode)
{
int i = 0;
CSModeUtil ptr;
LevelInfo l_ptr;
ptr = csmodeutils[i];
while (ptr.name) {
if (strcmp(ptr.name, "PROTECT") == 0) {
csmodeutils[i].bsname = sstrdup(fant_protect_add);
csmodeutils[i].mode = sstrdup(protect_set_mode);
} else if (strcmp(ptr.name, "DEPROTECT") == 0) {
csmodeutils[i].bsname = sstrdup(fant_protect_del);
csmodeutils[i].mode = sstrdup(protect_unset_mode);
}
ptr = csmodeutils[++i];
}
i = 0;
l_ptr = levelinfo[i];
while (l_ptr.what != -1) {
if (l_ptr.what == CA_PROTECT) {
levelinfo[i].name = sstrdup(level_info_protect_word);
} else if (l_ptr.what == CA_PROTECTME) {
levelinfo[i].name = sstrdup(level_info_protectme_word);
} else if (l_ptr.what == CA_AUTOPROTECT) {
levelinfo[i].name = sstrdup(level_protect_word);
}
l_ptr = levelinfo[++i];
}
}
void updateOwnerDetails(const char *fant_owner_add, const char *fant_owner_del, const char *owner_set_mode, const char *owner_del_mode)
{
CSModeUtil ptr;
int i = 0;
ptr = csmodeutils[i];
while (ptr.name) {
if (!strcmp(ptr.name, "OWNER")) {
csmodeutils[i].bsname = sstrdup(fant_owner_add);
csmodeutils[i].mode = sstrdup(owner_set_mode);
}
else if (!strcmp(ptr.name, "DEOWNER")) {
csmodeutils[i].bsname = sstrdup(fant_owner_del);
csmodeutils[i].mode = sstrdup(owner_del_mode);
}
ptr = csmodeutils[++i];
}
}
void Module::NoticeLang(char *source, User * u, int number, ...)
{
va_list va;
+3 -6
View File
@@ -47,9 +47,7 @@ class CommandCSEnforce : public Command
void DoModes(Channel *c)
{
CBMode *cbm;
if ((cbm = &cbmodes[static_cast<int>('R')])->flag && (c->mode & cbm->flag))
if (c->HasMode(CMODE_REGISTEREDONLY))
this->DoCModeR(c);
}
@@ -140,7 +138,6 @@ class CommandCSEnforce : public Command
const char *reason;
const char *av[3];
User *u;
CBMode *cbm;
if (!(ci = c->ci))
return;
@@ -159,7 +156,7 @@ class CommandCSEnforce : public Command
get_idealban(ci, u, mask, sizeof(mask));
av[1] = mask;
reason = getstring(u, CHAN_NOT_ALLOWED_TO_JOIN);
if (!(cbm = &cbmodes[static_cast<int>('R')])->flag || !(c->mode & cbm->flag))
if (!c->HasMode(CMODE_REGISTERED))
{
ircdproto->SendMode(whosends(ci), ci->name, "+b %s %lu", mask, time(NULL));
chan_set_modes(s_ChanServ, c, 2, av, 1);
@@ -234,7 +231,7 @@ class CommandCSEnforce : public Command
ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " ");
me->NoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE);
ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " ");
if (cbmodes[static_cast<int>('R')].flag)
if (ModeManager::FindChannelModeByName(CMODE_REGISTERED))
me->NoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_ENABLED);
else
me->NoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_DISABLED);
+2 -2
View File
@@ -214,9 +214,9 @@ int canBanUser(Channel * c, User * u, User * u2)
int ok = 0;
if (!check_access(u, ci, CA_BAN))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else if (ircd->except && is_excepted(ci, u2))
else if (is_excepted(ci, u2))
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
else if (ircd->protectedumode && is_protected(u2))
else if (is_protected(u2))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else
ok = 1;
+2 -2
View File
@@ -1408,7 +1408,7 @@ int should_mode_change(int16 status, int16 mode)
return 1;
break;
case CUS_OWNER:
if (ircd->owner)
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
{
if (status & CUS_OWNER)
{
@@ -1417,7 +1417,7 @@ int should_mode_change(int16 status, int16 mode)
}
break;
case CUS_PROTECT:
if (ircd->protect)
if (ModeManager::FindChannelModeByName(CMODE_PROTECT))
{
if (status & CUS_PROTECT)
{
+52 -31
View File
@@ -1275,17 +1275,14 @@ int defconParseModeString(const char *str)
{
int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
unsigned char mode;
CBMode *cbm;
ChannelMode *cm;
ChannelModeParam *cmp;
char *str_copy = sstrdup(str); /* We need this copy as str is const -GD */
char *param; /* Store parameters during mode parsing */
/* Reinitialize everything */
DefConModesOn = 0;
DefConModesOff = 0;
DefConModesCI.mlock_limit = 0;
DefConModesCI.mlock_key = NULL;
DefConModesCI.mlock_flood = NULL;
DefConModesCI.mlock_redirect = NULL;
/* Initialize strtok() internal buffer */
strtok(str_copy, " ");
@@ -1304,32 +1301,55 @@ int defconParseModeString(const char *str)
continue;
}
if (static_cast<int>(mode) < 128 && (cbm = &cbmodes[static_cast<int>(mode)])->flag != 0) {
if (cbm->flags & CBM_NO_MLOCK) {
alog("DefConChanModes mode character '%c' cannot be locked", mode);
if ((cm = ModeManager::FindChannelModeByChar(mode)))
{
if (!cm->CanSet(NULL))
{
alog("DefConCHanModes mode character '%c' cannot be locked", mode);
delete [] str_copy;
return 0;
} else if (add) {
DefConModesOn |= cbm->flag;
DefConModesOff &= ~cbm->flag;
if (cbm->cssetvalue) {
if (!(param = strtok(NULL, " "))) {
}
else if (add)
{
DefConModesCI.SetMLock(cm->Name, true);
DefConModesCI.RemoveMLock(cm->Name, false);
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
if (!(param = strtok(NULL, " ")))
{
alog("DefConChanModes mode character '%c' has no parameter while one is expected", mode);
delete [] str_copy;
return 0;
}
cbm->cssetvalue(&DefConModesCI, param);
if (!cmp->IsValid(param))
continue;
DefConModesCI.SetParam(cmp->Name, param);
}
} else {
DefConModesOff |= cbm->flag;
if (DefConModesOn & cbm->flag) {
DefConModesOn &= ~cbm->flag;
if (cbm->cssetvalue) {
cbm->cssetvalue(&DefConModesCI, NULL);
}
else
{
DefConModesCI.RemoveMLock(cm->Name, true);
if (DefConModesCI.HasMLock(cm->Name, true))
{
DefConModesCI.RemoveMLock(cm->Name, true);
if (cm->Type == MODE_PARAM)
{
cmp = static_cast<ChannelModeParam *>(cm);
DefConModesCI.UnsetParam(cmp->Name);
}
}
}
} else {
}
else
{
alog("DefConChanModes unknown mode character '%c'", mode);
delete [] str_copy;
return 0;
@@ -1338,13 +1358,13 @@ int defconParseModeString(const char *str)
delete [] str_copy;
if (ircd->Lmode) {
if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)))
{
/* We can't mlock +L if +l is not mlocked as well. */
if ((DefConModesOn & ircd->chan_lmode)
&& !(DefConModesOn & anope_get_limit_mode())) {
DefConModesOn &= ~ircd->chan_lmode;
delete [] DefConModesCI.mlock_redirect;
DefConModesCI.mlock_redirect = NULL;
if (DefConModesCI.HasMLock(cm->Name, true) && !DefConModesCI.HasMLock(CMODE_LIMIT, true))
{
DefConModesCI.RemoveMLock(CMODE_REDIRECT, true);
DefConModesCI.UnsetParam(CMODE_REDIRECT);
alog("DefConChanModes must lock mode +l as well to lock mode +L");
return 0;
}
@@ -1352,10 +1372,11 @@ int defconParseModeString(const char *str)
/* Some ircd we can't set NOKNOCK without INVITE */
/* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
if (ircd->noknock && ircd->knock_needs_i) {
if ((DefConModesOn & ircd->noknock)
&& !(DefConModesOn & anope_get_invite_mode())) {
DefConModesOn &= ~ircd->noknock;
if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)))
{
if (DefConModesCI.HasMLock(cm->Name, true) && !DefConModesCI.HasMLock(CMODE_INVITE, true))
{
DefConModesCI.RemoveMLock(CMODE_NOKNOCK, true);
alog("DefConChanModes must lock mode +i as well to lock mode +K");
return 0;
}
+56 -355
View File
@@ -16,85 +16,26 @@
#include "services.h"
#include "pseudo.h"
#define UMODE_a 0x00000001 /* umode +a - Services Admin */
#define UMODE_h 0x00000002 /* umode +h - Helper */
#define UMODE_i 0x00000004 /* umode +i - Invisible */
#define UMODE_o 0x00000008 /* umode +o - Oper */
#define UMODE_r 0x00000010 /* umode +r - registered nick */
#define UMODE_w 0x00000020 /* umode +w - Get wallops */
#define UMODE_A 0x00000040 /* umode +A - Server Admin */
#define UMODE_x 0x00000080 /* umode +x - Squelch with notice */
#define UMODE_X 0x00000100 /* umode +X - Squelch without notice */
#define UMODE_F 0x00000200 /* umode +F - no cptr->since message rate throttle */
#define UMODE_j 0x00000400 /* umode +j - client rejection notices */
#define UMODE_K 0x00000800 /* umode +K - U: lined server kill messages */
#define UMODE_O 0x00001000 /* umode +O - Local Oper */
#define UMODE_s 0x00002000 /* umode +s - Server notices */
#define UMODE_c 0x00004000 /* umode +c - Client connections/exits */
#define UMODE_k 0x00008000 /* umode +k - Server kill messages */
#define UMODE_f 0x00010000 /* umode +f - Server flood messages */
#define UMODE_y 0x00020000 /* umode +y - Stats/links */
#define UMODE_d 0x00040000 /* umode +d - Debug info */
#define UMODE_g 0x00080000 /* umode +g - Globops */
#define UMODE_b 0x00100000 /* umode +b - Chatops */
#define UMODE_n 0x00200000 /* umode +n - Routing Notices */
#define UMODE_m 0x00400000 /* umode +m - spambot notices */
#define UMODE_e 0x00800000 /* umode +e - oper notices for the above +D */
#define UMODE_D 0x01000000 /* umode +D - Hidden dccallow umode */
#define UMODE_I 0x02000000 /* umode +I - invisible oper (masked) */
#define UMODE_R 0x80000000 /* unmode +R - No non registered msgs */
#define CMODE_i 0x00000001
#define CMODE_m 0x00000002
#define CMODE_n 0x00000004
#define CMODE_p 0x00000008
#define CMODE_s 0x00000010
#define CMODE_t 0x00000020
#define CMODE_k 0x00000040 /* These two used only by ChanServ */
#define CMODE_l 0x00000080
#define CMODE_R 0x00000100 /* Only identified users can join */
#define CMODE_r 0x00000200 /* Set for all registered channels */
#define CMODE_c 0x00000400 /* Colors can't be used */
#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */
#define CMODE_j 0x00001000 /* join throttle */
#define CMODE_O 0x00008000 /* Only opers can join */
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
IRCDVar myIrcd[] = {
{"Bahamut 1.8.x", /* ircd name */
"+", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"-cilmnpstOR", /* Modes to Remove */
"+o", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
0, /* Vhost */
0, /* Has Owner */
NULL, /* Mode to set for an owner */
NULL, /* Mode to unset for an owner */
NULL, /* Mode to set for channel admin */
NULL, /* Mode to unset for channel admin */
"-r+d", /* Mode on UnReg */
1, /* Supports SGlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
0, /* Supports Halfop +h */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* Has exceptions +e */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Protected Umode */
0, /* Has Admin */
1, /* Chan SQlines */
1, /* Quit on Kill */
1, /* SVSMODE unban */
0, /* Has Protect */
0, /* Reverse */
1, /* Chan Reg */
CMODE_r, /* Channel Mode */
0, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
@@ -103,28 +44,18 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
0, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
0, /* Vhost Mode */
1, /* +f */
0, /* +L */
CMODE_j, /* Mode */
0, /* Mode */
0,
1,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
1, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
0, /* SJOIN invite char */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
NULL, /* vhost char */
0, /* ts6 */
1, /* support helper umode */
0, /* p10 */
NULL, /* character set */
0, /* CIDR channelbans */
@@ -168,258 +99,6 @@ IRCDCAPAB myIrcdcap[] = {
};
unsigned long umodes[128] = {
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Horzontal Tab */
0, 0, 0, /* Line Feed, Unused, Unused */
0, 0, 0, /* Carriage Return, Unused, Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Space */
0, 0, 0, /* ! " # */
0, 0, 0, /* $ % & */
0, 0, 0, /* ! ( ) */
0, 0, 0, /* * + , */
0, 0, 0, /* - . / */
0, 0, /* 0 1 */
0, 0, /* 2 3 */
0, 0, /* 4 5 */
0, 0, /* 6 7 */
0, 0, /* 8 9 */
0, 0, /* : ; */
0, 0, 0, /* < = > */
0, 0, /* ? @ */
UMODE_A, 0, 0, /* A B C */
UMODE_D, 0, UMODE_F, /* D E F */
0, 0, UMODE_I, /* G H I */
0, UMODE_K, 0, /* J K L */
0, 0, UMODE_O, /* M N O */
0, 0, UMODE_R, /* P Q R */
0, 0, 0, /* S T U */
0, 0, UMODE_X, /* V W X */
0, /* Y */
0, /* Z */
0, 0, 0, /* [ \ ] */
0, 0, 0, /* ^ _ ` */
UMODE_a, UMODE_b, UMODE_c, /* a b c */
UMODE_d, UMODE_e, UMODE_f, /* d e f */
UMODE_g, UMODE_h, UMODE_i, /* g h i */
UMODE_j, UMODE_k, 0, /* j k l */
UMODE_m, UMODE_n, UMODE_o, /* m n o */
0, 0, UMODE_r, /* p q r */
UMODE_s, 0, 0, /* s t u */
0, UMODE_w, UMODE_x, /* v w x */
UMODE_y, /* y */
0, /* z */
0, 0, 0, /* { | } */
0, 0 /* ~ */
};
char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0, 0, 0,
0,
0, 0, 0, 0,
0,
'v', 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, /* BCD */
{NULL}, {NULL}, {NULL}, /* EFG */
{NULL}, /* H */
{add_invite, del_invite}, /* I */
{NULL}, /* J */
{NULL}, {NULL}, {NULL}, /* KLM */
{NULL}, {NULL}, {NULL}, /* NOP */
{NULL}, {NULL}, {NULL}, /* QRS */
{NULL}, {NULL}, {NULL}, /* TUV */
{NULL}, {NULL}, {NULL}, /* WXY */
{NULL}, /* Z */
{NULL}, {NULL}, /* (char 91 - 92) */
{NULL}, {NULL}, {NULL}, /* (char 93 - 95) */
{NULL}, /* ` (char 96) */
{NULL}, /* a (char 97) */
{add_ban, del_ban}, /* b */
{NULL}, {NULL}, /* cd */
{add_exception, del_exception},
{NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{0}, /* A */
{0}, /* B */
{0}, /* C */
{0}, /* D */
{0}, /* E */
{0}, /* F */
{0}, /* G */
{0}, /* H */
{0}, /* I */
{0}, /* J */
{0}, /* K */
{0}, /* L */
{CMODE_M, 0, NULL, NULL}, /* M */
{0}, /* N */
{CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* P */
{0}, /* Q */
{CMODE_R, 0, NULL, NULL}, /* R */
{0}, /* S */
{0}, /* T */
{0}, /* U */
{0}, /* V */
{0}, /* W */
{0}, /* X */
{0}, /* Y */
{0}, /* Z */
{0}, {0}, {0}, {0}, {0}, {0},
{0}, /* a */
{0}, /* b */
{CMODE_c, 0, NULL, NULL},
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0}, /* h */
{CMODE_i, 0, NULL, NULL},
{CMODE_j, 0, set_flood, cs_set_flood}, /* j */
{CMODE_k, 0, chan_set_key, cs_set_key},
{CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
{CMODE_m, 0, NULL, NULL},
{CMODE_n, 0, NULL, NULL},
{0}, /* o */
{CMODE_p, 0, NULL, NULL},
{0}, /* q */
{CMODE_r, CBM_NO_MLOCK, NULL, NULL},
{CMODE_s, 0, NULL, NULL},
{CMODE_t, 0, NULL, NULL},
{0},
{0}, /* v */
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}
};
CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'j', CMODE_j, 0, get_flood, cs_get_flood},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
{'m', CMODE_m, 0, NULL, NULL},
{'n', CMODE_n, 0, NULL, NULL},
{'p', CMODE_p, 0, NULL, NULL},
{'r', CMODE_r, 0, NULL, NULL},
{'s', CMODE_s, 0, NULL, NULL},
{'t', CMODE_t, 0, NULL, NULL},
{'M', CMODE_M, 0, NULL, NULL},
{'O', CMODE_O, 0, NULL, NULL},
{'R', CMODE_R, 0, NULL, NULL},
{0}
};
CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{0}, /* a */
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0}, /* h */
{0}, /* i */
{0}, /* j */
{0}, /* k */
{0}, /* l */
{0}, /* m */
{0}, /* n */
{CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* p */
{0}, /* q */
{0}, /* r */
{0}, /* s */
{0}, /* t */
{0}, /* u */
{CUS_VOICE, 0, NULL},
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}, {0}
};
void bahamut_cmd_burst()
{
send_cmd(NULL, "BURST");
@@ -471,10 +150,11 @@ class BahamutIRCdProto : public IRCDProto
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
if (add)
user->SetMode(*modes);
else
user->RemoveMode(*modes);
switch (*modes++) {
case '+':
add = 1;
@@ -501,7 +181,7 @@ class BahamutIRCdProto : public IRCDProto
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
user->RemoveMode(CMODE_REGISTERED);
}
}
}
@@ -685,13 +365,6 @@ class BahamutIRCdProto : public IRCDProto
common_svsmode(u, "+d", "1");
}
int IsFloodModeParamValid(const char *value)
{
char *dp, *end;
if (value && *value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
else return 0;
}
/* SERVER */
void SendServer(Server *server)
{
@@ -999,15 +672,19 @@ int anope_event_burst(const char *source, int ac, const char **av)
return MOD_CONT;
}
bool ChannelModeFlood::IsValid(const char *value)
{
char *dp, *end;
if (value && *value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
return true;
return false;
}
/* *INDENT-OFF* */
void moduleAddIRCDMsgs() {
Message *m;
/* first update the cs protect info about this ircd */
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
/* now add the commands */
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
@@ -1037,7 +714,41 @@ void moduleAddIRCDMsgs() {
m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m);
}
/* *INDENT-ON* */
void moduleAddModes()
{
/* Add user modes */
ModeManager::AddUserMode('A', new UserMode(UMODE_SERV_ADMIN));
ModeManager::AddUserMode('R', new UserMode(UMODE_REGPRIV));
ModeManager::AddUserMode('a', new UserMode(UMODE_ADMIN));
ModeManager::AddUserMode('i', new UserMode(UMODE_INVIS));
ModeManager::AddUserMode('o', new UserMode(UMODE_OPER));
ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED));
ModeManager::AddUserMode('s', new UserMode(UMODE_SNOMASK));
ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS));
/* b/e/I */
ModeManager::AddChannelMode('b', new ChannelModeBan());
/* v/h/o/a/q */
ModeManager::AddChannelMode('v', new ChannelModeStatus(CMODE_VOICE, CUS_VOICE, '+'));
ModeManager::AddChannelMode('o', new ChannelModeStatus(CMODE_OP, CUS_OP, '@', true));
/* Add channel modes */
ModeManager::AddChannelMode('c', new ChannelMode(CMODE_BLOCKCOLOR));
ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE));
ModeManager::AddChannelMode('j', new ChannelModeFlood());
ModeManager::AddChannelMode('k', new ChannelModeKey());
ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT));
ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED));
ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL));
ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE));
ModeManager::AddChannelMode('r', new ChannelModeRegistered());
ModeManager::AddChannelMode('s', new ChannelMode(CMODE_SECRET));
ModeManager::AddChannelMode('t', new ChannelMode(CMODE_TOPIC));
ModeManager::AddChannelMode('M', new ChannelMode(CMODE_REGMODERATED));
ModeManager::AddChannelMode('O', new ChannelModeOper());
ModeManager::AddChannelMode('R', new ChannelMode(CMODE_REGISTEREDONLY));
}
class ProtoBahamut : public Module
{
@@ -1051,23 +762,13 @@ class ProtoBahamut : public Module
pmodule_ircd_version("BahamutIRCd 1.4.*/1.8.*");
pmodule_ircd_cap(myIrcdcap);
pmodule_ircd_var(myIrcd);
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cumodes(myCumodes);
pmodule_ircd_flood_mode_char_set("+j");
pmodule_ircd_flood_mode_char_remove("-j");
pmodule_ircd_cbmodes(myCbmodes);
pmodule_ircd_cmmodes(myCmmodes);
pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(0);
/** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i);
pmodule_secret_cmode(CMODE_s);
pmodule_private_cmode(CMODE_p);
pmodule_key_mode(CMODE_k);
pmodule_limit_mode(CMODE_l);
moduleAddModes();
ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
+75 -348
View File
@@ -17,44 +17,6 @@
#include "pseudo.h"
#include "hashcomp.h"
#define UMODE_a 0x00000001
#define UMODE_h 0x00000002
#define UMODE_i 0x00000004
#define UMODE_o 0x00000008
#define UMODE_r 0x00000010
#define UMODE_w 0x00000020
#define UMODE_A 0x00000040
#define UMODE_g 0x80000000
#define UMODE_x 0x40000000
#define CMODE_i 0x00000001
#define CMODE_m 0x00000002
#define CMODE_n 0x00000004
#define CMODE_p 0x00000008
#define CMODE_s 0x00000010
#define CMODE_t 0x00000020
#define CMODE_k 0x00000040 /* These two used only by ChanServ */
#define CMODE_l 0x00000080
#define CMODE_c 0x00000400
#define CMODE_A 0x00000800
#define CMODE_H 0x00001000
#define CMODE_K 0x00002000
#define CMODE_L 0x00004000
#define CMODE_O 0x00008000
#define CMODE_Q 0x00010000
#define CMODE_S 0x00020000
#define CMODE_V 0x00040000
#define CMODE_f 0x00080000
#define CMODE_G 0x00100000
#define CMODE_C 0x00200000
#define CMODE_u 0x00400000
#define CMODE_z 0x00800000
#define CMODE_N 0x01000000
#define CMODE_R 0x00000100 /* Only identified users can join */
#define CMODE_r 0x00000200 /* Set for all registered channels */
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
@@ -75,35 +37,22 @@ IRCDVar myIrcd[] = {
{"InspIRCd 1.1", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Has Owner */
"+q", /* Mode to set for an owner */
"-q", /* Mode to unset for an owner */
"+a", /* Mode to set for channel admin */
"-a", /* Mode to unset for channel admin */
"-r", /* Mode on UnReg */
1, /* Supports SGlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
1, /* Supports Halfop +h */
4, /* Number of server args */
0, /* Join 2 Set */
1, /* Join 2 Message */
0, /* Has exceptions +e */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Protected Umode */
0, /* Has Admin */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Has Protect */
1, /* Reverse */
1, /* Chan Reg */
CMODE_r, /* Channel Mode */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
@@ -112,28 +61,18 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
CMODE_K, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
UMODE_x, /* Vhost Mode */
0, /* +f */
1, /* +L */
CMODE_f,
CMODE_L,
0,
0,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
0, /* SJOIN invite char */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
"x", /* vhost char */
0, /* ts6 */
1, /* support helper umode */
0, /* p10 */
NULL, /* character set */
1, /* CIDR channelbans */
@@ -178,221 +117,6 @@ IRCDCAPAB myIrcdcap[] = {
0, 0}
};
unsigned long umodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0,
0,
0, 0, 0, 0, 0,
0, UMODE_a, 0, 0, 0, 0, 0,
UMODE_g,
UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o,
0,
0, UMODE_r, 0, 0, 0, 0, UMODE_w,
UMODE_x,
0,
0,
0, 0, 0, 0, 0
};
char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0, 0, 0,
'h', /* (37) % Channel halfops */
'a',
0, 0, 0, 0,
'v', 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0
};
CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL},
{NULL},
{add_ban, del_ban},
{NULL},
{NULL},
{NULL, NULL},
{NULL},
{NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* B */
{CMODE_C, 0, NULL, NULL}, /* C */
{0}, /* D */
{0}, /* E */
{0}, /* F */
{CMODE_G, 0, NULL, NULL}, /* G */
{CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* I */
{0}, /* J */
{CMODE_K, 0, NULL, NULL}, /* K */
{CMODE_L, 0, set_redirect, cs_set_redirect},
{0}, /* M */
{CMODE_N, 0, NULL, NULL}, /* N */
{CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* P */
{CMODE_Q, 0, NULL, NULL}, /* Q */
{CMODE_R, 0, NULL, NULL}, /* R */
{CMODE_S, 0, NULL, NULL}, /* S */
{0}, /* T */
{0}, /* U */
{CMODE_V, 0, NULL, NULL}, /* V */
{0}, /* W */
{0}, /* X */
{0}, /* Y */
{0}, /* Z */
{0}, {0}, {0}, {0}, {0}, {0},
{0}, /* a */
{0}, /* b */
{CMODE_c, 0, NULL, NULL},
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0}, /* h */
{CMODE_i, 0, NULL, NULL},
{0}, /* j */
{CMODE_k, 0, chan_set_key, cs_set_key},
{CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
{CMODE_m, 0, NULL, NULL},
{CMODE_n, 0, NULL, NULL},
{0}, /* o */
{CMODE_p, 0, NULL, NULL},
{0}, /* q */
{CMODE_r, CBM_NO_MLOCK, NULL, NULL},
{CMODE_s, 0, NULL, NULL},
{CMODE_t, 0, NULL, NULL},
{CMODE_u, 0, NULL, NULL},
{0}, /* v */
{0}, /* w */
{0}, /* x */
{0}, /* y */
{CMODE_z, 0, NULL, NULL},
{0}, {0}, {0}, {0}
};
CBModeInfo myCbmodeinfos[] = {
{'f', CMODE_f, 0, NULL, NULL},
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
{'m', CMODE_m, 0, NULL, NULL},
{'n', CMODE_n, 0, NULL, NULL},
{'p', CMODE_p, 0, NULL, NULL},
{'r', CMODE_r, 0, NULL, NULL},
{'s', CMODE_s, 0, NULL, NULL},
{'t', CMODE_t, 0, NULL, NULL},
{'u', CMODE_u, 0, NULL, NULL},
{'z', CMODE_z, 0, NULL, NULL},
{'A', CMODE_A, 0, NULL, NULL},
{'C', CMODE_C, 0, NULL, NULL},
{'G', CMODE_G, 0, NULL, NULL},
{'H', CMODE_H, 0, NULL, NULL},
{'K', CMODE_K, 0, NULL, NULL},
{'L', CMODE_L, 0, get_redirect, cs_get_redirect},
{'N', CMODE_N, 0, NULL, NULL},
{'O', CMODE_O, 0, NULL, NULL},
{'Q', CMODE_Q, 0, NULL, NULL},
{'R', CMODE_R, 0, NULL, NULL},
{'S', CMODE_S, 0, NULL, NULL},
{'V', CMODE_V, 0, NULL, NULL},
{0}
};
CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{CUS_HALFOP, 0, check_valid_op},
{0}, /* i */
{0}, /* j */
{0}, /* k */
{0}, /* l */
{0}, /* m */
{0}, /* n */
{CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* p */
{CUS_OWNER, 0, check_valid_op},
{0}, /* r */
{0}, /* s */
{0}, /* t */
{0}, /* u */
{CUS_VOICE, 0, NULL},
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}, {0}
};
static int has_servicesmod = 0;
static int has_globopsmod = 0;
static int has_svsholdmod = 0;
@@ -444,10 +168,11 @@ class InspIRCdProto : public IRCDProto
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
if (add)
user->SetMode(*modes);
else
user->RemoveMode(*modes);
switch (*modes++) {
case '+':
add = 1;
@@ -466,7 +191,7 @@ class InspIRCdProto : public IRCDProto
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
user->RemoveMode(UMODE_REGISTERED);
}
break;
case 'x':
@@ -504,7 +229,10 @@ class InspIRCdProto : public IRCDProto
void SendVhostDel(User *u)
{
inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->GetCloakedHost().c_str() : u->host));
if (u->HasMode(UMODE_CLOAK))
inspircd_cmd_chghost(u->nick, u->chost.c_str());
else
inspircd_cmd_chghost(u->nick, u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
{
@@ -683,13 +411,6 @@ class InspIRCdProto : public IRCDProto
send_cmd(NULL, "ENDBURST");
}
int IsFloodModeParamValid(const char *value)
{
char *dp, *end;
if (value && *value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
else return 0;
}
void SetAutoIdentificationToken(User *u)
{
char svidbuf[15], *c;
@@ -1183,7 +904,6 @@ int anope_event_whois(const char *source, int ac, const char **av)
int anope_event_capab(const char *source, int ac, const char **av)
{
int argc;
CBModeInfo *cbmi;
if (strcasecmp(av[0], "START") == 0) {
/* reset CAPAB */
@@ -1254,52 +974,16 @@ int anope_event_capab(const char *source, int ac, const char **av)
ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
if (has_messagefloodmod) {
cbmi = myCbmodeinfos;
/* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos
* to enable +f support if found. This is needed because we're really not set up to
* handle modular ircds which can have modes enabled/disabled as they please :( - mark
*/
while ((cbmi->mode != 'f')) {
cbmi++;
}
if (cbmi) {
cbmi->getvalue = get_flood;
cbmi->csgetvalue = cs_get_flood;
myCbmodes[static_cast<int>('f')].flag = CMODE_f;
myCbmodes[static_cast<int>('f')].flags = 0;
myCbmodes[static_cast<int>('f')].setvalue = set_flood;
myCbmodes[static_cast<int>('f')].cssetvalue = cs_set_flood;
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cbmodes(myCbmodes);
ircd->fmode = 1;
}
else {
alog("Support for channelmode +f can not be enabled");
if (debug) {
alog("debug: 'f' missing from myCbmodeinfos");
}
}
ModeManager::AddChannelMode('f', new ChannelModeFlood());
}
if (has_banexceptionmod) {
myCmmodes[static_cast<int>('e')].addmask = add_exception;
myCmmodes[static_cast<int>('e')].delmask = del_exception;
ircd->except = 1;
ModeManager::AddChannelMode('e', new ChannelModeExcept());
}
if (has_inviteexceptionmod) {
myCmmodes[static_cast<int>('I')].addmask = add_invite;
myCmmodes[static_cast<int>('I')].delmask = del_invite;
ircd->invitemode = 1;
ModeManager::AddChannelMode('e', new ChannelModeInvite());
}
ircd->svshold = has_svsholdmod;
if (has_banexceptionmod || has_inviteexceptionmod) {
pmodule_ircd_cmmodes(myCmmodes);
}
/* Generate a fake capabs parsing call so things like NOQUIT work
* fine. It's ugly, but it works....
*/
@@ -1321,9 +1005,6 @@ int anope_event_endburst(const char *source, int ac, const char **av)
void moduleAddIRCDMsgs() {
Message *m;
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
updateOwnerDetails("OWNER", "DEOWNER", ircd->ownerset, ircd->ownerunset);
m = createMessage("ENDBURST", anope_event_endburst); addCoreMessage(IRCD, m);
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
@@ -1357,6 +1038,62 @@ void moduleAddIRCDMsgs() {
m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m);
}
bool ChannelModeFlood::IsValid(const char *value)
{
char *dp, *end;
if (value && *value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end)
return true;
return false;
}
void moduleAddModes()
{
/* Add user modes */
ModeManager::AddUserMode('g', new UserMode(UMODE_CALLERID));
ModeManager::AddUserMode('h', new UserMode(UMODE_HELPOP));
ModeManager::AddUserMode('i', new UserMode(UMODE_INVIS));
ModeManager::AddUserMode('o', new UserMode(UMODE_OPER));
ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED));
ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS));
ModeManager::AddUserMode('x', new UserMode(UMODE_CLOAK));
/* b/e/I */
ModeManager::AddChannelMode('b', new ChannelModeBan());
/* v/h/o/a/q */
ModeManager::AddChannelMode('v', new ChannelModeStatus(CMODE_VOICE, CUS_VOICE, '+'));
ModeManager::AddChannelMode('h', new ChannelModeStatus(CMODE_HALFOP, CUS_HALFOP, '%'));
ModeManager::AddChannelMode('o', new ChannelModeStatus(CMODE_OP, CUS_OP, '@', true));
ModeManager::AddChannelMode('a', new ChannelModeStatus(CMODE_PROTECT, CUS_PROTECT, '&', true));
ModeManager::AddChannelMode('q', new ChannelModeStatus(CMODE_OWNER, CUS_OWNER, '~'));
/* Add channel modes */
ModeManager::AddChannelMode('c', new ChannelMode(CMODE_BLOCKCOLOR));
ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE));
ModeManager::AddChannelMode('k', new ChannelModeKey());
ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT));
ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED));
ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL));
ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE));
ModeManager::AddChannelMode('r', new ChannelModeRegistered());
ModeManager::AddChannelMode('s', new ChannelMode(CMODE_SECRET));
ModeManager::AddChannelMode('t', new ChannelMode(CMODE_TOPIC));
ModeManager::AddChannelMode('u', new ChannelMode(CMODE_AUDITORIUM));
ModeManager::AddChannelMode('z', new ChannelMode(CMODE_SSL));
ModeManager::AddChannelMode('A', new ChannelMode(CMODE_ALLINVITE));
ModeManager::AddChannelMode('C', new ChannelMode(CMODE_NOCTCP));
ModeManager::AddChannelMode('G', new ChannelMode(CMODE_FILTER));
ModeManager::AddChannelMode('K', new ChannelMode(CMODE_NOKNOCK));
ModeManager::AddChannelMode('L', new ChannelModeParam(CMODE_REDIRECT));
ModeManager::AddChannelMode('N', new ChannelMode(CMODE_NONICK));
ModeManager::AddChannelMode('O', new ChannelModeOper());
ModeManager::AddChannelMode('Q', new ChannelMode(CMODE_NOKICK));
ModeManager::AddChannelMode('R', new ChannelMode(CMODE_REGISTEREDONLY));
ModeManager::AddChannelMode('S', new ChannelMode(CMODE_STRIPCOLOR));
ModeManager::AddChannelMode('V', new ChannelMode(CMODE_NOINVITE));
}
class ProtoInspIRCd : public Module
{
@@ -1370,23 +1107,13 @@ class ProtoInspIRCd : public Module
pmodule_ircd_version("inspircdIRCd 1.1");
pmodule_ircd_cap(myIrcdcap);
pmodule_ircd_var(myIrcd);
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cumodes(myCumodes);
pmodule_ircd_flood_mode_char_set("+f");
pmodule_ircd_flood_mode_char_remove("-f");
pmodule_ircd_cbmodes(myCbmodes);
pmodule_ircd_cmmodes(myCmmodes);
pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(0);
/** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i);
pmodule_secret_cmode(CMODE_s);
pmodule_private_cmode(CMODE_p);
pmodule_key_mode(CMODE_k);
pmodule_limit_mode(CMODE_l);
moduleAddModes();
ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
+65 -341
View File
@@ -17,44 +17,6 @@
#include "pseudo.h"
#include "hashcomp.h"
#define UMODE_a 0x00000001
#define UMODE_h 0x00000002
#define UMODE_i 0x00000004
#define UMODE_o 0x00000008
#define UMODE_r 0x00000010
#define UMODE_w 0x00000020
#define UMODE_A 0x00000040
#define UMODE_g 0x80000000
#define UMODE_x 0x40000000
#define CMODE_i 0x00000001
#define CMODE_m 0x00000002
#define CMODE_n 0x00000004
#define CMODE_p 0x00000008
#define CMODE_s 0x00000010
#define CMODE_t 0x00000020
#define CMODE_k 0x00000040 /* These two used only by ChanServ */
#define CMODE_l 0x00000080
#define CMODE_c 0x00000400
#define CMODE_A 0x00000800
#define CMODE_H 0x00001000
#define CMODE_K 0x00002000
#define CMODE_L 0x00004000
#define CMODE_O 0x00008000
#define CMODE_Q 0x00010000
#define CMODE_S 0x00020000
#define CMODE_V 0x00040000
#define CMODE_f 0x00080000
#define CMODE_G 0x00100000
#define CMODE_C 0x00200000
#define CMODE_u 0x00400000
#define CMODE_z 0x00800000
#define CMODE_N 0x01000000
#define CMODE_R 0x00000100 /* Only identified users can join */
#define CMODE_r 0x00000200 /* Set for all registered channels */
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
@@ -75,35 +37,22 @@ IRCDVar myIrcd[] = {
{"InspIRCd 1.2", /* ircd name */
"+I", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Has Owner */
"+q", /* Mode to set for an owner */
"-q", /* Mode to unset for an owner */
"+a", /* Mode to set for channel admin */
"-a", /* Mode to unset for channel admin */
"-r", /* Mode on UnReg */
0, /* Supports SGlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
1, /* Supports Halfop +h */
4, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
0, /* Has exceptions +e */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Protected Umode */
0, /* Has Admin */
0, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
1, /* Has Protect */
1, /* Reverse */
1, /* Chan Reg */
CMODE_r, /* Channel Mode */
1, /* vidents */
1, /* svshold */
0, /* time stamp on mode */
@@ -112,28 +61,18 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
CMODE_K, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
UMODE_x, /* Vhost Mode */
0, /* +f */
1, /* +L */
CMODE_f,
CMODE_L,
0,
0,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support inspircd TOKENS */
0, /* TIME STAMPS are BASE64 */
0, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
0, /* SJOIN invite char */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
"x", /* vhost char */
1, /* ts6 */
1, /* support helper umode */
0, /* p10 */
NULL, /* character set */
1, /* CIDR channelbans */
@@ -178,221 +117,6 @@ IRCDCAPAB myIrcdcap[] = {
0, 0}
};
unsigned long umodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0,
0,
0, 0, 0, 0, 0,
0, UMODE_a, 0, 0, 0, 0, 0,
UMODE_g,
UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o,
0,
0, UMODE_r, 0, 0, 0, 0, UMODE_w,
UMODE_x,
0,
0,
0, 0, 0, 0, 0
};
char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0, 0, 0,
'h', /* (37) % Channel halfops */
'a',
0, 0, 0, 0,
'v', 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0
};
CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL},
{NULL},
{add_ban, del_ban},
{NULL},
{NULL},
{NULL, NULL},
{NULL},
{NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* B */
{CMODE_C, 0, NULL, NULL}, /* C */
{0}, /* D */
{0}, /* E */
{0}, /* F */
{CMODE_G, 0, NULL, NULL}, /* G */
{CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* I */
{0}, /* J */
{CMODE_K, 0, NULL, NULL}, /* K */
{CMODE_L, 0, set_redirect, cs_set_redirect},
{0}, /* M */
{CMODE_N, 0, NULL, NULL}, /* N */
{CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* P */
{CMODE_Q, 0, NULL, NULL}, /* Q */
{CMODE_R, 0, NULL, NULL}, /* R */
{CMODE_S, 0, NULL, NULL}, /* S */
{0}, /* T */
{0}, /* U */
{CMODE_V, 0, NULL, NULL}, /* V */
{0}, /* W */
{0}, /* X */
{0}, /* Y */
{0}, /* Z */
{0}, {0}, {0}, {0}, {0}, {0},
{0}, /* a */
{0}, /* b */
{CMODE_c, 0, NULL, NULL},
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0}, /* h */
{CMODE_i, 0, NULL, NULL},
{0}, /* j */
{CMODE_k, 0, chan_set_key, cs_set_key},
{CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
{CMODE_m, 0, NULL, NULL},
{CMODE_n, 0, NULL, NULL},
{0}, /* o */
{CMODE_p, 0, NULL, NULL},
{0}, /* q */
{CMODE_r, CBM_NO_MLOCK, NULL, NULL},
{CMODE_s, 0, NULL, NULL},
{CMODE_t, 0, NULL, NULL},
{CMODE_u, 0, NULL, NULL},
{0}, /* v */
{0}, /* w */
{0}, /* x */
{0}, /* y */
{CMODE_z, 0, NULL, NULL},
{0}, {0}, {0}, {0}
};
CBModeInfo myCbmodeinfos[] = {
{'f', CMODE_f, 0, NULL, NULL},
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
{'m', CMODE_m, 0, NULL, NULL},
{'n', CMODE_n, 0, NULL, NULL},
{'p', CMODE_p, 0, NULL, NULL},
{'r', CMODE_r, 0, NULL, NULL},
{'s', CMODE_s, 0, NULL, NULL},
{'t', CMODE_t, 0, NULL, NULL},
{'u', CMODE_u, 0, NULL, NULL},
{'z', CMODE_z, 0, NULL, NULL},
{'A', CMODE_A, 0, NULL, NULL},
{'C', CMODE_C, 0, NULL, NULL},
{'G', CMODE_G, 0, NULL, NULL},
{'H', CMODE_H, 0, NULL, NULL},
{'K', CMODE_K, 0, NULL, NULL},
{'L', CMODE_L, 0, get_redirect, cs_get_redirect},
{'N', CMODE_N, 0, NULL, NULL},
{'O', CMODE_O, 0, NULL, NULL},
{'Q', CMODE_Q, 0, NULL, NULL},
{'R', CMODE_R, 0, NULL, NULL},
{'S', CMODE_S, 0, NULL, NULL},
{'V', CMODE_V, 0, NULL, NULL},
{0}
};
CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{CUS_HALFOP, 0, check_valid_op},
{0}, /* i */
{0}, /* j */
{0}, /* k */
{0}, /* l */
{0}, /* m */
{0}, /* n */
{CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* p */
{CUS_OWNER, 0, check_valid_op},
{0}, /* r */
{0}, /* s */
{0}, /* t */
{0}, /* u */
{CUS_VOICE, 0, NULL},
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}, {0}
};
static int has_servicesmod = 0;
static int has_globopsmod = 0;
static int has_svsholdmod = 0;
@@ -449,10 +173,11 @@ class InspIRCdProto : public IRCDProto
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
if (add)
user->SetMode(*modes);
else
user->RemoveMode(*modes);
switch (*modes++) {
case '+':
add = 1;
@@ -476,7 +201,7 @@ class InspIRCdProto : public IRCDProto
break;
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
user->RemoveMode(UMODE_REGISTERED);
}
break;
case 'x':
@@ -515,7 +240,10 @@ class InspIRCdProto : public IRCDProto
void SendVhostDel(User *u)
{
inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->GetCloakedHost().c_str() : u->host));
if (u->HasMode(UMODE_CLOAK))
inspircd_cmd_chghost(u->nick, u->chost.c_str());
else
inspircd_cmd_chghost(u->nick, u->host);
if (has_chgidentmod && u->GetIdent() != u->GetVIdent())
{
@@ -1293,7 +1021,6 @@ int anope_event_metadata(const char *source, int ac, const char **av)
int anope_event_capab(const char *source, int ac, const char **av)
{
int argc;
CBModeInfo *cbmi;
if (strcasecmp(av[0], "START") == 0) {
/* reset CAPAB */
@@ -1367,52 +1094,16 @@ int anope_event_capab(const char *source, int ac, const char **av)
ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
if (has_messagefloodmod) {
cbmi = myCbmodeinfos;
/* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos
* to enable +f support if found. This is needed because we're really not set up to
* handle modular ircds which can have modes enabled/disabled as they please :( - mark
*/
while ((cbmi->mode != 'f')) {
cbmi++;
}
if (cbmi) {
cbmi->getvalue = get_flood;
cbmi->csgetvalue = cs_get_flood;
myCbmodes[static_cast<int>('f')].flag = CMODE_f;
myCbmodes[static_cast<int>('f')].flags = 0;
myCbmodes[static_cast<int>('f')].setvalue = set_flood;
myCbmodes[static_cast<int>('f')].cssetvalue = cs_set_flood;
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cbmodes(myCbmodes);
ircd->fmode = 1;
}
else {
alog("Support for channelmode +f can not be enabled");
if (debug) {
alog("debug: 'f' missing from myCbmodeinfos");
}
}
ModeManager::AddChannelMode('f', new ChannelModeFlood());
}
if (has_banexceptionmod) {
myCmmodes[static_cast<int>('e')].addmask = add_exception;
myCmmodes[static_cast<int>('e')].delmask = del_exception;
ircd->except = 1;
ModeManager::AddChannelMode('e', new ChannelModeExcept());
}
if (has_inviteexceptionmod) {
myCmmodes[static_cast<int>('I')].addmask = add_invite;
myCmmodes[static_cast<int>('I')].delmask = del_invite;
ircd->invitemode = 1;
ModeManager::AddChannelMode('I', new ChannelModeInvite());
}
ircd->svshold = has_svsholdmod;
if (has_banexceptionmod || has_inviteexceptionmod) {
pmodule_ircd_cmmodes(myCmmodes);
}
/* Generate a fake capabs parsing call so things like NOQUIT work
* fine. It's ugly, but it works....
*/
@@ -1453,9 +1144,6 @@ int anope_event_endburst(const char *source, int ac, const char **av)
void moduleAddIRCDMsgs() {
Message *m;
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
updateOwnerDetails("OWNER", "DEOWNER", ircd->ownerset, ircd->ownerunset);
m = createMessage("ENDBURST", anope_event_endburst); addCoreMessage(IRCD, m);
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
@@ -1492,6 +1180,52 @@ void moduleAddIRCDMsgs() {
m = createMessage("METADATA", anope_event_metadata); addCoreMessage(IRCD,m);
}
void moduleAddModes()
{
/* Add user modes */
ModeManager::AddUserMode('g', new UserMode(UMODE_CALLERID));
ModeManager::AddUserMode('h', new UserMode(UMODE_HELPOP));
ModeManager::AddUserMode('i', new UserMode(UMODE_INVIS));
ModeManager::AddUserMode('o', new UserMode(UMODE_OPER));
ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED));
ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS));
ModeManager::AddUserMode('x', new UserMode(UMODE_CLOAK));
/* b/e/I */
ModeManager::AddChannelMode('b', new ChannelModeBan());
/* v/h/o/a/q */
ModeManager::AddChannelMode('v', new ChannelModeStatus(CMODE_VOICE, CUS_VOICE, '+'));
ModeManager::AddChannelMode('h', new ChannelModeStatus(CMODE_HALFOP, CUS_HALFOP, '%'));
ModeManager::AddChannelMode('o', new ChannelModeStatus(CMODE_OP, CUS_OP, '@', true));
ModeManager::AddChannelMode('a', new ChannelModeStatus(CMODE_PROTECT, CUS_PROTECT, '&', true));
ModeManager::AddChannelMode('q', new ChannelModeStatus(CMODE_OWNER, CUS_OWNER, '~'));
/* Add channel modes */
ModeManager::AddChannelMode('c', new ChannelMode(CMODE_BLOCKCOLOR));
ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE));
ModeManager::AddChannelMode('k', new ChannelModeKey());
ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT));
ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED));
ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL));
ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE));
ModeManager::AddChannelMode('r', new ChannelModeRegistered());
ModeManager::AddChannelMode('s', new ChannelMode(CMODE_SECRET));
ModeManager::AddChannelMode('t', new ChannelMode(CMODE_TOPIC));
ModeManager::AddChannelMode('u', new ChannelMode(CMODE_AUDITORIUM));
ModeManager::AddChannelMode('z', new ChannelMode(CMODE_SSL));
ModeManager::AddChannelMode('A', new ChannelMode(CMODE_ALLINVITE));
ModeManager::AddChannelMode('C', new ChannelMode(CMODE_NOCTCP));
ModeManager::AddChannelMode('G', new ChannelMode(CMODE_FILTER));
ModeManager::AddChannelMode('K', new ChannelMode(CMODE_NOKNOCK));
ModeManager::AddChannelMode('L', new ChannelModeParam(CMODE_REDIRECT));
ModeManager::AddChannelMode('N', new ChannelMode(CMODE_NONICK));
ModeManager::AddChannelMode('O', new ChannelModeOper());
ModeManager::AddChannelMode('Q', new ChannelMode(CMODE_NOKICK));
ModeManager::AddChannelMode('R', new ChannelMode(CMODE_REGISTEREDONLY));
ModeManager::AddChannelMode('S', new ChannelMode(CMODE_STRIPCOLOR));
}
class ProtoInspIRCd : public Module
{
public:
@@ -1507,23 +1241,13 @@ class ProtoInspIRCd : public Module
pmodule_ircd_version("InspIRCd 1.2");
pmodule_ircd_cap(myIrcdcap);
pmodule_ircd_var(myIrcd);
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cumodes(myCumodes);
pmodule_ircd_flood_mode_char_set("+f");
pmodule_ircd_flood_mode_char_remove("-f");
pmodule_ircd_cbmodes(myCbmodes);
pmodule_ircd_cmmodes(myCmmodes);
pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(0);
/** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i);
pmodule_secret_cmode(CMODE_s);
pmodule_private_cmode(CMODE_p);
pmodule_key_mode(CMODE_k);
pmodule_limit_mode(CMODE_l);
moduleAddModes();
ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
+47 -332
View File
@@ -14,72 +14,26 @@
#include "services.h"
#include "pseudo.h"
#define UMODE_a 0x00000001
#define UMODE_C 0x00000002
#define UMODE_i 0x00000004
#define UMODE_o 0x00000008
#define UMODE_z 0x00000010
#define UMODE_w 0x00000020
#define UMODE_s 0x00000040
#define UMODE_c 0x00000080
#define UMODE_r 0x00000100
#define UMODE_k 0x00000200
#define UMODE_f 0x00000400
#define UMODE_y 0x00000800
#define UMODE_d 0x00001000
#define UMODE_n 0x00002000
#define UMODE_x 0x00004000
#define UMODE_u 0x00008000
#define UMODE_b 0x00010000
#define UMODE_l 0x00020000
#define UMODE_g 0x00040000
#define UMODE_Z 0x00080000
#define CMODE_i 0x00000001
#define CMODE_m 0x00000002
#define CMODE_n 0x00000004
#define CMODE_p 0x00000008
#define CMODE_s 0x00000010
#define CMODE_t 0x00000020
#define CMODE_k 0x00000040
#define CMODE_l 0x00000080
#define DEFAULT_MLOCK CMODE_n | CMODE_t
IRCDVar myIrcd[] = {
{"Ratbox 2.0+", /* ircd name */
"+oi", /* Modes used by pseudoclients */
2, /* Chan Max Symbols */
"-acilmnpst", /* Modes to Remove */
"+o", /* Channel Umode used by Botserv bots */
0, /* SVSNICK */
0, /* Vhost */
0, /* Has Owner */
NULL, /* Mode to set for an owner */
NULL, /* Mode to unset for an owner */
NULL, /* Mode to set for chan admin */
NULL, /* Mode to unset for chan admin */
NULL, /* Mode on UnReg */
1, /* Supports SGlines */
1, /* Supports SQlines */
0, /* Supports SZlines */
0, /* Supports Halfop +h */
3, /* Number of server args */
1, /* Join 2 Set */
1, /* Join 2 Message */
1, /* Has exceptions +e */
0, /* TS Topic Forward */
0, /* TS Topci Backward */
0, /* Protected Umode */
0, /* Has Admin */
1, /* Chan SQlines */
0, /* Quit on Kill */
0, /* SVSMODE unban */
0, /* Has Protect */
0, /* Reverse */
0, /* Chan Reg */
0, /* Channel Mode */
0, /* vidents */
0, /* svshold */
0, /* time stamp on mode */
@@ -88,28 +42,18 @@ IRCDVar myIrcd[] = {
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
CMODE_p, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
0, /* Vhost Mode */
0, /* +f */
0, /* +L */
0, /* +f Mode */
0, /* +L Mode */
0,
0, /* On nick change check if they could be identified */
0, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support TOKENS */
0, /* TIME STAMPS are BASE64 */
1, /* +I support */
0, /* SJOIN ban char */
0, /* SJOIN except char */
0, /* SJOIN invite char */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
NULL, /* vhost char */
1, /* ts6 */
0, /* support helper umode */
0, /* p10 */
NULL, /* character set */
0, /* CIDR channelbans */
@@ -152,257 +96,6 @@ IRCDCAPAB myIrcdcap[] = {
0, 0, 0}
};
unsigned long umodes[128] = {
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Horzontal Tab */
0, 0, 0, /* Line Feed, Unused, Unused */
0, 0, 0, /* Carriage Return, Unused, Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Space */
0, 0, 0, /* ! " # */
0, 0, 0, /* $ % & */
0, 0, 0, /* ! ( ) */
0, 0, 0, /* * + , */
0, 0, 0, /* - . / */
0, 0, /* 0 1 */
0, 0, /* 2 3 */
0, 0, /* 4 5 */
0, 0, /* 6 7 */
0, 0, /* 8 9 */
0, 0, /* : ; */
0, 0, 0, /* < = > */
0, 0, /* ? @ */
0, 0, 0, /* A B C */
0, 0, 0, /* D E F */
0, 0, 0, /* G H I */
0, 0, 0, /* J K L */
0, 0, 0, /* M N O */
0, 0, 0, /* P Q R */
0, 0, 0, /* S T U */
0, 0, 0, /* V W X */
0, /* Y */
0, /* Z */
0, 0, 0, /* [ \ ] */
0, 0, 0, /* ^ _ ` */
UMODE_a, UMODE_b, 0, /* a b c */
UMODE_d, 0, 0, /* d e f */
UMODE_g, 0, UMODE_i, /* g h i */
0, 0, UMODE_l, /* j k l */
0, UMODE_n, UMODE_o, /* m n o */
0, 0, 0, /* p q r */
0, 0, UMODE_u, /* s t u */
0, UMODE_w, UMODE_x, /* v w x */
0, /* y */
0, /* z */
0, 0, 0, /* { | } */
0, 0 /* ~ */
};
char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0, 0, 0,
0,
0, 0, 0, 0,
0,
'v', 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, /* BCD */
{NULL}, {NULL}, {NULL}, /* EFG */
{NULL}, /* H */
{add_invite, del_invite},
{NULL}, /* J */
{NULL}, {NULL}, {NULL}, /* KLM */
{NULL}, {NULL}, {NULL}, /* NOP */
{NULL}, {NULL}, {NULL}, /* QRS */
{NULL}, {NULL}, {NULL}, /* TUV */
{NULL}, {NULL}, {NULL}, /* WXY */
{NULL}, /* Z */
{NULL}, {NULL}, /* (char 91 - 92) */
{NULL}, {NULL}, {NULL}, /* (char 93 - 95) */
{NULL}, /* ` (char 96) */
{NULL}, /* a (char 97) */
{add_ban, del_ban},
{NULL},
{NULL},
{add_exception, del_exception},
{NULL},
{NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{0}, /* A */
{0}, /* B */
{0}, /* C */
{0}, /* D */
{0}, /* E */
{0}, /* F */
{0}, /* G */
{0}, /* H */
{0}, /* I */
{0}, /* J */
{0}, /* K */
{0}, /* L */
{0}, /* M */
{0}, /* N */
{0}, /* O */
{0}, /* P */
{0}, /* Q */
{0}, /* R */
{0}, /* S */
{0}, /* T */
{0}, /* U */
{0}, /* V */
{0}, /* W */
{0}, /* X */
{0}, /* Y */
{0}, /* Z */
{0}, {0}, {0}, {0}, {0}, {0},
{0},
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0}, /* h */
{CMODE_i, 0, NULL, NULL},
{0}, /* j */
{CMODE_k, 0, chan_set_key, cs_set_key},
{CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
{CMODE_m, 0, NULL, NULL},
{CMODE_n, 0, NULL, NULL},
{0}, /* o */
{CMODE_p, 0, NULL, NULL},
{0}, /* q */
{0},
{CMODE_s, 0, NULL, NULL},
{CMODE_t, 0, NULL, NULL},
{0},
{0}, /* v */
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}
};
CBModeInfo myCbmodeinfos[] = {
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
{'m', CMODE_m, 0, NULL, NULL},
{'n', CMODE_n, 0, NULL, NULL},
{'p', CMODE_p, 0, NULL, NULL},
{'s', CMODE_s, 0, NULL, NULL},
{'t', CMODE_t, 0, NULL, NULL},
{0}
};
CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{0}, /* a */
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{0},
{0}, /* i */
{0}, /* j */
{0}, /* k */
{0}, /* l */
{0}, /* m */
{0}, /* n */
{CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* p */
{0}, /* q */
{0}, /* r */
{0}, /* s */
{0}, /* t */
{0}, /* u */
{CUS_VOICE, 0, NULL},
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}, {0}
};
/*
* SVINFO
@@ -481,10 +174,11 @@ class RatboxProto : public IRCDTS6Proto
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
if (add)
user->SetMode(*modes);
else
user->RemoveMode(*modes);
switch (*modes++) {
case '+':
add = 1;
@@ -1084,6 +778,7 @@ int anope_event_bmask(const char *source, int ac, const char **av)
char *bans;
char *b;
int count, i;
ChannelModeList *cms;
/* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */
/* 0 1 2 3 */
@@ -1095,13 +790,16 @@ int anope_event_bmask(const char *source, int ac, const char **av)
for (i = 0; i <= count - 1; i++) {
b = myStrGetToken(bans, ' ', i);
if (!stricmp(av[2], "b")) {
add_ban(c, b);
cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "e")) {
add_exception(c, b);
cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "I")) {
add_invite(c, b);
cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
cms->AddMask(c, b);
}
if (b)
delete [] b;
@@ -1125,8 +823,6 @@ void moduleAddIRCDMsgs()
{
Message *m;
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
@@ -1154,6 +850,36 @@ void moduleAddIRCDMsgs()
m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m);
}
void moduleAddModes()
{
/* Add user modes */
ModeManager::AddUserMode('a', new UserMode(UMODE_ADMIN));
ModeManager::AddUserMode('i', new UserMode(UMODE_INVIS));
ModeManager::AddUserMode('o', new UserMode(UMODE_OPER));
ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED));
ModeManager::AddUserMode('s', new UserMode(UMODE_SNOMASK));
ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS));
/* b/e/I */
ModeManager::AddChannelMode('b', new ChannelModeBan());
ModeManager::AddChannelMode('e', new ChannelModeExcept());
ModeManager::AddChannelMode('I', new ChannelModeInvite());
/* v/h/o/a/q */
ModeManager::AddChannelMode('v', new ChannelModeStatus(CMODE_VOICE, CUS_VOICE, '+'));
ModeManager::AddChannelMode('o', new ChannelModeStatus(CMODE_OP, CUS_OP, '@', true));
/* Add channel modes */
ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE));
ModeManager::AddChannelMode('k', new ChannelModeKey());
ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT));
ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED));
ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL));
ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE));
ModeManager::AddChannelMode('s', new ChannelMode(CMODE_SECRET));
ModeManager::AddChannelMode('t', new ChannelMode(CMODE_TOPIC));
}
class ProtoRatbox : public Module
{
public:
@@ -1170,23 +896,12 @@ class ProtoRatbox : public Module
pmodule_ircd_version("Ratbox IRCD 2.0+");
pmodule_ircd_cap(myIrcdcap);
pmodule_ircd_var(myIrcd);
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cumodes(myCumodes);
pmodule_ircd_flood_mode_char_set("");
pmodule_ircd_flood_mode_char_remove("");
pmodule_ircd_cbmodes(myCbmodes);
pmodule_ircd_cmmodes(myCmmodes);
pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(1);
/** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i);
pmodule_secret_cmode(CMODE_s);
pmodule_private_cmode(CMODE_p);
pmodule_key_mode(CMODE_k);
pmodule_limit_mode(CMODE_l);
moduleAddModes();
ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
+115 -418
View File
@@ -16,107 +16,26 @@
#include "services.h"
#include "pseudo.h"
/* User Modes */
#define UMODE_a 0x00000001 /* a Services Admin */
#define UMODE_h 0x00000002 /* h Available for help (HelpOp) */
#define UMODE_i 0x00000004 /* i Invisible (not shown in /who) */
#define UMODE_o 0x00000008 /* o Global IRC Operator */
#define UMODE_r 0x00000010 /* r Identifies the nick as being registered */
#define UMODE_w 0x00000020 /* w Can listen to wallop messages */
#define UMODE_A 0x00000040 /* A Server Admin */
#define UMODE_N 0x00000080 /* N Network Administrator */
#define UMODE_O 0x00000100 /* O Local IRC Operator */
#define UMODE_C 0x00000200 /* C Co-Admin */
#define UMODE_d 0x00000400 /* d Makes it so you can not receive channel PRIVMSGs */
#define UMODE_p 0x00000800 /* Hides the channels you are in in a /whois reply */
#define UMODE_q 0x00001000 /* q Only U:Lines can kick you (Services Admins Only) */
#define UMODE_s 0x00002000 /* s Can listen to server notices */
#define UMODE_t 0x00004000 /* t Says you are using a /vhost */
#define UMODE_v 0x00008000 /* v Receives infected DCC Send Rejection notices */
#define UMODE_z 0x00010000 /* z Indicates that you are an SSL client */
#define UMODE_B 0x00020000 /* B Marks you as being a Bot */
#define UMODE_G 0x00040000 /* G Filters out all the bad words per configuration */
#define UMODE_H 0x00080000 /* H Hide IRCop Status (IRCop Only) */
#define UMODE_S 0x00100000 /* S services client */
#define UMODE_V 0x00200000 /* V Marks you as a WebTV user */
#define UMODE_W 0x00400000 /* W Lets you see when people do a /whois on you */
#define UMODE_T 0x00800000 /* T Prevents you from receiving CTCPs */
#define UMODE_g 0x20000000 /* g Can send & read globops and locops */
#define UMODE_x 0x40000000 /* x Gives user a hidden hostname */
#define UMODE_R 0x80000000 /* Allows you to only receive PRIVMSGs/NOTICEs from registered (+r) users */
/*************************************************************************/
/* Channel Modes */
#define CMODE_i 0x00000001
#define CMODE_m 0x00000002
#define CMODE_n 0x00000004
#define CMODE_p 0x00000008
#define CMODE_s 0x00000010
#define CMODE_t 0x00000020
#define CMODE_k 0x00000040 /* These two used only by ChanServ */
#define CMODE_l 0x00000080
#define CMODE_R 0x00000100 /* Only identified users can join */
#define CMODE_r 0x00000200 /* Set for all registered channels */
#define CMODE_c 0x00000400
#define CMODE_A 0x00000800
/* #define CMODE_H 0x00001000 Was now +I may not join, but Unreal Removed it and it will not set in 3.2 */
#define CMODE_K 0x00002000
#define CMODE_L 0x00004000
#define CMODE_O 0x00008000
#define CMODE_Q 0x00010000
#define CMODE_S 0x00020000
#define CMODE_V 0x00040000
#define CMODE_f 0x00080000
#define CMODE_G 0x00100000
#define CMODE_C 0x00200000
#define CMODE_u 0x00400000
#define CMODE_z 0x00800000
#define CMODE_N 0x01000000
#define CMODE_T 0x02000000
#define CMODE_M 0x04000000
/* Default Modes with MLOCK */
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
IRCDVar myIrcd[] = {
{"UnrealIRCd 3.2.x", /* ircd name */
"+Soi", /* Modes used by pseudoclients */
5, /* Chan Max Symbols */
"-cilmnpstuzACGHKMNOQRSTV", /* Modes to Remove */
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
1, /* Has Owner */
"+q", /* Mode to set for an owner */
"-q", /* Mode to unset for an owner */
"+a", /* Mode to set for channel admin */
"-a", /* Mode to unset for channel admin */
"-r+d", /* Mode on UnReg */
1, /* Supports SGlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
1, /* Supports Halfop +h */
3, /* Number of server args */
0, /* Join 2 Set */
0, /* Join 2 Message */
1, /* Has exceptions +e */
1, /* TS Topic Forward */
0, /* TS Topci Backward */
UMODE_S, /* Protected Umode */
0, /* Has Admin */
0, /* Chan SQlines */
0, /* Quit on Kill */
1, /* SVSMODE unban */
1, /* Has Protect */
1, /* Reverse */
1, /* Chan Reg */
CMODE_r, /* Channel Mode */
1, /* vidents */
1, /* svshold */
1, /* time stamp on mode */
@@ -125,28 +44,18 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
UMODE_x, /* Vhost Mode */
1, /* +f */
1, /* +L */
CMODE_f, /* +f Mode */
CMODE_L, /* +L Mode */
0,
0, /* On nick change check if they could be identified */
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
1, /* We support Unreal TOKENS */
1, /* TIME STAMPS are BASE64 */
1, /* +I support */
'&', /* SJOIN ban char */
'\"', /* SJOIN except char */
'\'', /* SJOIN invite char */
1, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
"x", /* vhost char */
0, /* ts6 */
1, /* support helper umode */
0, /* p10 */
NULL, /* character set */
0, /* CIDR channelbans */
@@ -192,271 +101,6 @@ IRCDCAPAB myIrcdcap[] = {
}
};
unsigned long umodes[128] = {
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Horzontal Tab */
0, 0, 0, /* Line Feed, Unused, Unused */
0, 0, 0, /* Carriage Return, Unused, Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused */
0, 0, 0, /* Unused, Unused, Space */
0, 0, 0, /* ! " # */
0, 0, 0, /* $ % & */
0, 0, 0, /* ! ( ) */
0, 0, 0, /* * + , */
0, 0, 0, /* - . / */
0, 0, /* 0 1 */
0, 0, /* 2 3 */
0, 0, /* 4 5 */
0, 0, /* 6 7 */
0, 0, /* 8 9 */
0, 0, /* : ; */
0, 0, 0, /* < = > */
0, 0, /* ? @ */
UMODE_A, UMODE_B, UMODE_C, /* A B C */
0, 0, 0, /* D E F */
UMODE_G, UMODE_H, 0, /* G H I */
0, 0, 0, /* J K L */
0, UMODE_N, UMODE_O, /* M N O */
0, 0, UMODE_R, /* P Q R */
UMODE_S, UMODE_T, 0, /* S T U */
UMODE_V, UMODE_W, 0, /* V W X */
0, /* Y */
0, /* Z */
0, 0, 0, /* [ \ ] */
0, 0, 0, /* ^ _ ` */
UMODE_a, 0, 0, /* a b c */
UMODE_d, 0, 0, /* d e f */
UMODE_g, UMODE_h, UMODE_i, /* g h i */
0, 0, 0, /* j k l */
0, 0, UMODE_o, /* m n o */
UMODE_p, UMODE_q, UMODE_r, /* p q r */
UMODE_s, UMODE_t, 0, /* s t u */
UMODE_v, UMODE_w, UMODE_x, /* v w x */
0, /* y */
UMODE_z, /* z */
0, 0, 0, /* { | } */
0, 0 /* ~ */
};
char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0, 0, 0,
'h', /* (37) % Channel halfops */
'b', /* (38) & bans */
0, 0, 0,
'q',
'v', 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
};
CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, /* BCD */
{NULL}, {NULL}, {NULL}, /* EFG */
{NULL}, /* H */
{add_invite, del_invite}, /* I */
{NULL}, /* J */
{NULL}, {NULL}, {NULL}, /* KLM */
{NULL}, {NULL}, {NULL}, /* NOP */
{NULL}, {NULL}, {NULL}, /* QRS */
{NULL}, {NULL}, {NULL}, /* TUV */
{NULL}, {NULL}, {NULL}, /* WXY */
{NULL}, /* Z */
{NULL}, {NULL}, /* (char 91 - 92) */
{NULL}, {NULL}, {NULL}, /* (char 93 - 95) */
{NULL}, /* ` (char 96) */
{NULL}, /* a (char 97) */
{add_ban, del_ban}, /* b */
{NULL}, {NULL}, /* cd */
{add_exception, del_exception},
{NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* B */
{CMODE_C, 0, NULL, NULL}, /* C */
{0}, /* D */
{0}, /* E */
{0}, /* F */
{CMODE_G, 0, NULL, NULL}, /* G */
{0}, /* H */
{0}, /* I */
{0}, /* J */
{CMODE_K, 0, NULL, NULL}, /* K */
{CMODE_L, 0, set_redirect, cs_set_redirect},
{CMODE_M, 0, NULL, NULL}, /* M */
{CMODE_N, 0, NULL, NULL}, /* N */
{CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
{0}, /* P */
{CMODE_Q, 0, NULL, NULL}, /* Q */
{CMODE_R, 0, NULL, NULL}, /* R */
{CMODE_S, 0, NULL, NULL}, /* S */
{CMODE_T, 0, NULL, NULL}, /* T */
{0}, /* U */
{CMODE_V, 0, NULL, NULL}, /* V */
{0}, /* W */
{0}, /* X */
{0}, /* Y */
{0}, /* Z */
{0}, {0}, {0}, {0}, {0}, {0},
{0}, /* a */
{0}, /* b */
{CMODE_c, 0, NULL, NULL},
{0}, /* d */
{0}, /* e */
{CMODE_f, 0, set_flood, cs_set_flood},
{0}, /* g */
{0}, /* h */
{CMODE_i, 0, NULL, NULL},
{0}, /* j */
{CMODE_k, 0, chan_set_key, cs_set_key},
{CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
{CMODE_m, 0, NULL, NULL},
{CMODE_n, 0, NULL, NULL},
{0}, /* o */
{CMODE_p, 0, NULL, NULL},
{0}, /* q */
{CMODE_r, CBM_NO_MLOCK, NULL, NULL},
{CMODE_s, 0, NULL, NULL},
{CMODE_t, 0, NULL, NULL},
{CMODE_u, 0, NULL, NULL},
{0}, /* v */
{0}, /* w */
{0}, /* x */
{0}, /* y */
{CMODE_z, 0, NULL, NULL},
{0}, {0}, {0}, {0}
};
CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'f', CMODE_f, 0, get_flood, cs_get_flood},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
{'m', CMODE_m, 0, NULL, NULL},
{'n', CMODE_n, 0, NULL, NULL},
{'p', CMODE_p, 0, NULL, NULL},
{'r', CMODE_r, 0, NULL, NULL},
{'s', CMODE_s, 0, NULL, NULL},
{'t', CMODE_t, 0, NULL, NULL},
{'u', CMODE_u, 0, NULL, NULL},
{'z', CMODE_z, 0, NULL, NULL},
{'A', CMODE_A, 0, NULL, NULL},
{'C', CMODE_C, 0, NULL, NULL},
{'G', CMODE_G, 0, NULL, NULL},
{'K', CMODE_K, 0, NULL, NULL},
{'L', CMODE_L, 0, get_redirect, cs_get_redirect},
{'M', CMODE_M, 0, NULL, NULL},
{'N', CMODE_N, 0, NULL, NULL},
{'O', CMODE_O, 0, NULL, NULL},
{'Q', CMODE_Q, 0, NULL, NULL},
{'R', CMODE_R, 0, NULL, NULL},
{'S', CMODE_S, 0, NULL, NULL},
{'T', CMODE_T, 0, NULL, NULL},
{'V', CMODE_V, 0, NULL, NULL},
{0}
};
CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0},
{CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* b */
{0}, /* c */
{0}, /* d */
{0}, /* e */
{0}, /* f */
{0}, /* g */
{CUS_HALFOP, 0, check_valid_op},
{0}, /* i */
{0}, /* j */
{0}, /* k */
{0}, /* l */
{0}, /* m */
{0}, /* n */
{CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
{0}, /* p */
{CUS_OWNER, 0, check_valid_op},
{0}, /* r */
{0}, /* s */
{0}, /* t */
{0}, /* u */
{CUS_VOICE, 0, NULL},
{0}, /* w */
{0}, /* x */
{0}, /* y */
{0}, /* z */
{0}, {0}, {0}, {0}, {0}
};
/* svswatch
* parv[0] - sender
* parv[1] - target nick
@@ -535,14 +179,10 @@ class UnrealIRCdProto : public IRCDProto
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
uint32 backup = user->mode;
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add)
user->mode |= umodes[static_cast<int>(*modes)];
user->SetMode(*modes);
else
user->mode &= ~umodes[static_cast<int>(*modes)];
user->RemoveMode(*modes);
switch (*modes++)
{
@@ -557,9 +197,11 @@ class UnrealIRCdProto : public IRCDProto
break;
if (isdigit(*av[1]))
{
//user->svid = strtoul(av[1], NULL, 0);
user->mode = backup; /* Ugly fix, but should do the job ~ Viper */
continue; // +d was setting a service stamp, ignore the usermode +-d.
/* +d was setting a service stamp, ignore the usermode +d */
if (add)
user->RemoveMode('d');
else
user->SetMode('d');
}
break;
case 'o':
@@ -573,7 +215,7 @@ class UnrealIRCdProto : public IRCDProto
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
user->RemoveMode('r');
}
break;
case 't':
@@ -874,38 +516,6 @@ class UnrealIRCdProto : public IRCDProto
send_cmd(ServerName, "ES");
}
/* check if +f mode is valid for the ircd */
/* borrowed part of the new check from channels.c in Unreal */
int IsFloodModeParamValid(const char *value)
{
char *dp, *end;
/* NEW +F */
char xbuf[256], *p, *p2, *x = xbuf + 1;
int v;
if (!value) return 0;
if (*value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
else {
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
strncpy(xbuf, value, sizeof(xbuf));
p2 = strchr(xbuf + 1, ']');
if (!p2) return 0;
*p2 = '\0';
if (*(p2 + 1) != ':') return 0;
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ",")) {
/* <number><1 letter>[optional: '#'+1 letter] */
p = x;
while (isdigit(*p)) ++p;
if (!*p || !(*p == 'c' || *p == 'j' || *p == 'k' || *p == 'm' || *p == 'n' || *p == 't')) continue; /* continue instead of break for forward compatability. */
*p = '\0';
v = atoi(x);
if (v < 1 || v > 999) return 0;
++p;
}
return 1;
}
}
/*
1 = valid nick
0 = nick is in valid
@@ -1216,7 +826,7 @@ int anope_event_sethost(const char *source, int ac, const char **av)
* to the sethost value (which really is their vhost) and clear the chost.
* The chost will be request later (if needed) - Adam
*/
if (u->mode & UMODE_t)
if (u->HasMode(UMODE_VHOST))
{
u->SetDisplayedHost(av[0]);
u->chost.clear();
@@ -1440,9 +1050,6 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
void moduleAddIRCDMsgs() {
Message *m;
updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
updateOwnerDetails("OWNER", "DEOWNER", ircd->ownerset, ircd->ownerunset);
m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m);
@@ -1512,6 +1119,106 @@ void moduleAddIRCDMsgs() {
m = createMessage("+", m_version); addCoreMessage(IRCD,m);
}
/* Borrowed part of this check from UnrealIRCd */
bool ChannelModeFlood::IsValid(const char *value)
{
char *dp, *end;
/* NEW +F */
char xbuf[256], *p, *p2, *x = xbuf + 1;
int v;
if (!value) return 0;
if (*value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1;
else {
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
strncpy(xbuf, value, sizeof(xbuf));
p2 = strchr(xbuf + 1, ']');
if (!p2) return 0;
*p2 = '\0';
if (*(p2 + 1) != ':') return 0;
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ",")) {
/* <number><1 letter>[optional: '#'+1 letter] */
p = x;
while (isdigit(*p)) ++p;
if (!*p || !(*p == 'c' || *p == 'j' || *p == 'k' || *p == 'm' || *p == 'n' || *p == 't')) continue; /* continue instead of break for forward compatability. */
*p = '\0';
v = atoi(x);
if (v < 1 || v > 999) return 0;
++p;
}
return 1;
}
}
void moduleAddModes()
{
/* Add user modes */
ModeManager::AddUserMode('A', new UserMode(UMODE_SERV_ADMIN));
ModeManager::AddUserMode('B', new UserMode(UMODE_BOT));
ModeManager::AddUserMode('C', new UserMode(UMODE_CO_ADMIN));
ModeManager::AddUserMode('G', new UserMode(UMODE_FILTER));
ModeManager::AddUserMode('H', new UserMode(UMODE_HIDEOPER));
ModeManager::AddUserMode('N', new UserMode(UMODE_NETADMIN));
ModeManager::AddUserMode('R', new UserMode(UMODE_REGPRIV));
ModeManager::AddUserMode('S', new UserMode(UMODE_PROTECTED));
ModeManager::AddUserMode('T', new UserMode(UMODE_NO_CTCP));
ModeManager::AddUserMode('V', new UserMode(UMODE_WEBTV));
ModeManager::AddUserMode('W', new UserMode(UMODE_WHOIS));
ModeManager::AddUserMode('a', new UserMode(UMODE_ADMIN));
ModeManager::AddUserMode('d', new UserMode(UMODE_DEAF));
ModeManager::AddUserMode('g', new UserMode(UMODE_GLOBOPS));
ModeManager::AddUserMode('h', new UserMode(UMODE_HELPOP));
ModeManager::AddUserMode('i', new UserMode(UMODE_INVIS));
ModeManager::AddUserMode('o', new UserMode(UMODE_OPER));
ModeManager::AddUserMode('p', new UserMode(UMODE_PRIV));
ModeManager::AddUserMode('q', new UserMode(UMODE_GOD));
ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED));
ModeManager::AddUserMode('s', new UserMode(UMODE_SNOMASK));
ModeManager::AddUserMode('t', new UserMode(UMODE_VHOST));
ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS));
ModeManager::AddUserMode('x', new UserMode(UMODE_CLOAK));
ModeManager::AddUserMode('z', new UserMode(UMODE_SSL));
/* b/e/I */
ModeManager::AddChannelMode('b', new ChannelModeBan());
ModeManager::AddChannelMode('e', new ChannelModeExcept());
ModeManager::AddChannelMode('I', new ChannelModeInvite());
/* v/h/o/a/q */
ModeManager::AddChannelMode('v', new ChannelModeStatus(CMODE_VOICE, CUS_VOICE, '+'));
ModeManager::AddChannelMode('h', new ChannelModeStatus(CMODE_HALFOP, CUS_HALFOP, '%'));
ModeManager::AddChannelMode('o', new ChannelModeStatus(CMODE_OP, CUS_OP, '@', true));
ModeManager::AddChannelMode('a', new ChannelModeStatus(CMODE_PROTECT, CUS_PROTECT, '&', true));
/* Unreal sends +q as * */
ModeManager::AddChannelMode('q', new ChannelModeStatus(CMODE_OWNER, CUS_OWNER, '*'));
/* Add channel modes */
ModeManager::AddChannelMode('c', new ChannelMode(CMODE_BLOCKCOLOR));
ModeManager::AddChannelMode('f', new ChannelModeFlood());
ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE));
ModeManager::AddChannelMode('k', new ChannelModeKey());
ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT));
ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED));
ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL));
ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE));
ModeManager::AddChannelMode('r', new ChannelModeRegistered());
ModeManager::AddChannelMode('s', new ChannelMode(CMODE_SECRET));
ModeManager::AddChannelMode('t', new ChannelMode(CMODE_TOPIC));
ModeManager::AddChannelMode('u', new ChannelMode(CMODE_AUDITORIUM));
ModeManager::AddChannelMode('z', new ChannelMode(CMODE_SSL));
ModeManager::AddChannelMode('A', new ChannelModeAdmin());
ModeManager::AddChannelMode('C', new ChannelMode(CMODE_NOCTCP));
ModeManager::AddChannelMode('G', new ChannelMode(CMODE_FILTER));
ModeManager::AddChannelMode('K', new ChannelMode(CMODE_NOKNOCK));
ModeManager::AddChannelMode('L', new ChannelModeParam(CMODE_REDIRECT));
ModeManager::AddChannelMode('M', new ChannelMode(CMODE_REGMODERATED));
ModeManager::AddChannelMode('N', new ChannelMode(CMODE_NONICK));
ModeManager::AddChannelMode('O', new ChannelModeOper());
ModeManager::AddChannelMode('Q', new ChannelMode(CMODE_NOKICK));
ModeManager::AddChannelMode('R', new ChannelMode(CMODE_REGISTEREDONLY));
ModeManager::AddChannelMode('S', new ChannelMode(CMODE_STRIPCOLOR));
ModeManager::AddChannelMode('T', new ChannelMode(CMODE_NONOTICE));
ModeManager::AddChannelMode('V', new ChannelMode(CMODE_NOINVITE));
}
class ProtoUnreal : public Module
{
@@ -1525,23 +1232,13 @@ class ProtoUnreal : public Module
pmodule_ircd_version("UnrealIRCd 3.2+");
pmodule_ircd_cap(myIrcdcap);
pmodule_ircd_var(myIrcd);
pmodule_ircd_cbmodeinfos(myCbmodeinfos);
pmodule_ircd_cumodes(myCumodes);
pmodule_ircd_flood_mode_char_set("+f");
pmodule_ircd_flood_mode_char_remove("-f");
pmodule_ircd_cbmodes(myCbmodes);
pmodule_ircd_cmmodes(myCmmodes);
pmodule_ircd_csmodes(myCsmodes);
pmodule_ircd_useTSMode(0);
/** Deal with modes anope _needs_ to know **/
pmodule_invis_umode(UMODE_i);
pmodule_oper_umode(UMODE_o);
pmodule_invite_cmode(CMODE_i);
pmodule_secret_cmode(CMODE_s);
pmodule_private_cmode(CMODE_p);
pmodule_key_mode(CMODE_k);
pmodule_limit_mode(CMODE_l);
moduleAddModes();
ircd->DefMLock[(size_t)CMODE_NOEXTERNAL] = true;
ircd->DefMLock[(size_t)CMODE_TOPIC] = true;
ircd->DefMLock[(size_t)CMODE_REGISTERED] = true;
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
+65 -17
View File
@@ -44,9 +44,9 @@ User::User(const std::string &snick, const std::string &suid)
nc = NULL;
chans = NULL;
founder_chans = NULL;
invalid_pw_count = timestamp = my_signon = mode = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
invalid_pw_count = timestamp = my_signon = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
OnAccess = false;
strscpy(this->nick, snick.c_str(), NICKMAX);
this->uid = suid;
list = &userlist[HASH(this->nick)];
@@ -130,7 +130,7 @@ const std::string User::GetDisplayedHost() const
{
if (ircd->vhost && this->vhost)
return this->vhost;
else if (ircd->vhostmode && (this->mode & ircd->vhostmode) && !this->GetCloakedHost().empty())
else if (this->HasMode(UMODE_CLOAK) && !this->GetCloakedHost().empty())
return this->GetCloakedHost();
else
return this->host;
@@ -178,7 +178,7 @@ void User::SetVIdent(const std::string &sident)
const std::string &User::GetVIdent() const
{
if (ircd->vhostmode && (this->mode & ircd->vhostmode))
if (this->HasMode(UMODE_CLOAK))
return this->vident;
else if (ircd->vident && !this->vident.empty())
return this->vident;
@@ -201,7 +201,6 @@ const std::string &User::GetIdent() const
return this->ident;
}
void User::SetRealname(const std::string &srealname)
{
if (srealname.empty())
@@ -476,6 +475,57 @@ User *finduser(const char *nick)
return user;
}
/** Check if the user has a mode
* @param Name Mode name
* @return true or false
*/
const bool User::HasMode(UserModeName Name) const
{
return modes[(size_t)Name];
}
/** Set a mode on the user
* @param Name The mode name
*/
void User::SetMode(UserModeName Name)
{
modes[(size_t)Name] = true;
}
/* Set a mode on the user
* @param ModeChar The mode char
*/
void User::SetMode(char ModeChar)
{
UserMode *um;
if ((um = ModeManager::FindUserModeByChar(ModeChar)))
{
SetMode(um->Name);
}
}
/** Remove a mode from the user
* @param Name The mode name
*/
void User::RemoveMode(UserModeName Name)
{
modes[(size_t)Name] = false;
}
/** Remove a mode from the user
* @param ModeChar The mode char
*/
void User::RemoveMode(char ModeChar)
{
UserMode *um;
if ((um = ModeManager::FindUserModeByChar(ModeChar)))
{
RemoveMode(um->Name);
}
}
/*************************************************************************/
@@ -944,11 +994,10 @@ void do_kill(const char *nick, const char *msg)
int is_protected(User * user)
{
if (ircd->protectedumode) {
return (user->mode & ircd->protectedumode);
} else {
return 0;
}
if (user && user->HasMode(UMODE_PROTECTED))
return 1;
return 0;
}
/*************************************************************************/
@@ -957,11 +1006,10 @@ int is_protected(User * user)
int is_oper(User * user)
{
if (user) {
return (user->mode & anope_get_oper_mode());
} else {
return 0;
}
if (user && user->HasMode(UMODE_OPER))
return 1;
return 0;
}
/*************************************************************************/
@@ -970,7 +1018,7 @@ int is_oper(User * user)
/* Is the given user ban-excepted? */
int is_excepted(ChannelInfo * ci, User * user)
{
if (!ci->c || !ircd->except)
if (!ci->c || !ModeManager::FindChannelModeByName(CMODE_EXCEPT))
return 0;
if (elist_match_user(ci->c->excepts, user))
@@ -984,7 +1032,7 @@ int is_excepted(ChannelInfo * ci, User * user)
/* Is the given MASK ban-excepted? */
int is_excepted_mask(ChannelInfo * ci, const char *mask)
{
if (!ci->c || !ircd->except)
if (!ci->c || !ModeManager::FindChannelModeByName(CMODE_EXCEPT))
return 0;
if (elist_match_mask(ci->c->excepts, mask, 0))