1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 06:53:12 +02:00

Pretty large coding style cleanup, in source doc

cleanup, and allow protocol mods to depend on each
other
This commit is contained in:
Adam
2012-11-22 00:50:33 -05:00
parent 368d469631
commit d33a0f75a5
303 changed files with 7880 additions and 9388 deletions
+67 -13
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef ACCESS_H #ifndef ACCESS_H
@@ -25,19 +24,25 @@ enum
ACCESS_FOUNDER = 10001 ACCESS_FOUNDER = 10001
}; };
/* A privilege, probably configured using a privilege{} block. Most
* commands require specific privileges to be executed. The AccessProvider
* backing each ChanAccess determines whether that ChanAccess has a given
* privilege.
*/
struct CoreExport Privilege struct CoreExport Privilege
{ {
Anope::string name; Anope::string name;
Anope::string desc; Anope::string desc;
/* Rank relative to other privileges */
int rank; int rank;
Privilege(const Anope::string &n, const Anope::string &d, int r); Privilege(const Anope::string &name, const Anope::string &desc, int rank);
bool operator==(const Privilege &other) const; bool operator==(const Privilege &other) const;
}; };
class CoreExport PrivilegeManager class CoreExport PrivilegeManager
{ {
static std::vector<Privilege> privs; static std::vector<Privilege> Privileges;
public: public:
static void AddPrivilege(Privilege p); static void AddPrivilege(Privilege p);
static void RemovePrivilege(Privilege &p); static void RemovePrivilege(Privilege &p);
@@ -46,25 +51,34 @@ class CoreExport PrivilegeManager
static void ClearPrivileges(); static void ClearPrivileges();
}; };
/* A provider of access. Only used for creating ChanAccesses, as
* they contain pure virtual functions.
*/
class CoreExport AccessProvider : public Service class CoreExport AccessProvider : public Service
{ {
public: public:
AccessProvider(Module *o, const Anope::string &n); AccessProvider(Module *owner, const Anope::string &name);
virtual ~AccessProvider(); virtual ~AccessProvider();
/** Creates a new ChanAccess entry using this provider.
* @return The new entry
*/
virtual ChanAccess *Create() = 0; virtual ChanAccess *Create() = 0;
private: private:
static std::list<AccessProvider *> providers; static std::list<AccessProvider *> Providers;
public: public:
static const std::list<AccessProvider *>& GetProviders(); static const std::list<AccessProvider *>& GetProviders();
}; };
/* Represents one entry of an access list on a channel. */
class CoreExport ChanAccess : public Serializable class CoreExport ChanAccess : public Serializable
{ {
public: public:
/* The provider that created this access entry */
AccessProvider *provider; AccessProvider *provider;
serialize_obj<ChannelInfo> ci; /* Channel this access entry is on */
Serialize::Reference<ChannelInfo> ci;
Anope::string mask; Anope::string mask;
Anope::string creator; Anope::string creator;
time_t last_seen; time_t last_seen;
@@ -73,29 +87,69 @@ class CoreExport ChanAccess : public Serializable
ChanAccess(AccessProvider *p); ChanAccess(AccessProvider *p);
virtual ~ChanAccess(); virtual ~ChanAccess();
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Check if this access entry matches the given user or account
* @param u The user
* @param nc The account
*/
virtual bool Matches(const User *u, const NickCore *nc) const; virtual bool Matches(const User *u, const NickCore *nc) const;
virtual bool HasPriv(const Anope::string &name) const = 0;
virtual Anope::string Serialize() const = 0;
virtual void Unserialize(const Anope::string &data) = 0;
/** Check if this access entry has the given privilege.
* @param name The privilege name
*/
virtual bool HasPriv(const Anope::string &name) const = 0;
/** Serialize the access given by this access entry into a human
* readable form. chanserv/access will return a number, chanserv/xop
* will be AOP, SOP, etc.
*/
virtual Anope::string AccessSerialize() const = 0;
/** Unserialize this access entry from the given data. This data
* will be fetched from AccessSerialize.
*/
virtual void AccessUnserialize(const Anope::string &data) = 0;
/* Comparison operators to other Access entries */
bool operator>(const ChanAccess &other) const; bool operator>(const ChanAccess &other) const;
bool operator<(const ChanAccess &other) const; bool operator<(const ChanAccess &other) const;
bool operator>=(const ChanAccess &other) const; bool operator>=(const ChanAccess &other) const;
bool operator<=(const ChanAccess &other) const; bool operator<=(const ChanAccess &other) const;
}; };
/* A group of access entries. This is used commonly, for example with ChannelInfo::AccessFor,
* to show what access a user has on a channel because users can match multiple access entries.
*/
class CoreExport AccessGroup : public std::vector<ChanAccess *> class CoreExport AccessGroup : public std::vector<ChanAccess *>
{ {
public: public:
/* Channel these access entries are on */
const ChannelInfo *ci; const ChannelInfo *ci;
/* Account these entries affect, if any */
const NickCore *nc; const NickCore *nc;
bool SuperAdmin, Founder; /* super_admin always gets all privs. founder is a special case where ci->founder == nc */
bool super_admin, founder;
AccessGroup(); AccessGroup();
/** Check if this access group has a certain privilege. Eg, it
* will check every ChanAccess entry of this group for any that
* has the given privilege.
* @param priv The privilege
* @return true if any entry has the given privilege
*/
bool HasPriv(const Anope::string &priv) const; bool HasPriv(const Anope::string &priv) const;
/** Get the "highest" access entry from this group of entries.
* The highest entry is determined by the entry that has the privilege
* with the highest rank (see Privilege::rank).
* @return The "highest" entry
*/
const ChanAccess *Highest() const; const ChanAccess *Highest() const;
/* Comparison operators to other AccessGroups */
bool operator>(const AccessGroup &other) const; bool operator>(const AccessGroup &other) const;
bool operator<(const AccessGroup &other) const; bool operator<(const AccessGroup &other) const;
bool operator>=(const AccessGroup &other) const; bool operator>=(const AccessGroup &other) const;
+112 -66
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef ACCOUNT_H #ifndef ACCOUNT_H
@@ -23,10 +22,8 @@
typedef Anope::hash_map<NickAlias *> nickalias_map; typedef Anope::hash_map<NickAlias *> nickalias_map;
typedef Anope::hash_map<NickCore *> nickcore_map; typedef Anope::hash_map<NickCore *> nickcore_map;
extern CoreExport serialize_checker<nickalias_map> NickAliasList; extern CoreExport Serialize::Checker<nickalias_map> NickAliasList;
extern CoreExport serialize_checker<nickcore_map> NickCoreList; extern CoreExport Serialize::Checker<nickcore_map> NickCoreList;
/* NickServ nickname structures. */
/** Flags set on NickAliases /** Flags set on NickAliases
*/ */
@@ -50,10 +47,6 @@ enum NickNameFlag
NS_END NS_END
}; };
const Anope::string NickNameFlagStrings[] = {
"BEGIN", "NO_EXPIRE", "HELD", "COLLIDED", ""
};
/** Flags set on NickCores /** Flags set on NickCores
*/ */
enum NickCoreFlag enum NickCoreFlag
@@ -101,40 +94,36 @@ enum NickCoreFlag
NI_END NI_END
}; };
const Anope::string NickCoreFlagStrings[] = { /* A registered nickname.
"BEGIN", "KILLPROTECT", "SECURE", "MSG", "MEMO_HARDMAX", "MEMO_SIGNON", "MEMO_RECEIVE", * It matters that Base is here before Extensible (it is inherited by Serializable)
"PRIVATE", "HIDE_EMAIL", "HIDE_MASK", "HIDE_QUIT", "KILL_QUICK", "KILL_IMMED", */
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "UNCONFIRMED", "STATS", "" class CoreExport NickAlias : public Serializable, public Extensible, public Flags<NickNameFlag>
};
/* It matters that Base is here before Extensible (it is inherited by Serializable) */
class CoreExport NickAlias : public Serializable, public Extensible, public Flags<NickNameFlag, NS_END>
{ {
Anope::string vhost_ident, vhost_host, vhost_creator; Anope::string vhost_ident, vhost_host, vhost_creator;
time_t vhost_created; time_t vhost_created;
public: public:
/** Default constructor Anope::string nick;
Anope::string last_quit;
Anope::string last_realname;
/* Last usermask this nick was seen on, eg user@host */
Anope::string last_usermask;
/* Last uncloaked usermask, requires nickserv/auspex to see */
Anope::string last_realhost;
time_t time_registered;
time_t last_seen;
/* Account this nick is tied to. Multiple nicks can be tied to a single account. */
Serialize::Reference<NickCore> nc;
/** Constructor
* @param nickname The nick * @param nickname The nick
* @param nickcore The nickcore for this nick * @param nickcore The nickcore for this nick
*/ */
NickAlias(const Anope::string &nickname, NickCore *nickcore); NickAlias(const Anope::string &nickname, NickCore *nickcore);
/** Default destructor
*/
~NickAlias(); ~NickAlias();
Anope::string nick; /* Nickname */ Serialize::Data Serialize() const anope_override;
Anope::string last_quit; /* Last quit message */ static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string last_realname; /* Last realname */
Anope::string last_usermask; /* Last usermask */
Anope::string last_realhost; /* Last uncloaked usermask, requires nickserv/auspex to see */
time_t time_registered; /* When the nick was registered */
time_t last_seen; /* When it was seen online for the last time */
serialize_obj<NickCore> nc; /* I'm an alias of this */
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
/** Release a nick /** Release a nick
* See the comment in users.cpp * See the comment in users.cpp
@@ -184,41 +173,67 @@ class CoreExport NickAlias : public Serializable, public Extensible, public Flag
* @return the time it was created * @return the time it was created
*/ */
time_t GetVhostCreated() const; time_t GetVhostCreated() const;
/** Finds a registered nick
* @param nick The nick to lookup
* @return the nick, if found
*/
static NickAlias *Find(const Anope::string &nick);
}; };
/* It matters that Base is here before Extensible (it is inherited by Serializable) */ /* A registered account. Each account must have a NickAlias with the same nick as the
class CoreExport NickCore : public Serializable, public Extensible, public Flags<NickCoreFlag, NI_END> * account's display.
* It matters that Base is here before Extensible (it is inherited by Serializable)
*/
class CoreExport NickCore : public Serializable, public Extensible, public Flags<NickCoreFlag>
{ {
public: public:
/** Default constructor /* Name of the account. Find(display)->nc == this. */
* @param display The display nick Anope::string display;
*/ /* User password in form of hashm:data */
NickCore(const Anope::string &nickdisplay); Anope::string pass;
Anope::string email;
/** Default destructor /* Greet associated with the account, sometimes sent when the user joins a channel */
*/ Anope::string greet;
~NickCore(); /* Locale name of the language of the user. Empty means default language */
Anope::string language;
std::list<User *> Users; /* Access list, contains user@host masks of users who get certain privileges based
* on if NI_SECURE is set and what (if any) kill protection is enabled. */
Anope::string display; /* How the nick is displayed */ std::vector<Anope::string> access;
Anope::string pass; /* Password of the nicks */ /* SSL certificate list. Users who have a matching certificate may be automatically logged in */
Anope::string email; /* E-mail associated to the nick */ std::vector<Anope::string> cert;
Anope::string greet; /* Greet associated to the nick */
Anope::string language; /* Language name */
std::vector<Anope::string> access; /* Access list, vector of strings */
std::vector<Anope::string> cert; /* ssl certificate list, vector of strings */
MemoInfo memos; MemoInfo memos;
/* Nicknames registered that are grouped to this account.
* for n in aliases, n->nc == this.
*/
std::list<Serialize::Reference<NickAlias> > aliases;
/* Set if this user is a services operattor. o->ot must exist. */
Oper *o; Oper *o;
/* Unsaved data */ /* Unsaved data */
uint16_t channelcount; /* Number of channels currently registered */
time_t lastmail; /* Last time this nick record got a mail */
std::list<serialize_obj<NickAlias> > aliases; /* List of aliases */
Serialize::Data serialize() const anope_override; /* Number of channels registered by this account */
static Serializable* unserialize(Serializable *obj, Serialize::Data &); uint16_t channelcount;
/* Last time an email was sent to this user */
time_t lastmail;
/* Users online now logged into this account */
std::list<User *> users;
/** Constructor
* @param display The display nick
*/
NickCore(const Anope::string &nickdisplay);
~NickCore();
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Changes the display for this account
* @param na The new display, must be grouped to this account.
*/
void SetDisplay(const NickAlias *na);
/** Checks whether this account is a services oper or not. /** Checks whether this account is a services oper or not.
* @return True if this account is a services oper, false otherwise. * @return True if this account is a services oper, false otherwise.
@@ -265,6 +280,14 @@ class CoreExport NickCore : public Serializable, public Extensible, public Flags
*/ */
void ClearAccess(); void ClearAccess();
/** Is the given user on this accounts access list?
*
* @param u The user
*
* @return true if the user is on the access list
*/
bool IsOnAccess(const User *u) const;
/** Add an entry to the nick's certificate list /** Add an entry to the nick's certificate list
* *
* @param entry The fingerprint to add to the cert list * @param entry The fingerprint to add to the cert list
@@ -304,10 +327,21 @@ class CoreExport NickCore : public Serializable, public Extensible, public Flags
* Deletes all the memory allocated in the certificate list vector and then clears the vector. * Deletes all the memory allocated in the certificate list vector and then clears the vector.
*/ */
void ClearCert(); void ClearCert();
/** Finds an account
* @param nick The account name to find
* @return The account, if it exists
*/
static NickCore* Find(const Anope::string &nick);
}; };
/* A request to check if an account/password is valid. These can exist for
* extended periods of time due to some authentication modules take.
*/
class CoreExport IdentifyRequest class CoreExport IdentifyRequest
{ {
/* Owner of this request, used to cleanup requests if a module is unloaded
* while a reqyest us pending */
Module *owner; Module *owner;
Anope::string account; Anope::string account;
Anope::string password; Anope::string password;
@@ -316,35 +350,47 @@ class CoreExport IdentifyRequest
bool dispatched; bool dispatched;
bool success; bool success;
static std::set<IdentifyRequest *> requests; static std::set<IdentifyRequest *> Requests;
protected: protected:
IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass); IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass);
virtual ~IdentifyRequest(); virtual ~IdentifyRequest();
public: public:
/* One of these is called when the request goes through */
virtual void OnSuccess() = 0; virtual void OnSuccess() = 0;
virtual void OnFail() = 0; virtual void OnFail() = 0;
const Anope::string &GetAccount() const { return account; } const Anope::string &GetAccount() const { return account; }
const Anope::string &GetPassword() const { return password; } const Anope::string &GetPassword() const { return password; }
/* Hold this request. Once held it must be Release()d later on */ /* Holds this request. When a request is held it must be Released later
* for the request to complete. Multiple modules may hold a request at any time,
* but the request is not complete until every module has released it. If you do not
* require holding this (eg, your password check is done in this thread and immediately)
* then you don't need to hold the request before Successing it.
* @param m The module holding this request
*/
void Hold(Module *m); void Hold(Module *m);
/** Releases a held request
* @param m The module releaseing the hold
*/
void Release(Module *m); void Release(Module *m);
/** Called by modules when this IdentifyRequest has successeded successfully.
* If this request is behind held it must still be Released after calling this.
* @param m The module confirming authentication
*/
void Success(Module *m); void Success(Module *m);
/** Used to either finalize this request or marks
* it as dispatched and begins waiting for the module(s)
* that have holds to finish.
*/
void Dispatch(); void Dispatch();
static void ModuleUnload(Module *m); static void ModuleUnload(Module *m);
}; };
extern CoreExport void change_core_display(NickCore *nc);
extern CoreExport void change_core_display(NickCore *nc, const Anope::string &newdisplay);
extern CoreExport NickAlias *findnick(const Anope::string &nick);
extern CoreExport NickCore *findcore(const Anope::string &nick);
extern CoreExport bool is_on_access(const User *u, const NickCore *nc);
#endif // ACCOUNT_H #endif // ACCOUNT_H
+190 -34
View File
@@ -1,4 +1,5 @@
/* /*
*
* (C) 2003-2012 Anope Team * (C) 2003-2012 Anope Team
* Contact us at team@anope.org * Contact us at team@anope.org
* *
@@ -6,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef ANOPE_H #ifndef ANOPE_H
@@ -304,11 +306,52 @@ namespace Anope
static const char *const compiled = __TIME__ " " __DATE__; static const char *const compiled = __TIME__ " " __DATE__;
/** The time Anope started.
*/
extern time_t StartTime;
/** The value to return from main()
*/
extern int ReturnValue;
extern bool Quitting;
extern bool Restarting;
extern Anope::string QuitReason;
/** The current system time, which is pretty close to being accurate. /** The current system time, which is pretty close to being accurate.
* Use this unless you need very specific time checks * Use this unless you need very specific time checks
*/ */
extern CoreExport time_t CurTime; extern CoreExport time_t CurTime;
/** The debug level we are running at.
*/
extern int Debug;
/** Other comand line options.
*/
extern bool ReadOnly, NoFork, NoThird, NoExpire, ProtocolDebug;
/** The root of the services installation. Usually ~/services
*/
extern Anope::string ServicesDir;
/** Services binary name (eg services)
*/
extern Anope::string ServicesBin;
/** Various directory paths. These can be set at runtime by command line args
*/
extern Anope::string ConfigDir;
extern Anope::string DataDir;
extern Anope::string ModuleDir;
extern Anope::string LocaleDir;
extern Anope::string LogDir;
/** The uplink we are currently connected to
*/
extern int CurrentUplink;
/** Various methods to determine the Anope version running
*/
extern CoreExport string Version(); extern CoreExport string Version();
extern CoreExport string VersionShort(); extern CoreExport string VersionShort();
extern CoreExport string VersionBuildString(); extern CoreExport string VersionBuildString();
@@ -316,6 +359,29 @@ namespace Anope
extern CoreExport int VersionMinor(); extern CoreExport int VersionMinor();
extern CoreExport int VersionPatch(); extern CoreExport int VersionPatch();
/** Determines if we are still attached to the terminal, and can print
* messages to the user via stderr/stdout.
* @return true if still attached
*/
extern bool AtTerm();
/** Used to "fork" the process and go into the background during initial startup
* while we are AtTerm(). The actual fork is not done here, but earlier, and this
* simply notifys the parent via kill() to exit().
*/
extern void Fork();
/** One of the first functions called, does general initialization such as reading
* command line args, loading the configuration, doing the initial fork() if necessary,
* initializating language support, loading modules, and loading databases.
* @throws CoreException if something bad went wrong
*/
extern void Init(int ac, char **av);
/** Calls the save database event
*/
extern void SaveDatabases();
/** Check whether two strings match. /** Check whether two strings match.
* @param str The string to check against the pattern (e.g. foobar) * @param str The string to check against the pattern (e.g. foobar)
* @param mask The pattern to check (e.g. foo*bar) * @param mask The pattern to check (e.g. foo*bar)
@@ -350,6 +416,20 @@ namespace Anope
*/ */
extern CoreExport void B64Decode(const string &src, string &target); extern CoreExport void B64Decode(const string &src, string &target);
/** Encrypts what is in 'src' to 'dest'
* @param src The source string to encrypt
* @param dest The destination where the encrypted string is placed
*/
extern void Encrypt(const Anope::string &src, Anope::string &dest);
/** Decrypts what is in 'src' to 'dest'.
* @param src The source string to decrypt
* @param dest The destination where the decrypted string is placed
* @return true if decryption was successful. This is usually not the case
* as most encryption methods we use are one way.
*/
extern bool Decrypt(const Anope::string &src, Anope::string &dest);
/** Returns a sequence of data formatted as the format argument specifies. /** Returns a sequence of data formatted as the format argument specifies.
** After the format parameter, the function expects at least as many ** After the format parameter, the function expects at least as many
** additional arguments as specified in format. ** additional arguments as specified in format.
@@ -368,6 +448,48 @@ namespace Anope
* @return An error message * @return An error message
*/ */
extern CoreExport const string LastError(); extern CoreExport const string LastError();
/** Determines if a path is a file
*/
extern bool IsFile(const Anope::string &file);
/** Converts a string into seconds
* @param s The string, eg 3d
* @return The time represented by the string, eg 259,200
*/
extern time_t DoTime(const Anope::string &s);
/** Retrieves a human readable string representing the time in seconds
* @param seconds The time on seconds, eg 60
* @param nc The account to use langauge settings for to translate this string, if applicable
* @return A human readable string, eg "1 minute"
*/
extern Anope::string Duration(time_t seconds, const NickCore *nc = NULL);
/** Generates a human readable string of type "expires in ..."
* @param expires time in seconds
* @param nc The account to use langauge settings for to translate this string, if applicable
* @return A human readable string, eg "expires in 5 days"
*/
extern Anope::string Expires(time_t seconds, const NickCore *nc = NULL);
/** Converts a time in seconds (epoch) to a human readable format.
* @param t The time
* @param nc The account to use langauge settings for to translate this string, if applicable
* @param short_output If true, the output is just a date (eg, "Apr 12 20:18:22 2009 MSD"), else it includes the date and how long ago/from now that date is, (eg "Apr 12 20:18:22 2009 MSD (1313 days, 9 hours, 32 minutes ago)"
*/
extern Anope::string strftime(time_t t, const NickCore *nc = NULL, bool short_output = false);
/** Normalize buffer, stripping control characters and colors
* @param A string to be parsed for control and color codes
* @return A string stripped of control and color codes
*/
extern Anope::string NormalizeBuffer(const Anope::string &);
/** Main processing routine. Parses the message and takes the appropriate action.
* @param Raw message from the uplink
*/
extern void Process(const Anope::string &);
} }
/** sepstream allows for splitting token seperated lists. /** sepstream allows for splitting token seperated lists.
@@ -394,23 +516,52 @@ class CoreExport sepstream
/** Create a sepstream and fill it with the provided data /** Create a sepstream and fill it with the provided data
*/ */
sepstream(const Anope::string &source, char seperator); sepstream(const Anope::string &source, char seperator);
virtual ~sepstream() { }
/** Fetch the next token from the stream /** Fetch the next token from the stream
* @param token The next token from the stream is placed here * @param token The next token from the stream is placed here
* @return True if tokens still remain, false if there are none left * @return True if tokens still remain, false if there are none left
*/ */
virtual bool GetToken(Anope::string &token); bool GetToken(Anope::string &token);
/** Gets token number 'num' from the stream
* @param token The token is placed here
* @param num The token number to featch
* @return True if the token was able to be detched
*/
bool GetToken(Anope::string &token, int num);
/** Gets every token from this stream
* @param token Tokens are pushed back here
*/
template<typename T> void GetTokens(T& token)
{
token.clear();
Anope::string t;
while (this->GetToken(t))
token.push_back(t);
}
/** Gets token number 'num' from the stream and all remaining tokens.
* @param token The token is placed here
* @param num The token number to featch
* @return True if the token was able to be detched
*/
bool GetTokenRemainder(Anope::string &token, int num);
/** Determines the number of tokens in this stream.
* @return The number of tokens in this stream
*/
int NumTokens();
/** Fetch the entire remaining stream, without tokenizing /** Fetch the entire remaining stream, without tokenizing
* @return The remaining part of the stream * @return The remaining part of the stream
*/ */
virtual const Anope::string GetRemaining(); const Anope::string GetRemaining();
/** Returns true if the end of the stream has been reached /** Returns true if the end of the stream has been reached
* @return True if the end of the stream has been reached, otherwise false * @return True if the end of the stream has been reached, otherwise false
*/ */
virtual bool StreamEnd(); bool StreamEnd();
}; };
/** A derived form of sepstream, which seperates on commas /** A derived form of sepstream, which seperates on commas
@@ -478,14 +629,6 @@ class CoreException : public std::exception
} }
}; };
class FatalException : public CoreException
{
public:
FatalException(const Anope::string &reason = "") : CoreException(reason) { }
virtual ~FatalException() throw() { }
};
class ModuleException : public CoreException class ModuleException : public CoreException
{ {
public: public:
@@ -600,39 +743,43 @@ template<typename T, typename O> inline T anope_dynamic_reinterpret_cast(O ptr)
/** Class with the ability to keep flags on items, they should extend from this /** Class with the ability to keep flags on items, they should extend from this
* where T is an enum. * where T is an enum.
*/ */
template<typename T, size_t Size = 32> class Flags template<typename T> class Flags
{ {
protected: std::vector<bool> flags_values;
std::bitset<Size> Flag_Values; static const Anope::string *flags_strings;
const Anope::string *Flag_Strings;
public: public:
Flags() : Flag_Strings(NULL) { }
Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
/** Add a flag to this item /** Add a flag to this item
* @param Value The flag * @param value The flag
*/ */
void SetFlag(T Value) void SetFlag(T value)
{ {
Flag_Values[Value] = true; if (value < 0)
return;
if (static_cast<unsigned>(value) >= flags_values.size())
flags_values.resize(value + 1);
flags_values[value] = true;
} }
/** Remove a flag from this item /** Remove a flag from this item
* @param Value The flag * @param value The flag
*/ */
void UnsetFlag(T Value) void UnsetFlag(T value)
{ {
Flag_Values[Value] = false; if (value >= 0 && static_cast<unsigned>(value) < flags_values.size())
flags_values[value] = false;
} }
/** Check if this item has a flag /** Check if this item has a flag
* @param Value The flag * @param value The flag
* @return true or false * @return true or false
*/ */
bool HasFlag(T Value) const bool HasFlag(T value) const
{ {
return Flag_Values.test(Value); if (value >= 0 && static_cast<unsigned>(value) < flags_values.size())
return flags_values[value];
return false;
} }
/** Check how many flags are set /** Check how many flags are set
@@ -640,14 +787,23 @@ template<typename T, size_t Size = 32> class Flags
*/ */
size_t FlagCount() const size_t FlagCount() const
{ {
return Flag_Values.count(); size_t c = 0;
for (unsigned i = 0; i < flags_values.size(); ++i)
if (flags_values[i])
++c;
return c;
} }
/** Unset all of the flags /** Unset all of the flags
*/ */
void ClearFlags() void ClearFlags()
{ {
Flag_Values.reset(); flags_values.clear();
}
static const Anope::string* GetFlagStrings()
{
return flags_strings;
} }
Anope::string ToString() const Anope::string ToString() const
@@ -675,9 +831,9 @@ template<typename T, size_t Size = 32> class Flags
std::vector<Anope::string> ToVector() const std::vector<Anope::string> ToVector() const
{ {
std::vector<Anope::string> ret; std::vector<Anope::string> ret;
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i) for (unsigned i = 0; this->flags_strings && !this->flags_strings[i].empty(); ++i)
if (this->HasFlag(static_cast<T>(i))) if (this->HasFlag(static_cast<T>(i)))
ret.push_back(this->Flag_Strings[i]); ret.push_back(this->flags_strings[i]);
return ret; return ret;
} }
@@ -685,9 +841,9 @@ template<typename T, size_t Size = 32> class Flags
{ {
this->ClearFlags(); this->ClearFlags();
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i) for (unsigned i = 0; this->flags_strings && !this->flags_strings[i].empty(); ++i)
for (unsigned j = 0; j < strings.size(); ++j) for (unsigned j = 0; j < strings.size(); ++j)
if (this->Flag_Strings[i] == strings[j]) if (this->flags_strings[i] == strings[j])
this->SetFlag(static_cast<T>(i)); this->SetFlag(static_cast<T>(i));
} }
}; };
+24 -14
View File
@@ -4,6 +4,7 @@
* Copyright (C) 2008-2012 Anope Team <team@anope.org> * Copyright (C) 2008-2012 Anope Team <team@anope.org>
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef BASE_H #ifndef BASE_H
@@ -16,48 +17,57 @@
class CoreExport Base class CoreExport Base
{ {
/* References to this base class */ /* References to this base class */
std::set<dynamic_reference_base *> References; std::set<ReferenceBase *> references;
public: public:
Base(); Base();
virtual ~Base(); virtual ~Base();
void AddReference(dynamic_reference_base *r);
void DelReference(dynamic_reference_base *r); /** Adds a reference to this object. Eg, when a Reference
* is created referring to this object this is called. It is used to
* cleanup references when this object is destructed.
*/
void AddReference(ReferenceBase *r);
void DelReference(ReferenceBase *r);
}; };
class dynamic_reference_base class ReferenceBase
{ {
protected: protected:
bool invalid; bool invalid;
public: public:
dynamic_reference_base() : invalid(false) { } ReferenceBase() : invalid(false) { }
dynamic_reference_base(const dynamic_reference_base &other) : invalid(other.invalid) { } ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
virtual ~dynamic_reference_base() { } virtual ~ReferenceBase() { }
inline void Invalidate() { this->invalid = true; } inline void Invalidate() { this->invalid = true; }
}; };
/** Used to hold pointers to objects that may be deleted. A Reference will
* no longer be valid once the object it refers is destructed.
*/
template<typename T> template<typename T>
class dynamic_reference : public dynamic_reference_base class Reference : public ReferenceBase
{ {
protected: protected:
T *ref; T *ref;
public: public:
dynamic_reference() : ref(NULL) Reference() : ref(NULL)
{ {
} }
dynamic_reference(T *obj) : ref(obj) Reference(T *obj) : ref(obj)
{ {
if (ref) if (ref)
ref->AddReference(this); ref->AddReference(this);
} }
dynamic_reference(const dynamic_reference<T> &other) : dynamic_reference_base(other), ref(other.ref) Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref)
{ {
if (operator bool()) if (operator bool())
ref->AddReference(this); ref->AddReference(this);
} }
virtual ~dynamic_reference() virtual ~Reference()
{ {
if (operator bool()) if (operator bool())
ref->DelReference(this); ref->DelReference(this);
@@ -105,12 +115,12 @@ class dynamic_reference : public dynamic_reference_base
this->ref->AddReference(this); this->ref->AddReference(this);
} }
inline bool operator<(const dynamic_reference<T> &other) const inline bool operator<(const Reference<T> &other) const
{ {
return this < &other; return this < &other;
} }
inline bool operator==(const dynamic_reference<T> &other) inline bool operator==(const Reference<T> &other)
{ {
if (!this->invalid) if (!this->invalid)
return this->ref == other; return this->ref == other;
+25 -19
View File
@@ -1,8 +1,10 @@
/* /*
*
* Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org> * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
* Copyright (C) 2008-2012 Anope Team <team@anope.org> * Copyright (C) 2008-2012 Anope Team <team@anope.org>
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef BOTS_H #ifndef BOTS_H
@@ -16,7 +18,7 @@
typedef Anope::map<BotInfo *> botinfo_map; typedef Anope::map<BotInfo *> botinfo_map;
extern CoreExport serialize_checker<botinfo_map> BotListByNick, BotListByUID; extern CoreExport Serialize::Checker<botinfo_map> BotListByNick, BotListByUID;
/** Flags settable on a bot /** Flags settable on a bot
*/ */
@@ -24,8 +26,6 @@ enum BotFlag
{ {
BI_BEGIN, BI_BEGIN,
/* This bot is a core bot. NickServ, ChanServ, etc */
BI_CORE,
/* This bot can only be assigned by IRCops */ /* This bot can only be assigned by IRCops */
BI_PRIVATE, BI_PRIVATE,
/* This bot is defined in the config */ /* This bot is defined in the config */
@@ -34,17 +34,21 @@ enum BotFlag
BI_END BI_END
}; };
static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF", "" }; /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable
{ {
public: public:
time_t created; /* Birth date ;) */ time_t created;
time_t lastmsg; /* Last time we said something */ /* Last time this bot said something (via privmsg) */
CommandInfo::map commands; /* Commands, actual name to service name */ time_t lastmsg;
Anope::string botmodes; /* Modes the bot should have as configured in service:modes */ /* Map of actual command names -> service name/permission required */
std::vector<Anope::string> botchannels; /* Channels the bot should be in as configured in service:channels */ CommandInfo::map commands;
bool introduced; /* Whether or not this bot is introduced */ /* Modes the bot should have as configured in service:modes */
Anope::string botmodes;
/* Channels the bot should be in as configured in service:channels */
std::vector<Anope::string> botchannels;
/* Whether or not this bot is introduced to the network */
bool introduced;
/** Create a new bot. /** Create a new bot.
* @param nick The nickname to assign to the bot. * @param nick The nickname to assign to the bot.
@@ -59,8 +63,8 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
*/ */
virtual ~BotInfo(); virtual ~BotInfo();
Serialize::Data serialize() const; Serialize::Data Serialize() const;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
void GenerateUID(); void GenerateUID();
@@ -126,11 +130,13 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
* @return A struct containing service name and permission * @return A struct containing service name and permission
*/ */
CommandInfo *GetCommand(const Anope::string &cname); CommandInfo *GetCommand(const Anope::string &cname);
/** Find a bot by nick
* @param nick The nick
* @param nick_only True to only look by nick, and not by UID
* @return The bot, if it exists
*/
static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
}; };
extern CoreExport BotInfo *findbot(const Anope::string &nick);
extern CoreExport void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
extern CoreExport void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
#endif // BOTS_H #endif // BOTS_H
-79
View File
@@ -1,79 +0,0 @@
/*
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#ifndef BOTSERV_H
#define BOTSERV_H
#include "anope.h"
/* BotServ SET flags */
enum BotServFlag
{
BS_BEGIN,
/* BotServ won't kick ops */
BS_DONTKICKOPS,
/* BotServ won't kick voices */
BS_DONTKICKVOICES,
/* BotServ bot accepts fantasy commands */
BS_FANTASY,
/* BotServ should show greets */
BS_GREET,
/* BotServ bots are not allowed to be in this channel */
BS_NOBOT,
/* BotServ kicks for bolds */
BS_KICK_BOLDS,
/* BotServ kicks for colors */
BS_KICK_COLORS,
/* BOtServ kicks for reverses */
BS_KICK_REVERSES,
/* BotServ kicks for underlines */
BS_KICK_UNDERLINES,
/* BotServ kicks for badwords */
BS_KICK_BADWORDS,
/* BotServ kicks for caps */
BS_KICK_CAPS,
/* BotServ kicks for flood */
BS_KICK_FLOOD,
/* BotServ kicks for repeating */
BS_KICK_REPEAT,
/* BotServ kicks for italics */
BS_KICK_ITALICS,
/* BotServ kicks for amsgs */
BS_KICK_AMSGS,
BS_END
};
const Anope::string BotServFlagStrings[] = {
"BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
"KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
"KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
"MSG_NOTICEOPS", ""
};
/* Indices for TTB (Times To Ban) */
enum
{
TTB_BOLDS,
TTB_COLORS,
TTB_REVERSES,
TTB_UNDERLINES,
TTB_BADWORDS,
TTB_CAPS,
TTB_FLOOD,
TTB_REPEAT,
TTB_ITALICS,
TTB_AMSGS,
TTB_SIZE
};
#endif // BOTSERV_H
+91 -58
View File
@@ -4,6 +4,7 @@
* Contact us at team@anope.org * Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef CHANNELS_H #ifndef CHANNELS_H
@@ -18,10 +19,12 @@ typedef Anope::hash_map<Channel *> channel_map;
extern CoreExport channel_map ChannelList; extern CoreExport channel_map ChannelList;
/* A user container, there is one of these per user per channel. */
struct UserContainer : public Extensible struct UserContainer : public Extensible
{ {
User *user; User *user;
ChannelStatus *Status; /* Status the user has in the channel */
ChannelStatus *status;
UserContainer(User *u) : user(u) { } UserContainer(User *u) : user(u) { }
virtual ~UserContainer() { } virtual ~UserContainer() { }
@@ -39,9 +42,7 @@ enum ChannelFlag
CH_SYNCING CH_SYNCING
}; };
const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" }; class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag>
class CoreExport Channel : public virtual Base, public Extensible, public Flags<ChannelFlag, 3>
{ {
public: public:
typedef std::multimap<ChannelModeName, Anope::string> ModeList; typedef std::multimap<ChannelModeName, Anope::string> ModeList;
@@ -51,27 +52,27 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
ModeList modes; ModeList modes;
public: public:
/** Default constructor /* Channel name */
* @param name The channel name Anope::string name;
* @param ts The time the channel was created /* Set if this channel is registered. ci->c == this. Contains information relevant to the registered channel */
*/ Serialize::Reference<ChannelInfo> ci;
Channel(const Anope::string &nname, time_t ts = Anope::CurTime); /* When the channel was created */
time_t creation_time;
/** Default destructor /* Users in the channel */
*/
~Channel();
Anope::string name; /* Channel name */
serialize_obj<ChannelInfo> ci; /* Corresponding ChannelInfo */
time_t creation_time; /* When channel was created */
/* List of users in the channel */
CUserList users; CUserList users;
Anope::string topic; /* Current topic of the channel */ /* Current topic of the channel */
Anope::string topic_setter; /* Who set the topic */ Anope::string topic;
time_t topic_ts; /* The timestamp associated with the topic. Not necessarually anywhere close to Anope::CurTime */ /* Who set the topic */
time_t topic_time; /* The actual time the topic was set, probably close to Anope::CurTime */ Anope::string topic_setter;
/* The timestamp associated with the topic. Not necessarually anywhere close to Anope::CurTime.
* This is the time the topic was *originally set*. When we restore the topic we want to change the TS back
* to this, but we can only do this on certain IRCds.
*/
time_t topic_ts;
/* The actual time the topic was set, probably close to Anope::CurTime */
time_t topic_time;
time_t server_modetime; /* Time of last server MODE */ time_t server_modetime; /* Time of last server MODE */
time_t chanserv_modetime; /* Time of last check_modes() */ time_t chanserv_modetime; /* Time of last check_modes() */
@@ -79,6 +80,16 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
int16_t chanserv_modecount; /* Number of check_mode()'s this sec */ int16_t chanserv_modecount; /* Number of check_mode()'s this sec */
int16_t bouncy_modes; /* Did we fail to set modes here? */ int16_t bouncy_modes; /* Did we fail to set modes here? */
/** Constructor
* @param name The channel name
* @param ts The time the channel was created
*/
Channel(const Anope::string &nname, time_t ts = Anope::CurTime);
/** Destructor
*/
~Channel();
/** Call if we need to unset all modes and clear all user status (internally). /** Call if we need to unset all modes and clear all user status (internally).
* Only useful if we get a SJOIN with a TS older than what we have here * Only useful if we get a SJOIN with a TS older than what we have here
*/ */
@@ -94,8 +105,9 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
/** Join a user internally to the channel /** Join a user internally to the channel
* @param u The user * @param u The user
* @return The UserContainer for the user
*/ */
void JoinUser(User *u); UserContainer* JoinUser(User *u);
/** Remove a user internally from the channel /** Remove a user internally from the channel
* @param u The user * @param u The user
@@ -118,94 +130,101 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
/** Check if a user has a status on a channel /** Check if a user has a status on a channel
* Use the overloaded function for ChannelModeStatus* to check for no status * Use the overloaded function for ChannelModeStatus* to check for no status
* @param u The user * @param u The user
* @param Name The Mode name, eg CMODE_OP, CMODE_VOICE * @param name The mode name, eg CMODE_OP, CMODE_VOICE
* @return true or false * @return true or false
*/ */
bool HasUserStatus(const User *u, ChannelModeName Name) const; bool HasUserStatus(const User *u, ChannelModeName name) const;
/** See if a channel has a mode /** See if a channel has a mode
* @param Name The mode name * @param name The mode name
* @return The number of modes set * @return The number of modes set
* @param param The optional mode param * @param param The optional mode param
*/ */
size_t HasMode(ChannelModeName Name, const Anope::string &param = ""); size_t HasMode(ChannelModeName name, const Anope::string &param = "");
/** Get a list of modes on a channel /** Get a list of modes on a channel
* @param Name A mode name to get the list of * @param name A mode name to get the list of
* @return a pair of iterators for the beginning and end of the list * @return a pair of iterators for the beginning and end of the list
*/ */
std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName Name); std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName name);
/** Set a mode internally on a channel, this is not sent out to the IRCd /** Set a mode internally on a channel, this is not sent out to the IRCd
* @param setter The setter * @param setter The setter
* @param cm The mode * @param cm The mode
* @param param The param * @param param The param
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void SetModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true); void SetModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** Remove a mode internally on a channel, this is not sent out to the IRCd /** Remove a mode internally on a channel, this is not sent out to the IRCd
* @param setter The Setter * @param setter The Setter
* @param cm The mode * @param cm The mode
* @param param The param * @param param The param
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void RemoveModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true); void RemoveModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** Set a mode on a channel /** Set a mode on a channel
* @param bi The client setting the modes * @param bi The client setting the modes
* @param cm The mode * @param cm The mode
* @param param Optional param arg for the mode * @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true); void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** /**
* Set a mode on a channel * Set a mode on a channel
* @param bi The client setting the modes * @param bi The client setting the modes
* @param Name The mode name * @param name The mode name
* @param param Optional param arg for the mode * @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true); void SetMode(BotInfo *bi, ChannelModeName name, const Anope::string &param = "", bool enforce_mlock = true);
/** Remove a mode from a channel /** Remove a mode from a channel
* @param bi The client setting the modes * @param bi The client setting the modes
* @param cm The mode * @param cm The mode
* @param param Optional param arg for the mode * @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true); void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** /**
* Remove a mode from a channel * Remove a mode from a channel
* @param bi The client setting the modes * @param bi The client setting the modes
* @param Name The mode name * @param name The mode name
* @param param Optional param arg for the mode * @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock * @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/ */
void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true); void RemoveMode(BotInfo *bi, ChannelModeName name, const Anope::string &param = "", bool enforce_mlock = true);
/** Get a param from the channel /** Get a modes parameter for the channel
* @param Name The mode * @param name The mode
* @param Target a string to put the param into * @param target a string to put the param into
* @return true on success * @return true if the parameter was fetched, false if on error (mode not set) etc.
*/ */
bool GetParam(ChannelModeName Name, Anope::string &Target) const; bool GetParam(ChannelModeName name, Anope::string &target) const;
/** Set a string of modes on the channel /** Set a string of modes on the channel
* @param bi The client setting the modes * @param bi The client setting the modes
* @param EnforceMLock Should mlock be enforced on this mode change * @param enforce_mlock Should mlock be enforced on this mode change
* @param cmodes The modes to set * @param cmodes The modes to set
*/ */
void SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...); void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...);
/** Set a string of modes internally on a channel /** Set a string of modes internally on a channel
* @param source The setter * @param source The setter
* @param mode the modes * @param mode the modes
* @param EnforceMLock true to enforce mlock * @param enforce_mlock true to enforce mlock
*/ */
void SetModesInternal(MessageSource &source, const Anope::string &mode, time_t ts = 0, bool EnforceMLock = true); void SetModesInternal(MessageSource &source, const Anope::string &mode, time_t ts = 0, bool enforce_mlock = true);
/** Does the given user match the given list? (CMODE_BAN, CMODE_EXCEPT, etc, a list mode)
* @param u The user
* @param list The mode of the list to check (eg CMODE_BAN)
* @return true if the user matches the list
*/
bool MatchesList(User *u, ChannelModeName list);
/** Kick a user from a channel internally /** Kick a user from a channel internally
* @param source The sender of the kick * @param source The sender of the kick
@@ -246,12 +265,26 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
/** Hold the channel open using ChanServ /** Hold the channel open using ChanServ
*/ */
void Hold(); void Hold();
/** Set the correct modes, or remove the ones granted without permission,
* for the specified user.
* @param user The user to give/remove modes to/from
* @param give_modes if true modes may be given to the user
* @param check_noop if true, CI_NOAUTOOP is checked before giving modes
*/
void SetCorrectModes(User *u, bool give_mode, bool check_noop);
/** Unbans a user from this channel.
* @param u The user to unban
* @param full Whether or not to match using the user's real host and IP
*/
void Unban(const User *u, bool full = false);
/** Finds a channel
* @param name The channel to find
* @return The channel, if found
*/
static Channel* Find(const Anope::string &name);
}; };
extern CoreExport Channel *findchan(const Anope::string &chan);
extern CoreExport User *nc_on_chan(Channel *c, const NickCore *nc);
extern CoreExport void chan_set_correct_modes(const User *user, Channel *c, int give_modes, bool check_noop);
#endif // CHANNELS_H #endif // CHANNELS_H
+12 -12
View File
@@ -22,20 +22,20 @@ enum CommandFlag
CFLAG_STRIP_CHANNEL CFLAG_STRIP_CHANNEL
}; };
const Anope::string CommandFlagStrings[] = { /* Used in BotInfo::commands */
"CFLAG_ALLOW_UNREGISTERED",
"CFLAG_STRIP_CHANNEL",
""
};
struct CommandInfo struct CommandInfo
{ {
typedef Anope::map<CommandInfo> map; typedef Anope::map<CommandInfo> map;
/* Service name of the command */
Anope::string name; Anope::string name;
/* Permission required to execute the command */
Anope::string permission; Anope::string permission;
}; };
/* Where the replies from commands go to. User inheits from this and is the normal
* source of a CommandReply
*/
struct CommandReply struct CommandReply
{ {
virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0; virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0;
@@ -47,16 +47,16 @@ class CoreExport CommandSource
/* The nick executing the command */ /* The nick executing the command */
Anope::string nick; Anope::string nick;
/* User executing the command, may be NULL */ /* User executing the command, may be NULL */
dynamic_reference<User> u; Reference<User> u;
public: public:
/* The account executing the command */ /* The account executing the command */
dynamic_reference<NickCore> nc; Reference<NickCore> nc;
/* Where the reply should go */ /* Where the reply should go */
CommandReply *reply; CommandReply *reply;
/* Channel the command was executed on (fantasy) */ /* Channel the command was executed on (fantasy) */
dynamic_reference<Channel> c; Reference<Channel> c;
/* The service this command is on */ /* The service this command is on */
dynamic_reference<BotInfo> service; Reference<BotInfo> service;
/* The actual name of the command being executed */ /* The actual name of the command being executed */
Anope::string command; Anope::string command;
/* The permission of the command being executed */ /* The permission of the command being executed */
@@ -88,9 +88,9 @@ class CoreExport Command : public Service, public Flags<CommandFlag>
public: public:
/* Maximum paramaters accepted by this command */ /* Maximum paramaters accepted by this command */
size_t MaxParams; size_t max_params;
/* Minimum parameters required to use this command */ /* Minimum parameters required to use this command */
size_t MinParams; size_t min_params;
/* Module which owns us */ /* Module which owns us */
Module *module; Module *module;
+4 -24
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef CONFIG_H #ifndef CONFIG_H
@@ -207,23 +206,6 @@ typedef bool (*MultiValidator)(ServerConfig *, const Anope::string &, const Anop
*/ */
typedef bool (*MultiNotify)(ServerConfig *, const Anope::string &); typedef bool (*MultiNotify)(ServerConfig *, const Anope::string &);
bool ValidateNotEmpty(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateNotZero(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateEmailReg(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidatePort(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGuestPrefix(ServerConfig *conf, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateBantype(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data);
bool ValidateChanServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateMemoServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateBotServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data);
bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
/** Represents a configuration file /** Represents a configuration file
*/ */
class ConfigurationFile class ConfigurationFile
@@ -463,8 +445,6 @@ class CoreExport ServerConfig
bool UseServerSideTopicLock; bool UseServerSideTopicLock;
/* Default botmodes on channels, defaults to ao */ /* Default botmodes on channels, defaults to ao */
Anope::string BotModes; Anope::string BotModes;
/* THe actual modes */
ChannelStatus BotModeList;
/* How long to wait between connection attempts */ /* How long to wait between connection attempts */
int RetryWait; int RetryWait;
/* If services should hide unprivileged commands */ /* If services should hide unprivileged commands */
@@ -517,7 +497,7 @@ class CoreExport ServerConfig
/* Don't allow nicks to use /ns group to regroup nicks */ /* Don't allow nicks to use /ns group to regroup nicks */
bool NSNoGroupChange; bool NSNoGroupChange;
/* Default flags for newly registered nicks */ /* Default flags for newly registered nicks */
Flags<NickCoreFlag, NI_END> NSDefFlags; Flags<NickCoreFlag> NSDefFlags;
/* All languages Anope is aware about */ /* All languages Anope is aware about */
Anope::string Languages; Anope::string Languages;
/* Default language used by services */ /* Default language used by services */
@@ -578,7 +558,7 @@ class CoreExport ServerConfig
/* Core ChanServ modules */ /* Core ChanServ modules */
Anope::string ChanCoreModules; Anope::string ChanCoreModules;
/* Default flags for newly registered channels */ /* Default flags for newly registered channels */
Flags<ChannelInfoFlag, CI_END> CSDefFlags; Flags<ChannelInfoFlag> CSDefFlags;
/* Max number of channels a user can own */ /* Max number of channels a user can own */
unsigned CSMaxReg; unsigned CSMaxReg;
/* Time before a channel expires */ /* Time before a channel expires */
@@ -741,7 +721,7 @@ class ConfigException : public CoreException
#define CONF_FILE_NOT_FOUND 0x000200 #define CONF_FILE_NOT_FOUND 0x000200
/** Allows reading of values from configuration files /** Allows reading of values from configuration files
* This class allows a module to read from either the main configuration file (inspircd.conf) or from * This class allows a module to read from either the main configuration file (services.conf) or from
* a module-specified configuration file. It may either be instantiated with one parameter or none. * a module-specified configuration file. It may either be instantiated with one parameter or none.
* Constructing the class using one parameter allows you to specify a path to your own configuration * Constructing the class using one parameter allows you to specify a path to your own configuration
* file, otherwise, inspircd.conf is read. * file, otherwise, inspircd.conf is read.
@@ -836,7 +816,7 @@ class CoreExport ConfigReader
int EnumerateValues(const Anope::string &, int); int EnumerateValues(const Anope::string &, int);
}; };
extern ConfigurationFile services_conf; extern ConfigurationFile ServicesConf;
extern CoreExport ServerConfig *Config; extern CoreExport ServerConfig *Config;
#endif // CONFIG_H #endif // CONFIG_H
+4 -4
View File
@@ -23,21 +23,21 @@ class ClientSocket;
class Command; class Command;
class CommandSource; class CommandSource;
class ConnectionSocket; class ConnectionSocket;
class DNSPacket; namespace DNS { class Packet; }
class dynamic_reference_base;
class Entry; class Entry;
class IdentifyRequest; class IdentifyRequest;
class InfoFormatter; class InfoFormatter;
class IRCDProto;
class ListenSocket; class ListenSocket;
class Log; class Log;
class LogInfo; class LogInfo;
class Memo; class Memo;
class Message;
class MessageSource; class MessageSource;
class Module; class Module;
class NickAlias; class NickAlias;
class NickCore; class NickCore;
class OperType; class OperType;
class ReferenceBase;
class Regex; class Regex;
class Serializable; class Serializable;
class Server; class Server;
@@ -48,7 +48,7 @@ class User;
class XLine; class XLine;
class XLineManager; class XLineManager;
struct BadWord; struct BadWord;
struct DNSQuery; namespace DNS { struct Query; }
struct Exception; struct Exception;
struct MemoInfo; struct MemoInfo;
struct ModeLock; struct ModeLock;
+237 -226
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef DNS_H #ifndef DNS_H
@@ -16,251 +15,263 @@
#include "sockets.h" #include "sockets.h"
#include "timers.h" #include "timers.h"
#include "extern.h"
#include "config.h" #include "config.h"
/** Valid query types namespace DNS
*/
enum QueryType
{ {
/* Nothing */
DNS_QUERY_NONE,
/* A simple A lookup */
DNS_QUERY_A = 1,
/* An authoritative name server */
DNS_QUERY_NS = 2,
/* A CNAME lookup */
DNS_QUERY_CNAME = 5,
/* Start of a zone of authority */
DNS_QUERY_SOA = 6,
/* Reverse DNS lookup */
DNS_QUERY_PTR = 12,
/* IPv6 AAAA lookup */
DNS_QUERY_AAAA = 28,
/* Zone transfer */
DNS_QUERY_AXFR = 252
};
/** Flags that can be AND'd into DNSPacket::flags to receive certain values /** Valid query types
*/ */
enum enum QueryType
{
DNS_QUERYFLAGS_QR = 0x8000,
DNS_QUERYFLAGS_OPCODE = 0x7800,
DNS_QUERYFLAGS_AA = 0x400,
DBS_QUERYFLAGS_TC = 0x200,
DNS_QUERYFLAGS_RD = 0x100,
DNS_QUERYFLAGS_RA = 0x80,
DNS_QUERYFLAGS_Z = 0x70,
DNS_QUERYFLAGS_RCODE = 0xF
};
enum DNSError
{
DNS_ERROR_NONE,
DNS_ERROR_UNKNOWN,
DNS_ERROR_UNLOADED,
DNS_ERROR_TIMEOUT,
DNS_ERROR_NOT_AN_ANSWER,
DNS_ERROR_NONSTANDARD_QUERY,
DNS_ERROR_FORMAT_ERROR,
DNS_ERROR_SERVER_FAILURE,
DNS_ERROR_DOMAIN_NOT_FOUND,
DNS_ERROR_NOT_IMPLEMENTED,
DNS_ERROR_REFUSED,
DNS_ERROR_NO_RECORDS,
DNS_ERROR_INVALIDTYPE
};
struct CoreExport Question
{
Anope::string name;
QueryType type;
unsigned short qclass;
Question();
Question(const Anope::string &, QueryType, unsigned short = 1);
};
struct CoreExport ResourceRecord : public Question
{
unsigned int ttl;
Anope::string rdata;
time_t created;
ResourceRecord(const Anope::string &, QueryType, unsigned short = 1);
ResourceRecord(const Question &);
};
struct CoreExport DNSQuery
{
std::vector<Question> questions;
std::vector<ResourceRecord> answers, authorities, additional;
DNSError error;
DNSQuery();
DNSQuery(const Question &q);
};
/** The request
*/
class CoreExport DNSRequest : public Timer, public Question
{
/* Use result cache if available */
bool use_cache;
public:
/* Request id */
unsigned short id;
/* Creator of this request */
Module *creator;
DNSRequest(const Anope::string &addr, QueryType qt, bool cache = false, Module *c = NULL);
virtual ~DNSRequest();
void Process();
virtual void OnLookupComplete(const DNSQuery *r) = 0;
virtual void OnError(const DNSQuery *r);
void Tick(time_t) anope_override;
};
/** A full packet sent or recieved to/from the nameserver
*/
class DNSPacket : public DNSQuery
{
static const int DNS_POINTER = 0xC0;
static const int DNS_LABEL = 0x3F;
void PackName(unsigned char *output, unsigned short output_size, unsigned short &pos, const Anope::string &name);
Anope::string UnpackName(const unsigned char *input, unsigned short input_size, unsigned short &pos);
Question UnpackQuestion(const unsigned char *input, unsigned short input_size, unsigned short &pos);
ResourceRecord UnpackResourceRecord(const unsigned char *input, unsigned short input_size, unsigned short &poss);
public:
static const int HEADER_LENGTH = 12;
/* Source or destination of the packet */
sockaddrs addr;
/* ID for this packet */
unsigned short id;
/* Flags on the packet */
unsigned short flags;
DNSPacket(sockaddrs *a);
void Fill(const unsigned char *input, const unsigned short len);
unsigned short Pack(unsigned char *output, unsigned short output_size);
};
/** DNS manager
*/
class CoreExport DNSManager : public Timer
{
class ReplySocket : public virtual Socket
{ {
public: /* Nothing */
virtual ~ReplySocket() { } QUERY_NONE,
virtual void Reply(DNSPacket *p) = 0; /* A simple A lookup */
QUERY_A = 1,
/* An authoritative name server */
QUERY_NS = 2,
/* A CNAME lookup */
QUERY_CNAME = 5,
/* Start of a zone of authority */
QUERY_SOA = 6,
/* Reverse DNS lookup */
QUERY_PTR = 12,
/* IPv6 AAAA lookup */
QUERY_AAAA = 28,
/* Zone transfer */
QUERY_AXFR = 252
}; };
/* Listens for TCP requests */ /** Flags that can be AND'd into DNSPacket::flags to receive certain values
class TCPSocket : public ListenSocket */
enum
{ {
/* A TCP client */ QUERYFLAGS_QR = 0x8000,
class Client : public ClientSocket, public Timer, public ReplySocket QUERYFLAGS_OPCODE = 0x7800,
QUERYFLAGS_AA = 0x400,
QUERYFLAGS_TC = 0x200,
QUERYFLAGS_RD = 0x100,
QUERYFLAGS_RA = 0x80,
QUERYFLAGS_Z = 0x70,
QUERYFLAGS_RCODE = 0xF
};
enum Error
{
ERROR_NONE,
ERROR_UNKNOWN,
ERROR_UNLOADED,
ERROR_TIMEOUT,
ERROR_NOT_AN_ANSWER,
ERROR_NONSTANDARD_QUERY,
ERROR_FORMAT_ERROR,
ERROR_SERVER_FAILURE,
ERROR_DOMAIN_NOT_FOUND,
ERROR_NOT_IMPLEMENTED,
ERROR_REFUSED,
ERROR_NO_RECORDS,
ERROR_INVALIDTYPE
};
struct CoreExport Question
{
Anope::string name;
QueryType type;
unsigned short qclass;
Question();
Question(const Anope::string &, QueryType, unsigned short = 1);
};
struct CoreExport ResourceRecord : public Question
{
unsigned int ttl;
Anope::string rdata;
time_t created;
ResourceRecord(const Anope::string &, QueryType, unsigned short = 1);
ResourceRecord(const Question &);
};
struct CoreExport Query
{
std::vector<Question> questions;
std::vector<ResourceRecord> answers, authorities, additional;
Error error;
Query();
Query(const Question &q);
};
/** A DNS query.
*/
class CoreExport Request : public Timer, public Question
{
/* Use result cache if available */
bool use_cache;
public:
/* Request id */
unsigned short id;
/* Creator of this request */
Module *creator;
Request(const Anope::string &addr, QueryType qt, bool cache = false, Module *c = NULL);
virtual ~Request();
void Process();
/** Called when this request succeeds
* @param r The query sent back from the nameserver
*/
virtual void OnLookupComplete(const Query *r) = 0;
/** Called when this request fails or times out.
* @param r The query sent back from the nameserver, check the error code.
*/
virtual void OnError(const Query *r);
/** Used to time out the query, Calls OnError and lets the TimerManager
* delete this request.
*/
void Tick(time_t) anope_override;
};
/** A full packet sent or recieved to/from the nameserver
*/
class Packet : public Query
{
static const int POINTER = 0xC0;
static const int LABEL = 0x3F;
void PackName(unsigned char *output, unsigned short output_size, unsigned short &pos, const Anope::string &name);
Anope::string UnpackName(const unsigned char *input, unsigned short input_size, unsigned short &pos);
Question UnpackQuestion(const unsigned char *input, unsigned short input_size, unsigned short &pos);
ResourceRecord UnpackResourceRecord(const unsigned char *input, unsigned short input_size, unsigned short &poss);
public:
static const int HEADER_LENGTH = 12;
/* Source or destination of the packet */
sockaddrs addr;
/* ID for this packet */
unsigned short id;
/* Flags on the packet */
unsigned short flags;
Packet(sockaddrs *a);
void Fill(const unsigned char *input, const unsigned short len);
unsigned short Pack(unsigned char *output, unsigned short output_size);
};
/** DNS manager
*/
class CoreExport Manager : public Timer
{
class ReplySocket : public virtual Socket
{ {
TCPSocket *tcpsock; public:
DNSPacket *packet; virtual ~ReplySocket() { }
unsigned char packet_buffer[524]; virtual void Reply(Packet *p) = 0;
int length; };
/* Listens for TCP requests */
class TCPSocket : public ListenSocket
{
/* A TCP client */
class Client : public ClientSocket, public Timer, public ReplySocket
{
TCPSocket *tcpsock;
Packet *packet;
unsigned char packet_buffer[524];
int length;
public:
Client(TCPSocket *ls, int fd, const sockaddrs &addr);
~Client();
/* Times out after a few seconds */
void Tick(time_t) anope_override { }
void Reply(Packet *p) anope_override;
bool ProcessRead() anope_override;
bool ProcessWrite() anope_override;
};
public: public:
Client(TCPSocket *ls, int fd, const sockaddrs &addr); TCPSocket(const Anope::string &ip, int port);
~Client();
ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override;
};
/* Listens for UDP requests */
class UDPSocket : public ReplySocket
{
std::deque<Packet *> packets;
public:
UDPSocket(const Anope::string &ip, int port);
~UDPSocket();
void Reply(Packet *p) anope_override;
std::deque<Packet *>& GetPackets() { return packets; }
/* Times out after a few seconds */
void Tick(time_t) anope_override { }
void Reply(DNSPacket *p) anope_override;
bool ProcessRead() anope_override; bool ProcessRead() anope_override;
bool ProcessWrite() anope_override; bool ProcessWrite() anope_override;
}; };
public: typedef std::multimap<Anope::string, ResourceRecord, ci::less> cache_map;
TCPSocket(const Anope::string &ip, int port); cache_map cache;
ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override; bool listen;
uint32_t serial;
public:
TCPSocket *tcpsock;
UDPSocket *udpsock;
sockaddrs addrs;
std::map<unsigned short, Request *> requests;
Manager(const Anope::string &nameserver, const Anope::string &ip, int port);
~Manager();
bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from);
/** Add a record to the dns cache
* @param r The record
*/
void AddCache(Query &r);
/** Check the DNS cache to see if request can be handled by a cached result
* @return true if a cached result was found.
*/
bool CheckCache(Request *request);
/** Tick this timer, used to clear the DNS cache.
*/
void Tick(time_t now) anope_override;
/** Cleanup all pending DNS queries for a module
* @param mod The module
*/
void Cleanup(Module *mod);
void UpdateSerial();
uint32_t GetSerial() const;
/** Does a BLOCKING DNS query and returns the first IP.
* Only use this if you know what you are doing. Unless you specifically
* need a blocking query use the DNSRequest system
*/
static Query BlockingQuery(const Anope::string &mask, QueryType qt);
}; };
/* Listens for UDP requests */ extern CoreExport Manager *Engine;
class UDPSocket : public ReplySocket
{
std::deque<DNSPacket *> packets;
public:
UDPSocket(const Anope::string &ip, int port); } // namespace DNS
~UDPSocket();
void Reply(DNSPacket *p) anope_override;
std::deque<DNSPacket *>& GetPackets() { return packets; }
bool ProcessRead() anope_override;
bool ProcessWrite() anope_override;
};
typedef std::multimap<Anope::string, ResourceRecord, ci::less> cache_map;
cache_map cache;
bool listen;
uint32_t serial;
public:
TCPSocket *tcpsock;
UDPSocket *udpsock;
sockaddrs addrs;
std::map<unsigned short, DNSRequest *> requests;
DNSManager(const Anope::string &nameserver, const Anope::string &ip, int port);
~DNSManager();
bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from);
/** Add a record to the dns cache
* @param r The record
*/
void AddCache(DNSQuery &r);
/** Check the DNS cache to see if request can be handled by a cached result
* @return true if a cached result was found.
*/
bool CheckCache(DNSRequest *request);
/** Tick this timer, used to clear the DNS cache.
*/
void Tick(time_t now) anope_override;
/** Cleanup all pending DNS queries for a module
* @param mod The module
*/
void Cleanup(Module *mod);
void UpdateSerial();
uint32_t GetSerial() const;
/** Does a BLOCKING DNS query and returns the first IP.
* Only use this if you know what you are doing. Unless you specifically
* need a blocking query use the DNSRequest system
*/
static DNSQuery BlockingQuery(const Anope::string &mask, QueryType qt);
};
extern CoreExport DNSManager *DNSEngine;
#endif // DNS_H #endif // DNS_H
+17 -5
View File
@@ -1,7 +1,10 @@
/* /*
* Copyright (C) 2008-2012 Anope Team <team@anope.org> *
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef EXTENSIBLE_H #ifndef EXTENSIBLE_H
@@ -9,19 +12,28 @@
#include "anope.h" #include "anope.h"
/* All items added to Extensible must inherit from this.
*/
class CoreExport ExtensibleItem class CoreExport ExtensibleItem
{ {
public: public:
ExtensibleItem(); virtual ~ExtensibleItem() { }
virtual ~ExtensibleItem();
virtual void OnDelete(); /* Called when this ExtensibleItem is being deleted. This should
* clean up things (eg, delete this;) if necessary.
*/
virtual void OnDelete() { delete this; }
}; };
/** Common class used to Extensible::Extend non-pointers from, as it doesn't delete
* itself when removed. Eg, obj->Extend(key, new ExtensibleItemClass<Anope::string>(value));
*/
template<typename T> struct CoreExport ExtensibleItemClass : T, ExtensibleItem template<typename T> struct CoreExport ExtensibleItemClass : T, ExtensibleItem
{ {
ExtensibleItemClass(const T& t) : T(t) { } ExtensibleItemClass(const T& t) : T(t) { }
}; };
/* Used to attach arbitrary objects to this object using unique keys */
class CoreExport Extensible class CoreExport Extensible
{ {
private: private:
@@ -33,7 +45,7 @@ class CoreExport Extensible
*/ */
Extensible() { } Extensible() { }
/** Default destructor, deletes all of the extensible items in this object /** Destructor, deletes all of the extensible items in this object
* then clears the map * then clears the map
*/ */
virtual ~Extensible() virtual ~Extensible()
-108
View File
@@ -1,108 +0,0 @@
/* Prototypes and external variable declarations.
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#ifndef EXTERN_H
#define EXTERN_H
#include "modes.h"
#define E extern CoreExport
#define EI extern DllExport
/**** actions.c ****/
E bool bad_password(User *u);
E void common_unban(const ChannelInfo *ci, User *u, bool full = false);
/**** encrypt.c ****/
E void enc_encrypt(const Anope::string &src, Anope::string &dest);
E bool enc_decrypt(const Anope::string &src, Anope::string &dest);
/**** init.c ****/
E Anope::string conf_dir, db_dir, modules_dir, locale_dir, log_dir;
E void introduce_user(const Anope::string &user);
E bool GetCommandLineArgument(const Anope::string &name, char shortname = 0);
E bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::string &param);
E bool AtTerm();
E void Fork();
E void Init(int ac, char **av);
/**** language.cpp ****/
E std::vector<Anope::string> languages;
E std::vector<Anope::string> domains;
E void InitLanguages();
E const char *translate(const char *string);
E const char *translate(User *u, const char *string);
E const char *translate(const NickCore *nc, const char *string);
E const char *anope_gettext(const char *lang, const char *string);
/**** main.c ****/
E Anope::string services_dir;
E Anope::string services_bin;
E int debug;
E bool readonly;
E bool nofork;
E bool nothird;
E bool noexpire;
E bool protocoldebug;
E bool quitting;
E int return_code;
E bool restarting;
E Anope::string quitmsg;
E time_t start_time;
E int CurrentUplink;
E void save_databases();
E void sighandler(int signum);
/**** misc.c ****/
E bool IsFile(const Anope::string &filename);
E time_t dotime(const Anope::string &s);
E Anope::string duration(const time_t &seconds, const NickCore *nc = NULL);
E Anope::string expire_left(const NickCore *nc, time_t expires);
E Anope::string do_strftime(const time_t &t, const NickCore *nc = NULL, bool short_output = false);
E bool IsValidIdent(const Anope::string &ident);
E bool IsValidHost(const Anope::string &host);
E Anope::string myStrGetToken(const Anope::string &str, char dilim, int token_number);
E Anope::string myStrGetTokenRemainder(const Anope::string &str, char dilim, int token_number);
E int myNumToken(const Anope::string &str, char dilim);
E bool nickIsServices(const Anope::string &nick, bool bot);
E std::list<Anope::string> BuildStringList(const Anope::string &, char = ' ');
E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' ');
E bool str_is_wildcard(const Anope::string &str);
E bool str_is_pure_wildcard(const Anope::string &str);
E Anope::string normalizeBuffer(const Anope::string &);
/**** modes.cpp ****/
/* Number of generic modes we support */
E unsigned GenericChannelModes, GenericUserModes;
E std::multimap<ChannelModeName, ModeLock *> def_mode_locks;
E void SetDefaultMLock(ServerConfig *config);
/**** process.c ****/
E void process(const Anope::string &buf);
#endif /* EXTERN_H */
+15 -15
View File
@@ -1,13 +1,10 @@
/* /*
*
* Copyright (C) 2002-2011 InspIRCd Development Team * Copyright (C) 2002-2011 InspIRCd Development Team
* Copyright (C) 2009-2012 Anope Team <team@anope.org> * Copyright (C) 2009-2012 Anope Team <team@anope.org>
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
* *
* These classes have been copied from InspIRCd and modified
* for use in Anope.
*
*
*/ */
#ifndef HASHCOMP_H #ifndef HASHCOMP_H
@@ -28,13 +25,15 @@ namespace Anope
{ {
class string; class string;
/* Casemap in use by Anope. ci::string's comparation functions use this (and thus Anope::string) */
extern std::locale casemap; extern std::locale casemap;
template<typename charT> /* ASCII case insensitive ctype. */
class ascii_ctype : public std::ctype<charT> template<typename char_type>
class ascii_ctype : public std::ctype<char_type>
{ {
public: public:
charT do_toupper(charT c) const anope_override char_type do_toupper(char_type c) const anope_override
{ {
if (c >= 'a' && c <= 'z') if (c >= 'a' && c <= 'z')
return c - 32; return c - 32;
@@ -42,7 +41,7 @@ namespace Anope
return c; return c;
} }
charT do_tolower(charT c) const anope_override char_type do_tolower(char_type c) const anope_override
{ {
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
return c + 32; return c + 32;
@@ -51,29 +50,30 @@ namespace Anope
} }
}; };
template<typename charT> /* rfc1459 case insensitive ctype, { = [, } = ], and | = \ */
class rfc1459_ctype : public ascii_ctype<charT> template<typename char_type>
class rfc1459_ctype : public ascii_ctype<char_type>
{ {
public: public:
charT do_toupper(charT c) const anope_override char_type do_toupper(char_type c) const anope_override
{ {
if (c == '{' || c == '}' || c == '|') if (c == '{' || c == '}' || c == '|')
return c - 32; return c - 32;
else else
return ascii_ctype<charT>::do_toupper(c); return ascii_ctype<char_type>::do_toupper(c);
} }
charT do_tolower(charT c) const anope_override char_type do_tolower(char_type c) const anope_override
{ {
if (c == '[' || c == ']' || c == '\\') if (c == '[' || c == ']' || c == '\\')
return c + 32; return c + 32;
else else
return ascii_ctype<charT>::do_tolower(c); return ascii_ctype<char_type>::do_tolower(c);
} }
}; };
} }
/** The ci namespace contains a number of helper classes. /** The ci namespace contains a number of helper classes relevant to case insensitive strings.
*/ */
namespace ci namespace ci
{ {
+57 -1
View File
@@ -1,11 +1,67 @@
/* Commonly used language strings /*
* *
* (C) 2008-2012 Anope Team * (C) 2008-2012 Anope Team
* Contact us at team@anope.org * Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
namespace Language
{
/* Languages we support as configured in services.conf. They are
* added to this list if we detect a language exists in the correct
* location for each language.
*/
extern std::vector<Anope::string> Languages;
/* Domains to search when looking for translations other than the
* default "anope domain. This is used by modules who add their own
* language files (and thus domains) to Anope. If a module is loaded
* and we detect a language file exists for at least one of the supported
* languages for the module, then we add the module's domain (its name)
* here.
*
* When strings are translated they are checked against all domains.
*/
extern std::vector<Anope::string> Domains;
/** Initialize the language system. Finds valid language files and
* populates the Languages list.
*/
extern void InitLanguages();
/** Translates a string to the default language.
* @param string A string to translate
* @return The translated string if found, else the original string.
*/
extern const char *Translate(const char *string);
/** Translates a string to the language of the given user.
* @param u The user to transate the string for
* @param string A string to translate
* @return The translated string if found, else the original string.
*/
extern const char *Translate(User *u, const char *string);
/** Translates a string to the language of the given account.
* @param nc The account to translate the string for
* @param string A string to translate
* @return The translated string if count, else the original string
*/
extern const char *Translate(const NickCore *nc, const char *string);
/** Translatesa string to the given language.
* @param lang The language to trnalsate to
* @param string The string to translate
* @return The translated string if found, else the original string.
*/
extern const char *Translate(const char *lang, const char *string);
} // namespace Language
/* Commonly used language strings */
#define MORE_INFO _("\002%s%s HELP %s\002 for more information.") #define MORE_INFO _("\002%s%s HELP %s\002 for more information.")
#define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.") #define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
#define BAD_EXPIRY_TIME _("Invalid expiry time.") #define BAD_EXPIRY_TIME _("Invalid expiry time.")
+5 -6
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef LISTS_H #ifndef LISTS_H
@@ -48,9 +47,9 @@ class CoreExport NumberList
void Process(); void Process();
/** Called with a number from the list /** Called with a number from the list
* @param Number The number * @param number The number
*/ */
virtual void HandleNumber(unsigned Number); virtual void HandleNumber(unsigned number);
/** Called when there is an error with the numbered list /** Called when there is an error with the numbered list
* Return false to immediatly stop processing the list and return * Return false to immediatly stop processing the list and return
@@ -71,9 +70,9 @@ class CoreExport ListFormatter
std::vector<Anope::string> columns; std::vector<Anope::string> columns;
std::vector<ListEntry> entries; std::vector<ListEntry> entries;
public: public:
ListFormatter &addColumn(const Anope::string &name); ListFormatter &AddColumn(const Anope::string &name);
void addEntry(const ListEntry &entry); void AddEntry(const ListEntry &entry);
bool isEmpty() const; bool IsEmpty() const;
void Process(std::vector<Anope::string> &); void Process(std::vector<Anope::string> &);
}; };
+33 -19
View File
@@ -18,8 +18,13 @@
enum LogType enum LogType
{ {
/* Used whenever an administrator uses an administrative comand */
LOG_ADMIN, LOG_ADMIN,
/* Used whenever an administrator overides something, such as adding
* access to a channel where they don't have permission to.
*/
LOG_OVERRIDE, LOG_OVERRIDE,
/* Any other command usage */
LOG_COMMAND, LOG_COMMAND,
LOG_SERVER, LOG_SERVER,
LOG_CHANNEL, LOG_CHANNEL,
@@ -37,30 +42,37 @@ enum LogType
struct LogFile struct LogFile
{ {
Anope::string filename; Anope::string filename;
public:
std::ofstream stream; std::ofstream stream;
LogFile(const Anope::string &name); LogFile(const Anope::string &name);
Anope::string GetName() const; Anope::string GetName() const;
}; };
/* Represents a single log message */
class CoreExport Log class CoreExport Log
{ {
public: public:
/* Bot that should log this message */
const BotInfo *bi; const BotInfo *bi;
/* For commands, the user executing the command */
Anope::string nick; Anope::string nick;
/* For commands, the user executing the command, but might not always exist */
const User *u; const User *u;
/* For commands, the account executing teh command, but will not always exist */
const NickCore *nc; const NickCore *nc;
/* For commands, the command being executed */
Command *c; Command *c;
/* Used for LOG_CHANNEL */
Channel *chan; Channel *chan;
/* For commands, the channel the command was executed on, will not always exist */
const ChannelInfo *ci; const ChannelInfo *ci;
/* For LOG_SERVER */
Server *s; Server *s;
/* For LOG_MODULE */
Module *m; Module *m;
LogType Type; LogType type;
Anope::string Category; Anope::string category;
std::list<Anope::string> Sources; std::list<Anope::string> sources;
std::stringstream buf; std::stringstream buf;
@@ -93,22 +105,23 @@ class CoreExport Log
} }
}; };
/* Configured in the configuration file, actually does the message logging */
class CoreExport LogInfo class CoreExport LogInfo
{ {
public: public:
std::list<Anope::string> Targets; std::list<Anope::string> targets;
std::map<Anope::string, LogFile *> Logfiles; std::map<Anope::string, LogFile *> logfiles;
std::list<Anope::string> Sources; std::list<Anope::string> sources;
int LogAge; int log_age;
std::list<Anope::string> Admin; std::list<Anope::string> admin;
std::list<Anope::string> Override; std::list<Anope::string> override;
std::list<Anope::string> Commands; std::list<Anope::string> commands;
std::list<Anope::string> Servers; std::list<Anope::string> servers;
std::list<Anope::string> Users; std::list<Anope::string> users;
std::list<Anope::string> Channels; std::list<Anope::string> channels;
std::list<Anope::string> Normal; std::list<Anope::string> normal;
bool RawIO; bool raw_io;
bool Debug; bool debug;
LogInfo(int logage, bool rawio, bool debug); LogInfo(int logage, bool rawio, bool debug);
@@ -118,6 +131,7 @@ class CoreExport LogInfo
bool HasType(LogType ltype, const Anope::string &type) const; bool HasType(LogType ltype, const Anope::string &type) const;
/* Logs the message l if configured to */
void ProcessMessage(const Log *l); void ProcessMessage(const Log *l);
}; };
+32 -19
View File
@@ -18,28 +18,41 @@
#include "threadengine.h" #include "threadengine.h"
#include "serialize.h" #include "serialize.h"
extern CoreExport bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message); namespace Mail
extern CoreExport bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message);
extern CoreExport bool MailValidate(const Anope::string &email);
class MailThread : public Thread
{ {
private: extern CoreExport bool Send(User *from, NickCore *to, const BotInfo *service, const Anope::string &subject, const Anope::string &message);
Anope::string SendMailPath; extern CoreExport bool Send(NickCore *to, const Anope::string &subject, const Anope::string &message);
Anope::string SendFrom; extern CoreExport bool Validate(const Anope::string &email);
Anope::string MailTo;
Anope::string Addr;
Anope::string Subject;
Anope::string Message;
bool DontQuoteAddresses;
bool Success; /* A email message being sent */
public: class Message : public Thread
MailThread(const Anope::string &smpath, const Anope::string &sf, const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message); {
private:
Anope::string sendmail_path;
Anope::string send_from;
Anope::string mail_to;
Anope::string addr;
Anope::string subject;
Anope::string message;
bool dont_quote_addresses;
~MailThread(); bool success;
public:
/** Construct this message. Once constructed call Thread::Start to launch the mail sending.
* @param sf Config->SendFrom
* @param mailto Name of person being mailed (u->nick, nc->display, etc)
* @param addr Destination address to mail
* @param subject Message subject
* @param message The actual message
*/
Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message);
void Run(); ~Message();
};
/* Called from within the thread to actually send the mail */
void Run() anope_override;
};
} // namespace Mail
#endif // MAIL_H #endif // MAIL_H
+8 -11
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef MEMO_H #ifndef MEMO_H
@@ -27,30 +26,28 @@ enum MemoFlag
MF_RECEIPT MF_RECEIPT
}; };
const Anope::string MemoFlagStrings[] = {
"MF_UNREAD", "MF_RECEIPT", ""
};
/* Memo info structures. Since both nicknames and channels can have memos,
* we encapsulate memo data in a MemoList to make it easier to handle. */
class CoreExport Memo : public Flags<MemoFlag>, public Serializable class CoreExport Memo : public Flags<MemoFlag>, public Serializable
{ {
public: public:
Memo(); Memo();
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string owner; Anope::string owner;
time_t time; /* When it was sent */ /* When it was sent */
time_t time;
Anope::string sender; Anope::string sender;
Anope::string text; Anope::string text;
}; };
/* Memo info structures. Since both nicknames and channels can have memos,
* we encapsulate memo data in a MemoInfo to make it easier to handle.
*/
struct CoreExport MemoInfo struct CoreExport MemoInfo
{ {
int16_t memomax; int16_t memomax;
serialize_checker<std::vector<Memo *> > memos; Serialize::Checker<std::vector<Memo *> > memos;
std::vector<Anope::string> ignores; std::vector<Anope::string> ignores;
MemoInfo(); MemoInfo();
+119 -84
View File
@@ -1,3 +1,15 @@
/*
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#include "protocol.h" #include "protocol.h"
/* Common IRCD messages. /* Common IRCD messages.
@@ -5,122 +17,145 @@
* as they see fit. * as they see fit.
*/ */
struct CoreExport CoreIRCDMessageAway : IRCDMessage namespace Message
{ {
CoreIRCDMessageAway(const Anope::string &mname = "AWAY") : IRCDMessage(mname, 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Away : IRCDMessage
}; {
Away(Module *creator, const Anope::string &mname = "AWAY") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageCapab : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageCapab(const Anope::string &mname = "CAPAB") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Capab : IRCDMessage
}; {
Capab(Module *creator, const Anope::string &mname = "CAPAB") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageError : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageError(const Anope::string &mname = "ERROR") : IRCDMessage(mname, 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Error : IRCDMessage
}; {
Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { }
struct CoreExport CoreIRCDMessageJoin : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageJoin(const Anope::string &mname = "JOIN") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Join : IRCDMessage
}; {
Join(Module *creator, const Anope::string &mname = "JOIN") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageKick : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{
CoreIRCDMessageKick(const Anope::string &mname = "KICK") : IRCDMessage(mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; typedef std::pair<ChannelStatus, User *> SJoinUser;
};
struct CoreExport CoreIRCDMessageKill : IRCDMessage /** Handle a SJOIN.
{ * @param source The source of the SJOIN
CoreIRCDMessageKill(const Anope::string &mname = "KILL") : IRCDMessage(mname, 2) { } * @param chan The channel the users are joining to
* @param ts The TS for the channel
* @param modes The modes sent with the SJOIN, if any
* @param users The users and their status, if any
*/
static void SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list<SJoinUser> &users);
};
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Kick : IRCDMessage
}; {
Kick(Module *creator, const Anope::string &mname = "KICK") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageMOTD : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageMOTD(const Anope::string &mname = "MOTD") : IRCDMessage(mname, 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Kill : IRCDMessage
}; {
Kill(Module *creator, const Anope::string &mname = "KILL") : IRCDMessage(creator, mname, 2) { }
struct CoreExport CoreIRCDMessagePart : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessagePart(const Anope::string &mname = "PART") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Mode : IRCDMessage
}; {
Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { }
struct CoreExport CoreIRCDMessagePing : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessagePing(const Anope::string &mname = "PING") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport MOTD : IRCDMessage
}; {
MOTD(Module *creator, const Anope::string &mname = "MOTD") : IRCDMessage(creator, mname, 1) { }
struct CoreExport CoreIRCDMessagePrivmsg : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessagePrivmsg(const Anope::string &mname = "PRIVMSG") : IRCDMessage(mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Part : IRCDMessage
}; {
Part(Module *creator, const Anope::string &mname = "PART") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageQuit : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageQuit(const Anope::string &mname = "QUIT") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Ping : IRCDMessage
}; {
Ping(Module *creator, const Anope::string &mname = "PPING") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageSQuit : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageSQuit(const Anope::string &mname = "SQUIT") : IRCDMessage(mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Privmsg : IRCDMessage
}; {
Privmsg(Module *creator, const Anope::string &mname = "PRIVMSG") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
struct CoreExport CoreIRCDMessageStats : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageStats(const Anope::string &mname = "STATS") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Quit : IRCDMessage
}; {
Quit(Module *creator, const Anope::string &mname = "QUIT") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
struct CoreExport CoreIRCDMessageTime : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageTime(const Anope::string &mname = "TIME") : IRCDMessage(mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport SQuit : IRCDMessage
}; {
SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
struct CoreExport CoreIRCDMessageTopic : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageTopic(const Anope::string &mname = "TOPIC") : IRCDMessage(mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Stats : IRCDMessage
}; {
Stats(Module *creator, const Anope::string &mname = "STATS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageVersion : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageVersion(const Anope::string &mname = "VERSION") : IRCDMessage(mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Time : IRCDMessage
}; {
Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
struct CoreExport CoreIRCDMessageWhois : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
{ };
CoreIRCDMessageWhois(const Anope::string &mname = "WHOIS") : IRCDMessage(mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override; struct CoreExport Topic : IRCDMessage
}; {
Topic(Module *creator, const Anope::string &mname = "TOPIC") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
struct CoreExport Version : IRCDMessage
{
Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
struct CoreExport Whois : IRCDMessage
{
Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
} // namespace Message
+104 -118
View File
@@ -27,18 +27,6 @@ enum UserModeName
UMODE_END UMODE_END
}; };
const Anope::string UserModeNameStrings[] = {
"UMODE_BEGIN",
"UMODE_SERV_ADMIN", "UMODE_BOT", "UMODE_CO_ADMIN", "UMODE_FILTER", "UMODE_HIDEOPER", "UMODE_NETADMIN",
"UMODE_REGPRIV", "UMODE_PROTECTED", "UMODE_NOCTCP", "UMODE_WEBTV", "UMODE_WEBIRC", "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_SOFTCALLERID", "UMODE_CALLERID",
"UMODE_COMMONCHANS", "UMODE_HIDDEN", "UMODE_STRIPCOLOR", "UMODE_INVISIBLE_OPER", "UMODE_RESTRICTED", "UMODE_HIDEIDLE",
""
};
/** All of the valid channel mode names /** All of the valid channel mode names
*/ */
enum ChannelModeName enum ChannelModeName
@@ -64,29 +52,6 @@ enum ChannelModeName
CMODE_END CMODE_END
}; };
const Anope::string ChannelModeNameStrings[] = {
"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", "CMODE_NICKFLOOD", "CMODE_JOINFLOOD", "CMODE_DELAYEDJOIN", "CMODE_NOREJOIN",
"CMODE_BANDWIDTH",
/* b/e/I */
"CMODE_BAN", "CMODE_EXCEPT",
"CMODE_INVITEOVERRIDE",
/* v/h/o/a/q */
"CMODE_VOICE", "CMODE_HALFOP", "CMODE_OP",
"CMODE_PROTECT", "CMODE_OWNER",
""
};
/** The different types of modes /** The different types of modes
*/ */
enum ModeType enum ModeType
@@ -105,9 +70,7 @@ enum ModeType
*/ */
enum ModeClass enum ModeClass
{ {
/* Channel mode */
MC_CHANNEL, MC_CHANNEL,
/* User mode */
MC_USER MC_USER
}; };
@@ -116,22 +79,19 @@ enum ModeClass
class CoreExport Mode : public Base class CoreExport Mode : public Base
{ {
public: public:
/* Class of mode this is */ /* Class of mode this is (user/channel) */
ModeClass Class; ModeClass mclass;
/* Mode char for this */ /* Mode char for this, eg 'b' */
char ModeChar; char mchar;
/* Type of mode this is */ /* Type of mode this is, eg MODE_LIST */
ModeType Type; ModeType type;
/** Default constructor /** constructor
* @param mClass The type of mode this is * @param mclass The type of mode this is
* @param modeChar The mode char * @param mc The mode char
* @param type The mode type * @param type The mode type
*/ */
Mode(ModeClass mClass, char modeChar, ModeType type); Mode(ModeClass mclass, char mc, ModeType type);
/** Default destructor
*/
virtual ~Mode(); virtual ~Mode();
}; };
@@ -141,16 +101,13 @@ class CoreExport UserMode : public Mode
{ {
public: public:
/* Mode name */ /* Mode name */
UserModeName Name; UserModeName name;
/** Default constructor /** constructor
* @param nName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
*/
UserMode(UserModeName mName, char modeChar);
/** Default destructor
*/ */
UserMode(UserModeName name, char mc);
virtual ~UserMode(); virtual ~UserMode();
/** Returns the mode name as a string /** Returns the mode name as a string
@@ -161,11 +118,11 @@ class CoreExport UserMode : public Mode
class CoreExport UserModeParam : public UserMode class CoreExport UserModeParam : public UserMode
{ {
public: public:
/** Default constructor /** constructor
* @param mName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
*/ */
UserModeParam(UserModeName mName, char modeChar); UserModeParam(UserModeName name, char mc);
/** Check if the param is valid /** Check if the param is valid
* @param value The param * @param value The param
@@ -180,16 +137,13 @@ class CoreExport ChannelMode : public Mode
{ {
public: public:
/* Mode name */ /* Mode name */
ChannelModeName Name; ChannelModeName name;
/** Default constructor /** constructor
* @param mName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
*/
ChannelMode(ChannelModeName mName, char modeChar);
/** Default destructor
*/ */
ChannelMode(ChannelModeName name, char mc);
virtual ~ChannelMode(); virtual ~ChannelMode();
/** Can a user set this mode, used for mlock /** Can a user set this mode, used for mlock
@@ -209,13 +163,13 @@ class CoreExport ChannelMode : public Mode
class CoreExport ChannelModeList : public ChannelMode class CoreExport ChannelModeList : public ChannelMode
{ {
public: public:
/** Default constructor /** constructor
* @param mName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
*/ */
ChannelModeList(ChannelModeName mName, char modeChar); ChannelModeList(ChannelModeName name, char mc);
/** Default destructor /** destructor
*/ */
virtual ~ChannelModeList(); virtual ~ChannelModeList();
@@ -251,19 +205,19 @@ class CoreExport ChannelModeList : public ChannelMode
class CoreExport ChannelModeParam : public ChannelMode class CoreExport ChannelModeParam : public ChannelMode
{ {
public: public:
/** Default constructor /** constructor
* @param mName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
* @param MinusArg true if this mode sends no arg when unsetting * @param minus_no_arg true if this mode sends no arg when unsetting
*/ */
ChannelModeParam(ChannelModeName mName, char modeChar, bool MinusArg = false); ChannelModeParam(ChannelModeName name, char mc, bool minus_no_arg = false);
/** Default destructor /** destructor
*/ */
virtual ~ChannelModeParam(); virtual ~ChannelModeParam();
/* Should we send an arg when unsetting this mode? */ /* Should we send an arg when unsetting this mode? */
bool MinusNoArg; bool minus_no_arg;
/** Is the param valid /** Is the param valid
* @param value The param * @param value The param
@@ -284,25 +238,33 @@ class CoreExport ChannelModeStatus : public ChannelMode
*/ */
unsigned short Level; unsigned short Level;
/** Default constructor /** constructor
* @param mName The mode name * @param name The mode name
* @param modeChar The mode char * @param mc The mode char
* @param mSymbol The symbol for the mode, eg @ % * @param mSymbol The symbol for the mode, eg @ %
* @param mLevel A level for the mode, which is usually determined by the PREFIX capab * @param mLevel A level for the mode, which is usually determined by the PREFIX capab
*/ */
ChannelModeStatus(ChannelModeName mName, char modeChar, char mSymbol, unsigned short mLevel = 0); ChannelModeStatus(ChannelModeName name, char mc, char mSymbol, unsigned short mLevel = 0);
/** Default destructor /** destructor
*/ */
virtual ~ChannelModeStatus(); virtual ~ChannelModeStatus();
}; };
/* The status a user has on a channel (+v, +h, +o) etc */
class CoreExport ChannelStatus : public Flags<ChannelModeName>
{
public:
Anope::string BuildCharPrefixList() const;
Anope::string BuildModePrefixList() const;
};
/** Channel mode +k (key) /** Channel mode +k (key)
*/ */
class CoreExport ChannelModeKey : public ChannelModeParam class CoreExport ChannelModeKey : public ChannelModeParam
{ {
public: public:
ChannelModeKey(char modeChar) : ChannelModeParam(CMODE_KEY, modeChar) { } ChannelModeKey(char mc) : ChannelModeParam(CMODE_KEY, mc) { }
bool IsValid(const Anope::string &value) const anope_override; bool IsValid(const Anope::string &value) const anope_override;
}; };
@@ -313,7 +275,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
class CoreExport ChannelModeAdmin : public ChannelMode class CoreExport ChannelModeAdmin : public ChannelMode
{ {
public: public:
ChannelModeAdmin(char modeChar) : ChannelMode(CMODE_ADMINONLY, modeChar) { } ChannelModeAdmin(char mc) : ChannelMode(CMODE_ADMINONLY, mc) { }
/* Opers only */ /* Opers only */
bool CanSet(User *u) const anope_override; bool CanSet(User *u) const anope_override;
@@ -325,7 +287,7 @@ class CoreExport ChannelModeAdmin : public ChannelMode
class CoreExport ChannelModeOper : public ChannelMode class CoreExport ChannelModeOper : public ChannelMode
{ {
public: public:
ChannelModeOper(char modeChar) : ChannelMode(CMODE_OPERONLY, modeChar) { } ChannelModeOper(char mc) : ChannelMode(CMODE_OPERONLY, mc) { }
/* Opers only */ /* Opers only */
bool CanSet(User *u) const anope_override; bool CanSet(User *u) const anope_override;
@@ -337,7 +299,7 @@ class CoreExport ChannelModeOper : public ChannelMode
class CoreExport ChannelModeRegistered : public ChannelMode class CoreExport ChannelModeRegistered : public ChannelMode
{ {
public: public:
ChannelModeRegistered(char modeChar) : ChannelMode(CMODE_REGISTERED, modeChar) { } ChannelModeRegistered(char mc) : ChannelMode(CMODE_REGISTERED, mc) { }
/* No one mlocks +r */ /* No one mlocks +r */
bool CanSet(User *u) const anope_override; bool CanSet(User *u) const anope_override;
@@ -355,17 +317,17 @@ class StackerInfo
/** Add a mode to this object /** Add a mode to this object
* @param mode The mode * @param mode The mode
* @param Set true if setting, false if unsetting * @param set true if setting, false if unsetting
* @param Param The param for the mode * @param param The param for the mode
*/ */
void AddMode(Mode *mode, bool Set, const Anope::string &Param); void AddMode(Mode *mode, bool set, const Anope::string &param);
}; };
/** This is mode manager /** This is the mode manager
* It contains functions for adding modes to Anope so Anope can track them * It contains functions for adding modes to Anope so Anope can track them
* and do things such as MLOCK. * and do things such as MLOCK.
* This also contains a mode stacker that will combine multiple modes and set * This also contains a mode stacker that will combine multiple modes and set
* them on a channel all at once * them on a channel or user at once
*/ */
class CoreExport ModeManager class CoreExport ModeManager
{ {
@@ -385,6 +347,13 @@ class CoreExport ModeManager
static std::vector<ChannelMode *> ChannelModes; static std::vector<ChannelMode *> ChannelModes;
static std::vector<UserMode *> UserModes; static std::vector<UserMode *> UserModes;
/* Number of generic channel and user modes we are tracking */
static unsigned GenericChannelModes, GenericUserModes;
/* Default channel mode lock */
static std::multimap<ChannelModeName, ModeLock *> DefaultModeLocks;
/* Default modes bots have on channels */
static ChannelStatus DefaultBotModes;
/** Add a user mode to Anope /** Add a user mode to Anope
* @param um A UserMode or UserMode derived class * @param um A UserMode or UserMode derived class
* @return true on success, false on error * @return true on success, false on error
@@ -397,29 +366,39 @@ class CoreExport ModeManager
*/ */
static bool AddChannelMode(ChannelMode *cm); static bool AddChannelMode(ChannelMode *cm);
/** Find a channel mode /** Remove a user mode from Anope
* @param Mode The mode * @param um A UserMode to remove
* @return The mode class
*/ */
static ChannelMode *FindChannelModeByChar(char Mode); static void RemoveUserMode(UserMode *um);
/** Find a user mode /** Remove a channel mode from Anope
* @param Mode The mode * @param um A ChanneMode to remove
* @return The mode class
*/ */
static UserMode *FindUserModeByChar(char Mode); static void RemoveChannelMode(ChannelMode *cm);
/** Find a channel mode /** Find a channel mode
* @param Mode The modename * @param mode The mode
* @return The mode class * @return The mode class
*/ */
static ChannelMode *FindChannelModeByName(ChannelModeName Name); static ChannelMode *FindChannelModeByChar(char mode);
/** Find a user mode /** Find a user mode
* @param Mode The modename * @param mode The mode
* @return The mode class * @return The mode class
*/ */
static UserMode *FindUserModeByName(UserModeName Name); static UserMode *FindUserModeByChar(char mode);
/** Find a channel mode
* @param name The modename
* @return The mode class
*/
static ChannelMode *FindChannelModeByName(ChannelModeName name);
/** Find a user mode
* @param name The modename
* @return The mode class
*/
static UserMode *FindUserModeByName(UserModeName name);
/** Find channel mode by string /** Find channel mode by string
* @param name The mode name * @param name The mode name
@@ -434,37 +413,44 @@ class CoreExport ModeManager
static UserMode *FindUserModeByString(const Anope::string &name); static UserMode *FindUserModeByString(const Anope::string &name);
/** Gets the channel mode char for a symbol (eg + returns v) /** Gets the channel mode char for a symbol (eg + returns v)
* @param Value The symbol * @param symbol The symbol
* @return The char * @return The char
*/ */
static char GetStatusChar(char Value); static char GetStatusChar(char symbol);
/** Add a mode to the stacker to be set on a channel /** Add a mode to the stacker to be set on a channel
* @param bi The client to set the modes from * @param bi The client to set the modes from
* @param c The channel * @param c The channel
* @param cm The channel mode * @param cm The channel mode
* @param Set true for setting, false for removing * @param set true for setting, false for removing
* @param Param The param, if there is one * @param param The param, if there is one
*/ */
static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = ""); static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string &param = "");
/** Add a mode to the stacker to be set on a user /** Add a mode to the stacker to be set on a user
* @param bi The client to set the modes from * @param bi The client to set the modes from
* @param u The user * @param u The user
* @param um The user mode * @param um The user mode
* @param Set true for setting, false for removing * @param set true for setting, false for removing
* @param param The param, if there is one * @param param The param, if there is one
*/ */
static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = ""); static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool set, const Anope::string &param = "");
/** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users
*/ */
static void ProcessModes(); static void ProcessModes();
/** Delete a user or channel from the stacker /** Delete a user, channel, or mode from the stacker
*/ */
static void StackerDel(User *u); static void StackerDel(User *u);
static void StackerDel(Channel *c); static void StackerDel(Channel *c);
static void StackerDel(Mode *m);
/** Updates the default mode locks and default bot modes
* @param config The configuration to read from. This is often called
* during a config reload.
*/
static void UpdateDefaultMLock(ServerConfig *config);
}; };
/** Entry flags /** Entry flags
@@ -493,10 +479,10 @@ class CoreExport Entry : public Flags<EntryType>
Anope::string nick, user, host; Anope::string nick, user, host;
/** Constructor /** Constructor
* @param _host A full nick!ident@host/cidr mask
* @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode * @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode
* @param host A full nick!ident@host/cidr mask
*/ */
Entry(ChannelModeName mode, const Anope::string &_host); Entry(ChannelModeName mode, const Anope::string &host);
/** Get the banned mask for this entry /** Get the banned mask for this entry
* @return The mask * @return The mask
+5 -3
View File
@@ -18,13 +18,11 @@
#include "anope.h" #include "anope.h"
#include "base.h" #include "base.h"
#include "bots.h" #include "bots.h"
#include "botserv.h"
#include "channels.h" #include "channels.h"
#include "commands.h" #include "commands.h"
#include "config.h" #include "config.h"
#include "dns.h" #include "dns.h"
#include "extensible.h" #include "extensible.h"
#include "extern.h"
#include "hashcomp.h" #include "hashcomp.h"
#include "language.h" #include "language.h"
#include "lists.h" #include "lists.h"
@@ -34,7 +32,6 @@
#include "messages.h" #include "messages.h"
#include "modes.h" #include "modes.h"
#include "modules.h" #include "modules.h"
#include "oper.h"
#include "opertype.h" #include "opertype.h"
#include "protocol.h" #include "protocol.h"
#include "regexpr.h" #include "regexpr.h"
@@ -50,9 +47,14 @@
#include "timers.h" #include "timers.h"
#include "uplink.h" #include "uplink.h"
#include "users.h" #include "users.h"
#include "xline.h"
#include "chanserv.h"
#include "botserv.h"
#include "global.h" #include "global.h"
#include "hostserv.h"
#include "memoserv.h" #include "memoserv.h"
#include "nickserv.h" #include "nickserv.h"
#include "operserv.h"
#endif // MODULE_H #endif // MODULE_H
+42 -32
View File
@@ -7,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#include "serialize.h" #include "serialize.h"
@@ -31,7 +32,7 @@
{ \ { \
return new x(modname, creator); \ return new x(modname, creator); \
} \ } \
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \ BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
{ \ { \
return TRUE; \ return TRUE; \
} \ } \
@@ -120,7 +121,6 @@ enum EventReturn
EVENT_ALLOW EVENT_ALLOW
}; };
enum ModuleReturn enum ModuleReturn
{ {
MOD_ERR_OK, MOD_ERR_OK,
@@ -141,26 +141,23 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR
/* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */ /* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */
enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END }; enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END };
extern CoreExport std::list<Module *> Modules; /** Returned by Module::GetVersion, used to see what version of Anope
* a module is compiled against.
*/
class ModuleVersion class ModuleVersion
{ {
private: private:
int Major; int version_major;
int Minor; int version_minor;
int Patch; int version_patch;
public: public:
/** Constructor /** Constructor
* @param vMajor The major version numbber * @param major The major version numbber
* @param vMinor The minor version numbber * @param minor The minor version numbber
* @param vPatch The patch version numbber * @param patch The patch version numbber
*/ */
ModuleVersion(int vMajor, int vMinor, int vPatch); ModuleVersion(int major, int minor, int patch);
/** Destructor
*/
virtual ~ModuleVersion();
/** Get the major version of Anope this was built against /** Get the major version of Anope this was built against
* @return The major version * @return The major version
@@ -200,7 +197,7 @@ class CoreExport Module : public Extensible
/** Callbacks used in this module /** Callbacks used in this module
*/ */
std::list<CallBack *> CallBacks; std::list<CallBack *> callbacks;
/** Handle for this module, obtained from dlopen() /** Handle for this module, obtained from dlopen()
*/ */
@@ -259,6 +256,14 @@ class CoreExport Module : public Extensible
*/ */
ModuleVersion GetVersion() const; ModuleVersion GetVersion() const;
/** Gets the IRCd protocol published by this module
*/
virtual IRCDProto *GetIRCDProto();
/* Everything below here are events. Modules must ModuleManager::Attach to these events
* before they will be called.
*/
/** Called when the ircd notifies that a user has been kicked from a channel. /** Called when the ircd notifies that a user has been kicked from a channel.
* @param c The channel the user has been kicked from. * @param c The channel the user has been kicked from.
* @param target The user that has been kicked. * @param target The user that has been kicked.
@@ -290,7 +295,7 @@ class CoreExport Module : public Extensible
* @param u The connecting user. * @param u The connecting user.
* @param exempt set to true/is true if the user should be excepted from bans etc * @param exempt set to true/is true if the user should be excepted from bans etc
*/ */
virtual void OnUserConnect(dynamic_reference<User> &u, bool &exempt) { } virtual void OnUserConnect(Reference<User> &u, bool &exempt) { }
/** Called when a new server connects to the network. /** Called when a new server connects to the network.
* @param s The server that has connected to the network * @param s The server that has connected to the network
@@ -649,9 +654,9 @@ class CoreExport Module : public Extensible
* @param source The user requesting info * @param source The user requesting info
* @param ci The channel the user is requesting info for * @param ci The channel the user is requesting info for
* @param info Data to show the user requesting information * @param info Data to show the user requesting information
* @param ShowHidden true if we should show the user everything * @param show_hidden true if we should show the user everything
*/ */
virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) { } virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) { }
/** Checks if access has the channel privilege 'priv'. /** Checks if access has the channel privilege 'priv'.
* @param access THe access struct * @param access THe access struct
@@ -763,9 +768,9 @@ class CoreExport Module : public Extensible
* @param source The user requesting info * @param source The user requesting info
* @param na The nick the user is requesting info from * @param na The nick the user is requesting info from
* @param info Data to show the user requesting information * @param info Data to show the user requesting information
* @param ShowHidden true if we should show the user everything * @param show_hidden true if we should show the user everything
*/ */
virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) { } virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) { }
/** Check whether a username and password is correct /** Check whether a username and password is correct
* @param u The user trying to identify, if applicable. * @param u The user trying to identify, if applicable.
@@ -824,32 +829,32 @@ class CoreExport Module : public Extensible
/** Called when a mode is set on a channel /** Called when a mode is set on a channel
* @param c The channel * @param c The channel
* @param setter The user or server that is setting the mode * @param setter The user or server that is setting the mode
* @param Name The mode name * @param mname The mode name
* @param param The mode param, if there is one * @param param The mode param, if there is one
* @return EVENT_STOP to make mlock/secureops etc checks not happen * @return EVENT_STOP to make mlock/secureops etc checks not happen
*/ */
virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelModeName Name, const Anope::string &param) { return EVENT_CONTINUE; } virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelModeName mname, const Anope::string &param) { return EVENT_CONTINUE; }
/** Called when a mode is unset on a channel /** Called when a mode is unset on a channel
* @param c The channel * @param c The channel
* @param setter The user or server that is unsetting the mode * @param setter The user or server that is unsetting the mode
* @param Name The mode name * @param mname The mode name
* @param param The mode param, if there is one * @param param The mode param, if there is one
* @return EVENT_STOP to make mlock/secureops etc checks not happen * @return EVENT_STOP to make mlock/secureops etc checks not happen
*/ */
virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelModeName Name, const Anope::string &param) { return EVENT_CONTINUE; } virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelModeName mname, const Anope::string &param) { return EVENT_CONTINUE; }
/** Called when a mode is set on a user /** Called when a mode is set on a user
* @param u The user * @param u The user
* @param Name The mode name * @param mname The mode name
*/ */
virtual void OnUserModeSet(User *u, UserModeName Name) { } virtual void OnUserModeSet(User *u, UserModeName mname) { }
/** Called when a mode is unset from a user /** Called when a mode is unset from a user
* @param u The user * @param u The user
* @param Name The mode name * @param mname The mode name
*/ */
virtual void OnUserModeUnset(User *u, UserModeName Name) { } virtual void OnUserModeUnset(User *u, UserModeName mname) { }
/** Called when a channel mode is introducted into Anope /** Called when a channel mode is introducted into Anope
* @param cm The mode * @param cm The mode
@@ -921,7 +926,7 @@ class CoreExport Module : public Extensible
* @param req The dns request * @param req The dns request
* @param reply The reply that will be sent * @param reply The reply that will be sent
*/ */
virtual void OnDnsRequest(DNSPacket &req, DNSPacket *reply) { } virtual void OnDnsRequest(DNS::Packet &req, DNS::Packet *reply) { }
/** Called when a channels modes are being checked to see if they are allowed, /** Called when a channels modes are being checked to see if they are allowed,
* mostly to ensure mlock/+r are set. * mostly to ensure mlock/+r are set.
@@ -930,7 +935,7 @@ class CoreExport Module : public Extensible
*/ */
virtual EventReturn OnCheckModes(Channel *c) { return EVENT_CONTINUE; } virtual EventReturn OnCheckModes(Channel *c) { return EVENT_CONTINUE; }
virtual void OnSerializeCheck(SerializeType *) { } virtual void OnSerializeCheck(Serialize::Type *) { }
virtual void OnSerializableConstruct(Serializable *) { } virtual void OnSerializableConstruct(Serializable *) { }
virtual void OnSerializableDestruct(Serializable *) { } virtual void OnSerializableDestruct(Serializable *) { }
virtual void OnSerializableUpdate(Serializable *) { } virtual void OnSerializableUpdate(Serializable *) { }
@@ -1012,6 +1017,10 @@ enum Implementation
class CoreExport ModuleManager class CoreExport ModuleManager
{ {
public: public:
/** List of all modules loaded in Anope
*/
static CoreExport std::list<Module *> Modules;
/** Event handler hooks. /** Event handler hooks.
* This needs to be public to be used by FOREACH_MOD and friends. * This needs to be public to be used by FOREACH_MOD and friends.
*/ */
@@ -1124,7 +1133,8 @@ class CoreExport ModuleManager
static ModuleReturn DeleteModule(Module *m); static ModuleReturn DeleteModule(Module *m);
}; };
/** Class used for callbacks within modules /** Class used for callbacks within modules. These are identical to Timers hwoever
* they will be cleaned up automatically when a module is unloaded, and Timers will not.
*/ */
class CoreExport CallBack : public Timer class CoreExport CallBack : public Timer
{ {
+9 -1
View File
@@ -3,6 +3,7 @@
* Copyright (C) 2008-2012 Anope Team <team@anope.org> * Copyright (C) 2008-2012 Anope Team <team@anope.org>
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef OPERTYPE_H #ifndef OPERTYPE_H
@@ -11,15 +12,22 @@
#include "services.h" #include "services.h"
#include "account.h" #include "account.h"
/* A services operator. Usually made by the configuration file, but not always.
* NickAlias::Find(name)->nc->o == this
*/
struct CoreExport Oper struct CoreExport Oper
{ {
/* The oper's nick */
Anope::string name; Anope::string name;
/* The type of operator this operator is */
OperType *ot; OperType *ot;
/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
bool require_oper; bool require_oper;
Anope::string password; Anope::string password;
Anope::string certfp; Anope::string certfp;
/* True if this operator is set in the config */
bool config; bool config;
/* Hosts allowed to use this operator block */
std::vector<Anope::string> hosts; std::vector<Anope::string> hosts;
Anope::string vhost; Anope::string vhost;
+114 -32
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef PROTOCOL_H #ifndef PROTOCOL_H
@@ -16,14 +15,17 @@
#include "services.h" #include "services.h"
#include "anope.h" #include "anope.h"
#include "service.h"
/* Encapsultes the IRCd protocol we are speaking. */
class CoreExport IRCDProto class CoreExport IRCDProto
{ {
Anope::string proto_name; Anope::string proto_name;
IRCDProto() { }
protected: protected:
IRCDProto(const Anope::string &proto_name); IRCDProto(const Anope::string &proto_name);
public:
virtual ~IRCDProto();
virtual void SendSVSKillInternal(const BotInfo *, User *, const Anope::string &); virtual void SendSVSKillInternal(const BotInfo *, User *, const Anope::string &);
virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &); virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &);
@@ -37,8 +39,6 @@ class CoreExport IRCDProto
virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf); virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf); virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf); virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf);
public:
virtual ~IRCDProto();
const Anope::string &GetProtocolName(); const Anope::string &GetProtocolName();
/* Modes used by default by our clients */ /* Modes used by default by our clients */
@@ -66,53 +66,135 @@ class CoreExport IRCDProto
/* The maximum number of modes we are allowed to set with one MODE command */ /* The maximum number of modes we are allowed to set with one MODE command */
unsigned MaxModes; unsigned MaxModes;
virtual void SendSVSNOOP(const Server *, bool) { } /** Sets the server in NOOP mode. If NOOP mode is enabled, no users
* will be able to oper on the server.
* @param s The server
* @param mode Whether to turn NOOP on or off
*/
virtual void SendSVSNOOP(const Server *s, bool mode) { }
/** Sets the topic on a channel
* @param bi The bot to set the topic from
* @param c The channel to set the topic on. The topic being set is Channel::topic
*/
virtual void SendTopic(BotInfo *, Channel *); virtual void SendTopic(BotInfo *, Channel *);
/** Sets a vhost on a user.
* @param u The user
* @param vident The ident to set
* @param vhost The vhost to set
*/
virtual void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost) { }
virtual void SendVhostDel(User *) { } virtual void SendVhostDel(User *) { }
/** Sets an akill. This is a recursive function that can be called multiple times
* for the same xline, but for different users, if the xline is not one that can be
* enforced by the IRCd, such as a nick/user/host/realname combination ban.
* @param u The user affected by the akill, if known
* @param x The akill
*/
virtual void SendAkill(User *, XLine *) = 0; virtual void SendAkill(User *, XLine *) = 0;
virtual void SendAkillDel(const XLine *) = 0; virtual void SendAkillDel(const XLine *) = 0;
/* Realname ban */
virtual void SendSGLine(User *, const XLine *) { }
virtual void SendSGLineDel(const XLine *) { }
/* IP ban */
virtual void SendSZLine(User *u, const XLine *) { }
virtual void SendSZLineDel(const XLine *) { }
/* Nick ban (and sometimes channel) */
virtual void SendSQLine(User *, const XLine *x) { }
virtual void SendSQLineDel(const XLine *x) { }
/** Kills a user
* @param source The client used to kill the user, if any
* @param user The user to be killed
* @param fmt Kill reason
*/
virtual void SendSVSKill(const BotInfo *source, User *user, const char *fmt, ...); virtual void SendSVSKill(const BotInfo *source, User *user, const char *fmt, ...);
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...); virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...); virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
/** Introduces a client to the rest of the network
* @param u The client to introduce
*/
virtual void SendClientIntroduction(const User *u) = 0; virtual void SendClientIntroduction(const User *u) = 0;
virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...); virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
/* Sends a message using SendPrivmsg or SendNotice, depending on the default message method. */
virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) = 0; virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) = 0;
virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg) = 0; virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
virtual void SendQuit(const User *u, const char *fmt, ...); virtual void SendQuit(const User *u, const char *fmt, ...);
virtual void SendPing(const Anope::string &servname, const Anope::string &who); virtual void SendPing(const Anope::string &servname, const Anope::string &who);
virtual void SendPong(const Anope::string &servname, const Anope::string &who); virtual void SendPong(const Anope::string &servname, const Anope::string &who);
virtual void SendJoin(const User *, Channel *, const ChannelStatus *) = 0;
virtual void SendSQLineDel(const XLine *x) { } /** Joins one of our users to a channel.
virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u); * @param u The user to join
* @param c The channel to join the user to
* @param status The status to set on the user after joining. This may or may not already internally
* be set on the user. This may include the modes in the join, but will usually place them on the mode
* stacker to be set "soon".
*/
virtual void SendJoin(const User *u, Channel *c, const ChannelStatus *status) = 0;
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...); virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
/** Force joins a user that isn't ours to a channel.
* @param bi The source of the message
* @param nick The user to join
* @param chan The channel to join the user to
* @param param Channel key?
*/
virtual void SendSVSJoin(const BotInfo *bi, const Anope::string &nick, const Anope::string &chan, const Anope::string &param) { }
virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u);
virtual void SendGlobops(const BotInfo *source, const char *fmt, ...); virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
virtual void SendSQLine(User *, const XLine *x) { }
virtual void SendSquit(Server *, const Anope::string &message); /** Sets oper flags on a user, currently only supported by Unreal
*/
virtual void SendSVSO(const BotInfo *, const Anope::string &, const Anope::string &) { } virtual void SendSVSO(const BotInfo *, const Anope::string &, const Anope::string &) { }
virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
/** Sends a nick change of one of our clients.
*/
virtual void SendNickChange(const User *u, const Anope::string &newnick);
/** Forces a nick change of a user that isn't ours (SVSNICK)
*/
virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when); virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
/** Used to introduce ourselves to our uplink. Usually will SendServer(Me) and any other
* initial handshake requirements.
*/
virtual void SendConnect() = 0; virtual void SendConnect() = 0;
virtual void SendSVSHold(const Anope::string &) { }
virtual void SendSVSHoldDel(const Anope::string &) { } /** Called right before we begin our burst, after we have handshaked successfully with the uplink/
virtual void SendSGLineDel(const XLine *) { } * At this point none of our servesr, users, or channels exist on the uplink
virtual void SendSZLineDel(const XLine *) { } */
virtual void SendSZLine(User *u, const XLine *) { }
virtual void SendSGLine(User *, const XLine *) { }
virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
virtual void SendSVSJoin(const BotInfo *bi, const Anope::string &, const Anope::string &, const Anope::string &) { }
virtual void SendSWhois(const BotInfo *bi, const Anope::string &, const Anope::string &) { }
virtual void SendBOB() { } virtual void SendBOB() { }
virtual void SendEOB() { } virtual void SendEOB() { }
virtual void SendSVSHold(const Anope::string &) { }
virtual void SendSVSHoldDel(const Anope::string &) { }
virtual void SendSWhois(const BotInfo *bi, const Anope::string &, const Anope::string &) { }
/** Introduces a server to the uplink
*/
virtual void SendServer(const Server *) = 0; virtual void SendServer(const Server *) = 0;
virtual bool IsNickValid(const Anope::string &) { return true; } virtual void SendSquit(Server *, const Anope::string &message);
virtual bool IsChannelValid(const Anope::string &);
virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...); virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
virtual void SendLogin(User *u) = 0; virtual void SendLogin(User *u) = 0;
virtual void SendLogout(User *u) = 0; virtual void SendLogout(User *u) = 0;
@@ -125,6 +207,11 @@ class CoreExport IRCDProto
* Normally this is a simple +o, though some IRCds require us to send the oper type * Normally this is a simple +o, though some IRCds require us to send the oper type
*/ */
virtual void SendOper(User *u); virtual void SendOper(User *u);
virtual bool IsNickValid(const Anope::string &);
virtual bool IsChannelValid(const Anope::string &);
virtual bool IsIdentValid(const Anope::string &);
virtual bool IsHostValid(const Anope::string &);
}; };
enum IRCDMessageFlag enum IRCDMessageFlag
@@ -150,21 +237,16 @@ class CoreExport MessageSource
Server *GetServer(); Server *GetServer();
}; };
class CoreExport IRCDMessage : public Flags<IRCDMessageFlag, 3> class CoreExport IRCDMessage : public Flags<IRCDMessageFlag>, public Service
{ {
static std::map<Anope::string, std::vector<IRCDMessage *> > messages;
Anope::string name; Anope::string name;
unsigned param_count; unsigned param_count;
public: public:
static const std::vector<IRCDMessage *> *Find(const Anope::string &name); IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
IRCDMessage(const Anope::string &n, unsigned p = 0);
~IRCDMessage();
unsigned GetParamCount() const; unsigned GetParamCount() const;
virtual bool Run(MessageSource &, const std::vector<Anope::string> &params) = 0; virtual bool Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
}; };
extern CoreExport IRCDProto *ircdproto; extern CoreExport IRCDProto *IRCD;
#endif // PROTOCOL_H #endif // PROTOCOL_H
+124 -64
View File
@@ -1,15 +1,15 @@
/* Modular support /*
* *
* (C) 2008-2012 Anope Team * (C) 2008-2012 Anope Team
* Contact us at team@anope.org * Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef REGCHANNEL_H #ifndef REGCHANNEL_H
#define REGCHANNEL_H #define REGCHANNEL_H
#include "botserv.h"
#include "memo.h" #include "memo.h"
#include "modes.h" #include "modes.h"
#include "extensible.h" #include "extensible.h"
@@ -20,7 +20,7 @@
typedef Anope::hash_map<ChannelInfo *> registered_channel_map; typedef Anope::hash_map<ChannelInfo *> registered_channel_map;
extern CoreExport serialize_checker<registered_channel_map> RegisteredChannelList; extern CoreExport Serialize::Checker<registered_channel_map> RegisteredChannelList;
/** Flags used for the ChannelInfo class /** Flags used for the ChannelInfo class
*/ */
@@ -68,10 +68,57 @@ enum ChannelInfoFlag
CI_END CI_END
}; };
const Anope::string ChannelInfoFlagStrings[] = { /* BotServ SET flags (ChannelInfo::botflags) */
"BEGIN", "KEEPTOPIC", "SECUREOPS", "PRIVATE", "TOPICLOCK", "RESTRICTED", enum BotServFlag
"PEACE", "SECURE", "NO_EXPIRE", "MEMO_HARDMAX", "SECUREFOUNDER", {
"SIGNKICK", "SIGNKICK_LEVEL", "SUSPENDED", "PERSIST", "STATS", "NOAUTOOP", "" BS_BEGIN,
/* BotServ won't kick ops */
BS_DONTKICKOPS,
/* BotServ won't kick voices */
BS_DONTKICKVOICES,
/* BotServ bot accepts fantasy commands */
BS_FANTASY,
/* BotServ should show greets */
BS_GREET,
/* BotServ bots are not allowed to be in this channel */
BS_NOBOT,
/* BotServ kicks for bolds */
BS_KICK_BOLDS,
/* BotServ kicks for colors */
BS_KICK_COLORS,
/* BOtServ kicks for reverses */
BS_KICK_REVERSES,
/* BotServ kicks for underlines */
BS_KICK_UNDERLINES,
/* BotServ kicks for badwords */
BS_KICK_BADWORDS,
/* BotServ kicks for caps */
BS_KICK_CAPS,
/* BotServ kicks for flood */
BS_KICK_FLOOD,
/* BotServ kicks for repeating */
BS_KICK_REPEAT,
/* BotServ kicks for italics */
BS_KICK_ITALICS,
/* BotServ kicks for amsgs */
BS_KICK_AMSGS,
BS_END
};
/* Indices for TTB (Times To Ban) */
enum
{
TTB_BOLDS,
TTB_COLORS,
TTB_REVERSES,
TTB_UNDERLINES,
TTB_BADWORDS,
TTB_CAPS,
TTB_FLOOD,
TTB_REPEAT,
TTB_ITALICS,
TTB_AMSGS,
TTB_SIZE
}; };
/** Flags for badwords /** Flags for badwords
@@ -96,8 +143,8 @@ struct CoreExport BadWord : Serializable
BadWordType type; BadWordType type;
BadWord() : Serializable("BadWord") { } BadWord() : Serializable("BadWord") { }
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
}; };
/** Flags for auto kick /** Flags for auto kick
@@ -108,31 +155,31 @@ enum AutoKickFlag
AK_ISNICK AK_ISNICK
}; };
const Anope::string AutoKickFlagString[] = { "AK_ISNICK", "" };
/* AutoKick data. */ /* AutoKick data. */
class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable
{ {
public: public:
AutoKick(); /* Channel this autokick is on */
serialize_obj<ChannelInfo> ci; Serialize::Reference<ChannelInfo> ci;
/* Only one of these can be in use */
/* Only one of these can be in use. if HasFlag(AK_ISNICK) then nc is in use */
Anope::string mask; Anope::string mask;
serialize_obj<NickCore> nc; Serialize::Reference<NickCore> nc;
Anope::string reason; Anope::string reason;
Anope::string creator; Anope::string creator;
time_t addtime; time_t addtime;
time_t last_used; time_t last_used;
Serialize::Data serialize() const anope_override; AutoKick();
static Serializable* unserialize(Serializable *obj, Serialize::Data &); Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
}; };
struct CoreExport ModeLock : Serializable struct CoreExport ModeLock : Serializable
{ {
public: public:
serialize_obj<ChannelInfo> ci; Serialize::Reference<ChannelInfo> ci;
bool set; bool set;
ChannelModeName name; ChannelModeName name;
Anope::string param; Anope::string param;
@@ -141,13 +188,13 @@ struct CoreExport ModeLock : Serializable
ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime); ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime);
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
}; };
struct CoreExport LogSetting : Serializable struct CoreExport LogSetting : Serializable
{ {
serialize_obj<ChannelInfo> ci; Serialize::Reference<ChannelInfo> ci;
/* Our service name of the command */ /* Our service name of the command */
Anope::string service_name; Anope::string service_name;
/* The name of the client the command is on */ /* The name of the client the command is on */
@@ -159,26 +206,52 @@ struct CoreExport LogSetting : Serializable
time_t created; time_t created;
LogSetting() : Serializable("LogSetting") { } LogSetting() : Serializable("LogSetting") { }
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &); static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
}; };
/* It matters that Base is here before Extensible (it is inherited by Serializable) */ /* It matters that Base is here before Extensible (it is inherited by Serializable) */
class CoreExport ChannelInfo : public Serializable, public Extensible, public Flags<ChannelInfoFlag, CI_END> class CoreExport ChannelInfo : public Serializable, public Extensible, public Flags<ChannelInfoFlag>
{ {
private: private:
serialize_obj<NickCore> founder; /* Channel founder */ Serialize::Reference<NickCore> founder; /* Channel founder */
serialize_checker<std::vector<ChanAccess *> > access; /* List of authorized users */ Serialize::Checker<std::vector<ChanAccess *> > access; /* List of authorized users */
serialize_checker<std::vector<AutoKick *> > akick; /* List of users to kickban */ Serialize::Checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
serialize_checker<std::vector<BadWord *> > badwords; /* List of badwords */ Serialize::Checker<std::vector<BadWord *> > badwords; /* List of badwords */
std::map<Anope::string, int16_t> levels; std::map<Anope::string, int16_t> levels;
public: public:
typedef std::multimap<ChannelModeName, ModeLock *> ModeList; typedef std::multimap<ChannelModeName, ModeLock *> ModeList;
serialize_checker<ModeList> mode_locks; Serialize::Checker<ModeList> mode_locks;
serialize_checker<std::vector<LogSetting *> > log_settings; Serialize::Checker<std::vector<LogSetting *> > log_settings;
/** Default constructor Anope::string name; /* Channel name */
Serialize::Reference<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
Anope::string desc;
time_t time_registered;
time_t last_used;
Anope::string last_topic; /* The last topic that was set on this channel */
Anope::string last_topic_setter; /* Setter */
time_t last_topic_time; /* Time */
int16_t bantype;
MemoInfo memos;
Channel *c; /* Pointer to channel, if the channel exists */
/* For BotServ */
Serialize::Reference<BotInfo> bi; /* Bot used on this channel */
Flags<BotServFlag> botflags;
int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
int16_t capsmin, capspercent; /* For CAPS kicker */
int16_t floodlines, floodsecs; /* For FLOOD kicker */
int16_t repeattimes; /* For REPEAT kicker */
/** Constructor
* @param chname The channel name * @param chname The channel name
*/ */
ChannelInfo(const Anope::string &chname); ChannelInfo(const Anope::string &chname);
@@ -188,38 +261,10 @@ class CoreExport ChannelInfo : public Serializable, public Extensible, public Fl
*/ */
ChannelInfo(const ChannelInfo &ci); ChannelInfo(const ChannelInfo &ci);
/** Default destructor
*/
~ChannelInfo(); ~ChannelInfo();
Anope::string name; /* Channel name */ Serialize::Data Serialize() const anope_override;
serialize_obj<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */ static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string desc;
time_t time_registered;
time_t last_used;
Anope::string last_topic; /* The last topic that was set on this channel */
Anope::string last_topic_setter; /* Setter */
time_t last_topic_time; /* Time */
int16_t bantype;
MemoInfo memos;
Channel *c; /* Pointer to channel record (if channel is currently in use) */
/* For BotServ */
serialize_obj<BotInfo> bi; /* Bot used on this channel */
Flags<BotServFlag> botflags;
int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
int16_t capsmin, capspercent; /* For CAPS kicker */
int16_t floodlines, floodsecs; /* For FLOOD kicker */
int16_t repeattimes; /* For REPEAT kicker */
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
/** Change the founder of the channek /** Change the founder of the channek
* @params nc The new founder * @params nc The new founder
@@ -440,11 +485,26 @@ class CoreExport ChannelInfo : public Serializable, public Extensible, public Fl
/** Clear all privileges from the channel /** Clear all privileges from the channel
*/ */
void ClearLevels(); void ClearLevels();
/** Gets a ban mask for the given user based on the bantype
* of the channel.
* @param u The user
* @return A ban mask that affects the user
*/
Anope::string GetIdealBan(User *u) const;
/** Finds a ChannelInfo
* @param name channel name to lookup
* @return the ChannelInfo associated with the channel
*/
static ChannelInfo* Find(const Anope::string &name);
}; };
extern CoreExport ChannelInfo *cs_findchan(const Anope::string &chan); /** Is the user the real founder?
* @param user The user
* @param ci The channel
* @return true or false
*/
extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci); extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
extern CoreExport void update_cs_lastseen(User *user, ChannelInfo *ci);
extern CoreExport int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
#endif // REGCHANNEL_H #endif // REGCHANNEL_H
+119 -57
View File
@@ -25,54 +25,65 @@ namespace Serialize
DT_TEXT, DT_TEXT,
DT_INT DT_INT
}; };
}
class CoreExport stringstream : public std::stringstream class CoreExport stringstream : public std::stringstream
{
private:
Serialize::DataType type;
unsigned _max;
public:
stringstream();
stringstream(const stringstream &ss);
Anope::string astr() const;
template<typename T> std::istream &operator>>(T &val)
{ {
std::istringstream is(this->str()); private:
is >> val; Serialize::DataType type;
return *this; unsigned _max;
}
std::istream &operator>>(Anope::string &val);
bool operator==(const stringstream &other) const; public:
bool operator!=(const stringstream &other) const; stringstream();
stringstream(const stringstream &ss);
Anope::string astr() const;
stringstream &setType(Serialize::DataType t); template<typename T> std::istream &operator>>(T &val)
Serialize::DataType getType() const; {
stringstream &setMax(unsigned m); std::istringstream is(this->str());
unsigned getMax() const; is >> val;
}; return *this;
}
std::istream &operator>>(Anope::string &val);
bool operator==(const stringstream &other) const;
bool operator!=(const stringstream &other) const;
stringstream &SetType(Serialize::DataType t);
Serialize::DataType GetType() const;
stringstream &SetMax(unsigned m);
unsigned GetMax() const;
};
namespace Serialize
{
typedef std::map<Anope::string, stringstream> Data; typedef std::map<Anope::string, stringstream> Data;
extern void RegisterTypes();
class Type;
template<typename T> class Checker;
template<typename T> class Reference;
} }
extern void RegisterTypes(); /** A serialziable object. Serializable objects can be serialized into
* a map of stringstreams (Serialize::Data), and then reconstructed or
class SerializeType; * updated later at any time.
*/
class CoreExport Serializable : public virtual Base class CoreExport Serializable : public virtual Base
{ {
private: private:
static std::list<Serializable *> *serializable_items; /* A list of every serializable item in Anope.
SerializeType *s_type; * Some of these are static and constructed at runtime,
* so this list must be on the heap, as it is not always
* constructed before other objects are if it isn't.
*/
static std::list<Serializable *> *SerializableItems;
/* The type of item this object is */
Serialize::Type *s_type;
private: private:
std::list<Serializable *>::iterator s_iter; // Iterator into serializable_items /* Iterator into serializable_items */
std::list<Serializable *>::iterator s_iter;
/* The last serialized form of this object commited to the database */
Serialize::Data last_commit; Serialize::Data last_commit;
/* The last time this object was commited to the database */
time_t last_commit_time; time_t last_commit_time;
Serializable(); Serializable();
@@ -85,10 +96,16 @@ class CoreExport Serializable : public virtual Base
Serializable &operator=(const Serializable &); Serializable &operator=(const Serializable &);
public: public:
/* Unique ID (per type, not globally) for this object */
unsigned int id; unsigned int id;
void destroy(); /* Destroys this object. This is effectively the same thing as
* delete, however it properly cleans up after this object.
*/
void Destroy();
/** Marks the object as potentially being updated "soon".
*/
void QueueUpdate(); void QueueUpdate();
bool IsCached(); bool IsCached();
@@ -97,27 +114,43 @@ class CoreExport Serializable : public virtual Base
bool IsTSCached(); bool IsTSCached();
void UpdateTS(); void UpdateTS();
SerializeType* GetSerializableType() const; /** Get the type of serializable object this is
* @return The serializable object type
*/
Serialize::Type* GetSerializableType() const;
virtual Serialize::Data serialize() const = 0; virtual Serialize::Data Serialize() const = 0;
static const std::list<Serializable *> &GetItems(); static const std::list<Serializable *> &GetItems();
}; };
class CoreExport SerializeType /* A serializable type. There should be one of these classes for each type
* of class that inherits from Serialiable. Used for unserializing objects
* of this type, as it requires a function pointer to a static member function.
*/
class CoreExport Serialize::Type
{ {
typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &); typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &);
static std::vector<Anope::string> type_order; static std::vector<Anope::string> TypeOrder;
static std::map<Anope::string, SerializeType *> types; static std::map<Anope::string, Serialize::Type *> Types;
/* The name of this type, should be a class name */
Anope::string name; Anope::string name;
unserialize_func unserialize; unserialize_func unserialize;
/* Owner of this type. Used for placing objects of this type in separate databases
* based on what module, if any, owns it.
*/
Module *owner; Module *owner;
/* The timesatmp for this type. All objects of this type are as up to date as
* this timestamp. if curtime == timestamp then we have the most up to date
* version of every object of this type.
*/
time_t timestamp; time_t timestamp;
public: public:
/* Map of Serializable::id to Serializable objects */
std::map<unsigned int, Serializable *> objects; std::map<unsigned int, Serializable *> objects;
/** Creates a new serializable type /** Creates a new serializable type
@@ -125,44 +158,67 @@ class CoreExport SerializeType
* @param f Func to unserialize objects * @param f Func to unserialize objects
* @param owner Owner of this type. Leave NULL for the core. * @param owner Owner of this type. Leave NULL for the core.
*/ */
SerializeType(const Anope::string &n, unserialize_func f, Module *owner = NULL); Type(const Anope::string &n, unserialize_func f, Module *owner = NULL);
~SerializeType(); ~Type();
/** Gets the name for this type
* @return The name, eg "NickAlias"
*/
const Anope::string &GetName(); const Anope::string &GetName();
/** Unserialized an object.
* @param obj NULL if this object doesn't yet exist. If this isn't NULL, instead
* update the contents of this object.
* @param data The data to unserialize
* @return The unserialized object. If obj != NULL this should be obj.
*/
Serializable *Unserialize(Serializable *obj, Serialize::Data &data); Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
/** Check if this object type has any pending changes and update them.
*/
void Check(); void Check();
/** Gets the timestamp for the object type. That is, the time we know
* all objects of this type are updated at least to.
*/
time_t GetTimestamp() const; time_t GetTimestamp() const;
/** Bumps object type timestamp to current time
*/
void UpdateTimestamp(); void UpdateTimestamp();
Module* GetOwner() const; Module* GetOwner() const;
static SerializeType *Find(const Anope::string &name); static Serialize::Type *Find(const Anope::string &name);
static const std::vector<Anope::string> &GetTypeOrder(); static const std::vector<Anope::string> &GetTypeOrder();
}; };
/** Should be used to hold lists and other objects of a specific type,
* but not a specific object. Used for ensuring that any access to
* this object type is always up to date. These are usually constructed
* at run time, before main is called, so no types are registered. This
* is why there are static Serialize::Type* variables in every function.
*/
template<typename T> template<typename T>
class serialize_checker class Serialize::Checker
{ {
Anope::string name; Anope::string name;
T obj; T obj;
public: public:
serialize_checker(const Anope::string &n) : name(n) { } Checker(const Anope::string &n) : name(n) { }
inline const T* operator->() const inline const T* operator->() const
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return &this->obj; return &this->obj;
} }
inline T* operator->() inline T* operator->()
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return &this->obj; return &this->obj;
@@ -170,14 +226,14 @@ class serialize_checker
inline const T& operator*() const inline const T& operator*() const
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return this->obj; return this->obj;
} }
inline T& operator*() inline T& operator*()
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return this->obj; return this->obj;
@@ -185,44 +241,50 @@ class serialize_checker
inline operator const T&() const inline operator const T&() const
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return this->obj; return this->obj;
} }
inline operator T&() inline operator T&()
{ {
static SerializeType *type = SerializeType::Find(this->name); static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type) if (type)
type->Check(); type->Check();
return this->obj; return this->obj;
} }
}; };
/** Used to hold references to serializable objects. Reference should always be
* used when holding references to serializable objects for extended periods of time
* to ensure that the object it refers to it always up to date. This also behaves like
* Reference in that it will invalidate itself if the object it refers to is
* destructed.
*/
template<typename T> template<typename T>
class serialize_obj : public dynamic_reference_base class Serialize::Reference : public ReferenceBase
{ {
protected: protected:
T *ref; T *ref;
public: public:
serialize_obj() : ref(NULL) Reference() : ref(NULL)
{ {
} }
serialize_obj(T *obj) : ref(obj) Reference(T *obj) : ref(obj)
{ {
if (obj) if (obj)
obj->AddReference(this); obj->AddReference(this);
} }
serialize_obj(const serialize_obj<T> &other) : ref(other.ref) Reference(const Reference<T> &other) : ref(other.ref)
{ {
if (*this) if (*this)
this->ref->AddReference(this); this->ref->AddReference(this);
} }
~serialize_obj() ~Reference()
{ {
if (*this) if (*this)
this->ref->DelReference(this); this->ref->DelReference(this);
+37 -15
View File
@@ -1,3 +1,15 @@
/*
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#ifndef SERVERS_H #ifndef SERVERS_H
#define SERVERS_H #define SERVERS_H
@@ -5,13 +17,25 @@
#include "anope.h" #include "anope.h"
#include "extensible.h" #include "extensible.h"
/* Anope */ /* Anope. We are at the top of the server tree, our uplink is
* almost always me->GetLinks()[0]. We never have an uplink. */
extern CoreExport Server *Me; extern CoreExport Server *Me;
extern CoreExport const Anope::string ts6_uid_retrieve(); namespace Servers
extern CoreExport const Anope::string ts6_sid_retrieve(); {
/* Retrieves the next free TS6 UID or SID */
extern CoreExport const Anope::string TS6_UID_Retrieve();
extern CoreExport const Anope::string TS6_SID_Retrieve();
extern CoreExport std::set<Anope::string> Capab; /* Gets our uplink. Note we don't actually have an "uplink", this is just
* the only server whose uplink *is* Me that is not a juped server.
* @return Our uplink, or NULL if not uplinked to anything
*/
extern CoreExport Server* GetUplink();
/* CAPAB/PROTOCTL given by the uplink */
extern CoreExport std::set<Anope::string> Capab;
}
/** Flags set on servers /** Flags set on servers
*/ */
@@ -24,28 +48,26 @@ enum ServerFlag
SERVER_JUPED SERVER_JUPED
}; };
const Anope::string ServerFlagStrings[] = { "SERVER_NONE", "SERVER_SYNCING", "SERVER_JUPED", "" };
/** Class representing a server /** Class representing a server
*/ */
class CoreExport Server : public Flags<ServerFlag>, public Extensible class CoreExport Server : public Flags<ServerFlag>, public Extensible
{ {
private: private:
/* Server name */ /* Server name */
Anope::string Name; Anope::string name;
/* Hops between services and server */ /* Hops between services and server */
unsigned int Hops; unsigned int hops;
/* Server description */ /* Server description */
Anope::string Description; Anope::string description;
/* Server ID */ /* Server ID */
Anope::string SID; Anope::string sid;
/* Links for this server */ /* Links for this server */
std::vector<Server *> Links; std::vector<Server *> links;
/* Uplink for this server */ /* Uplink for this server */
Server *UplinkServer; Server *uplink;
/* Reason this server was quit */ /* Reason this server was quit */
Anope::string QReason; Anope::string quit_reason;
public: public:
/** Constructor /** Constructor
@@ -65,7 +87,7 @@ class CoreExport Server : public Flags<ServerFlag>, public Extensible
public: public:
/* Number of users on the server */ /* Number of users on the server */
unsigned Users; unsigned users;
/** Delete this server with a reason /** Delete this server with a reason
* @param reason The reason * @param reason The reason
@@ -125,7 +147,7 @@ class CoreExport Server : public Flags<ServerFlag>, public Extensible
/** Finish syncing this server and optionally all links to it /** Finish syncing this server and optionally all links to it
* @param SyncLinks True to sync the links for this server too (if any) * @param SyncLinks True to sync the links for this server too (if any)
*/ */
void Sync(bool SyncLinks); void Sync(bool sync_links);
/** Check if this server is synced /** Check if this server is synced
* @return true or false * @return true or false
+70 -14
View File
@@ -1,4 +1,5 @@
/* /*
*
* (C) 2003-2012 Anope Team * (C) 2003-2012 Anope Team
* Contact us at team@anope.org * Contact us at team@anope.org
* *
@@ -6,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef SERVICE_H #ifndef SERVICE_H
@@ -15,18 +17,34 @@
#include "anope.h" #include "anope.h"
#include "modules.h" #include "modules.h"
/** Anything that inherits from this class can be referred to
* using ServiceReference. Any interfaces provided by modules,
* such as commands, use this. This is also used for modules
* that publish a service (m_ssl, etc).
*/
class CoreExport Service : public virtual Base class CoreExport Service : public virtual Base
{ {
static std::map<Anope::string, std::map<Anope::string, Service *> > services; static std::map<Anope::string, std::map<Anope::string, Service *> > Services;
static std::map<Anope::string, std::map<Anope::string, Anope::string> > Aliases;
public: public:
static Service *FindService(const Anope::string &t, const Anope::string &n) static Service *FindService(const Anope::string &t, const Anope::string &n)
{ {
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = services.find(t); std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = Services.find(t);
if (it != services.end()) if (it != Services.end())
{ {
std::map<Anope::string, Service *>::iterator it2 = it->second.find(n); Anope::string name = n;
if (it2 != it->second.end())
return it2->second; std::map<Anope::string, std::map<Anope::string, Anope::string> >::iterator it2 = Aliases.find(t);
if (it2 != Aliases.end())
{
std::map<Anope::string, Anope::string>::iterator it3 = it2->second.find(n);
if (it3 != it2->second.end())
name = it3->second;
}
std::map<Anope::string, Service *>::iterator it4 = it->second.find(name);
if (it4 != it->second.end())
return it4->second;
} }
return NULL; return NULL;
@@ -35,15 +53,31 @@ class CoreExport Service : public virtual Base
static std::vector<Anope::string> GetServiceKeys(const Anope::string &t) static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
{ {
std::vector<Anope::string> keys; std::vector<Anope::string> keys;
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = services.find(t); std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = Services.find(t);
if (it != services.end()) if (it != Services.end())
for (std::map<Anope::string, Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) for (std::map<Anope::string, Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
keys.push_back(it2->first); keys.push_back(it2->first);
return keys; return keys;
} }
static void AddAlias(const Anope::string &t, const Anope::string &n, const Anope::string &v)
{
std::map<Anope::string, Anope::string> &smap = Aliases[t];
smap[n] = v;
}
static void DelAlias(const Anope::string &t, const Anope::string &n)
{
std::map<Anope::string, Anope::string> &smap = Aliases[t];
smap.erase(n);
if (smap.empty())
Aliases.erase(t);
}
Module *owner; Module *owner;
/* Service type, which should be the class name (eg "Command") */
Anope::string type; Anope::string type;
/* Service name, commands are usually named service/command */
Anope::string name; Anope::string name;
Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n) Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
@@ -58,7 +92,7 @@ class CoreExport Service : public virtual Base
void Register() void Register()
{ {
std::map<Anope::string, Service *> &smap = services[this->type]; std::map<Anope::string, Service *> &smap = Services[this->type];
if (smap.find(this->name) != smap.end()) if (smap.find(this->name) != smap.end())
throw ModuleException("Service " + this->type + " with name " + this->name + " already exists"); throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
smap[this->name] = this; smap[this->name] = this;
@@ -66,29 +100,32 @@ class CoreExport Service : public virtual Base
void Unregister() void Unregister()
{ {
std::map<Anope::string, Service *> &smap = services[this->type]; std::map<Anope::string, Service *> &smap = Services[this->type];
smap.erase(this->name); smap.erase(this->name);
if (smap.empty()) if (smap.empty())
services.erase(this->type); Services.erase(this->type);
} }
}; };
/** Like Reference, but used to refer to Services.
*/
template<typename T> template<typename T>
class service_reference : public dynamic_reference<T> class ServiceReference : public Reference<T>
{ {
Anope::string type; Anope::string type;
Anope::string name; Anope::string name;
public: public:
service_reference() : dynamic_reference<T>(NULL) { } ServiceReference() { }
service_reference(const Anope::string &t, const Anope::string &n) : dynamic_reference<T>(NULL), type(t), name(n) ServiceReference(const Anope::string &t, const Anope::string &n) : type(t), name(n)
{ {
} }
inline void operator=(const Anope::string &n) inline void operator=(const Anope::string &n)
{ {
this->name = n; this->name = n;
this->invalid = true;
} }
operator bool() anope_override operator bool() anope_override
@@ -100,6 +137,10 @@ class service_reference : public dynamic_reference<T>
} }
if (!this->ref) if (!this->ref)
{ {
/* This really could be dynamic_cast in every case, except for when a module
* creates its own service type (that other modules must include the header file
* for), as the core is not compiled with it so there is no RTTI for it.
*/
this->ref = static_cast<T *>(Service::FindService(this->type, this->name)); this->ref = static_cast<T *>(Service::FindService(this->type, this->name));
if (this->ref) if (this->ref)
this->ref->AddReference(this); this->ref->AddReference(this);
@@ -108,5 +149,20 @@ class service_reference : public dynamic_reference<T>
} }
}; };
class ServiceAlias
{
Anope::string t, f;
public:
ServiceAlias(const Anope::string &type, const Anope::string &from, const Anope::string &to) : t(type), f(from)
{
Service::AddAlias(type, from, to);
}
~ServiceAlias()
{
Service::DelAlias(t, f);
}
};
#endif // SERVICE_H #endif // SERVICE_H
-10
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef SERVICES_H #ifndef SERVICES_H
@@ -66,13 +65,4 @@
# include "anope_windows.h" # include "anope_windows.h"
#endif #endif
/**
* RFC: defination of a valid nick
* nickname = ( letter / special ) *8( letter / digit / special / "-" )
* letter = %x41-5A / %x61-7A ; A-Z / a-z
* digit = %x30-39 ; 0-9
* special = %x5B-60 / %x7B-7D ; "[", "]", "\", "`", "_", "^", "{", "|", "}"
**/
#define isvalidnick(c) (isalnum(c) || ((c) >= '\x5B' && (c) <= '\x60') || ((c) >= '\x7B' && (c) <= '\x7D') || (c) == '-')
#endif // SERVICES_H #endif // SERVICES_H
-1
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
* *
*
*/ */
#ifndef SIGNAL_H #ifndef SIGNAL_H
+2 -1
View File
@@ -7,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef SOCKETENGINE_H #ifndef SOCKETENGINE_H
@@ -17,7 +18,7 @@
class CoreExport SocketEngine class CoreExport SocketEngine
{ {
static const int DefaultSize = 4; // Uplink, DNS, Signal handler, Mode stacker static const int DefaultSize = 8; // Uplink, DNS, Signal handlers, Mode stacker
public: public:
/* Map of sockets */ /* Map of sockets */
static std::map<int, Socket *> Sockets; static std::map<int, Socket *> Sockets;
+21 -40
View File
@@ -7,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef SOCKETS_H #ifndef SOCKETS_H
@@ -104,12 +105,12 @@ class CoreExport cidr
class SocketException : public CoreException class SocketException : public CoreException
{ {
public: public:
/** Default constructor for socket exceptions /** Constructor for socket exceptions
* @param message Error message * @param message Error message
*/ */
SocketException(const Anope::string &message) : CoreException(message) { } SocketException(const Anope::string &message) : CoreException(message) { }
/** Default destructor /** Destructor
* @throws Nothing * @throws Nothing
*/ */
virtual ~SocketException() throw() { } virtual ~SocketException() throw() { }
@@ -126,9 +127,6 @@ enum SocketFlag
SF_ACCEPTED SF_ACCEPTED
}; };
static const Anope::string SocketFlagStrings[] = { "SF_DEAD", "SF_WRITABLE", "SF_CONNECTING", "SF_CONNECTED", "SF_ACCEPTING", "SF_ACCEPTED", "" };
class CoreExport SocketIO class CoreExport SocketIO
{ {
public: public:
@@ -189,29 +187,29 @@ class CoreExport Socket : public Flags<SocketFlag>
{ {
protected: protected:
/* Socket FD */ /* Socket FD */
int Sock; int sock;
/* Is this an IPv6 socket? */ /* Is this an IPv6 socket? */
bool IPv6; bool ipv6;
public: public:
/* Sockaddrs for bind() (if it's bound) */ /* Sockaddrs for bind() (if it's bound) */
sockaddrs bindaddr; sockaddrs bindaddr;
/* I/O functions used for this socket */ /* I/O functions used for this socket */
SocketIO *IO; SocketIO *io;
/** Empty constructor, should not be called. /** Empty constructor, should not be called.
*/ */
Socket(); Socket();
/** Default constructor /** Constructor, possibly creates the socket and adds it to the engine
* @param sock The socket to use, -1 if we need to create our own * @param sock The socket to use, -1 if we need to create our own
* @param ipv6 true if using ipv6 * @param ipv6 true if using ipv6
* @param type The socket type, defaults to SOCK_STREAM * @param type The socket type, defaults to SOCK_STREAM
*/ */
Socket(int sock, bool ipv6 = false, int type = SOCK_STREAM); Socket(int sock, bool ipv6 = false, int type = SOCK_STREAM);
/** Default destructor /** Destructor, closes the socket and removes it from the engine
*/ */
virtual ~Socket(); virtual ~Socket();
@@ -225,7 +223,7 @@ class CoreExport Socket : public Flags<SocketFlag>
*/ */
bool IsIPv6() const; bool IsIPv6() const;
/** Mark a socket as blockig /** Mark a socket as blocking
* @return true if the socket is now blocking * @return true if the socket is now blocking
*/ */
bool SetBlocking(); bool SetBlocking();
@@ -266,19 +264,14 @@ class CoreExport BufferedSocket : public virtual Socket
{ {
protected: protected:
/* Things to be written to the socket */ /* Things to be written to the socket */
Anope::string WriteBuffer; Anope::string write_buffer;
/* Part of a message sent from the server, but not totally received */ /* Part of a message sent from the server, but not totally received */
Anope::string extrabuf; Anope::string extra_buf;
/* How much data was received from this socket */ /* How much data was received from this socket on this recv() */
int RecvLen; int recv_len;
public: public:
/** Constructor
*/
BufferedSocket(); BufferedSocket();
/** Default destructor
*/
virtual ~BufferedSocket(); virtual ~BufferedSocket();
/** Called when there is something to be received for this socket /** Called when there is something to be received for this socket
@@ -330,15 +323,11 @@ class CoreExport BinarySocket : public virtual Socket
~DataBlock(); ~DataBlock();
}; };
std::deque<DataBlock *> WriteBuffer; /* Data to be written out */
std::deque<DataBlock *> write_buffer;
public: public:
/** Constructor
*/
BinarySocket(); BinarySocket();
/** Default destructor
*/
virtual ~BinarySocket(); virtual ~BinarySocket();
/** Called when there is something to be received for this socket /** Called when there is something to be received for this socket
@@ -376,9 +365,6 @@ class CoreExport ListenSocket : public virtual Socket
* @param ipv6 true for ipv6 * @param ipv6 true for ipv6
*/ */
ListenSocket(const Anope::string &bindip, int port, bool ipv6); ListenSocket(const Anope::string &bindip, int port, bool ipv6);
/** Destructor
*/
virtual ~ListenSocket(); virtual ~ListenSocket();
/** Process what has come in from the connection /** Process what has come in from the connection
@@ -435,7 +421,7 @@ class CoreExport ClientSocket : public virtual Socket
{ {
public: public:
/* Listen socket this connection came from */ /* Listen socket this connection came from */
ListenSocket *LS; ListenSocket *ls;
/* Clients address */ /* Clients address */
sockaddrs clientaddr; sockaddrs clientaddr;
@@ -469,19 +455,14 @@ class CoreExport Pipe : public Socket
{ {
public: public:
/** The FD of the write pipe (if this isn't evenfd) /** The FD of the write pipe (if this isn't evenfd)
* this->Sock is the readfd * this->sock is the readfd
*/ */
int WritePipe; int write_pipe;
/** Constructor
*/
Pipe(); Pipe();
/** Destructor
*/
~Pipe(); ~Pipe();
/** Called when data is to be read /** Called when data is to be read, reads the data then calls OnNotify
*/ */
bool ProcessRead() anope_override; bool ProcessRead() anope_override;
@@ -489,13 +470,13 @@ class CoreExport Pipe : public Socket
*/ */
void Notify(); void Notify();
/** Overload to do something useful /** Called after ProcessRead comes back from Notify(), overload to do something useful
*/ */
virtual void OnNotify() = 0; virtual void OnNotify() = 0;
}; };
extern CoreExport uint32_t TotalRead; extern CoreExport uint32_t TotalRead;
extern CoreExport uint32_t TotalWritten; extern CoreExport uint32_t TotalWritten;
extern CoreExport SocketIO normalSocketIO; extern CoreExport SocketIO NormalSocketIO;
#endif // SOCKET_H #endif // SOCKET_H
+13 -1
View File
@@ -1,3 +1,15 @@
/*
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#ifndef THREADENGINE_H #ifndef THREADENGINE_H
#define THREADENGINE_H #define THREADENGINE_H
@@ -12,7 +24,7 @@ class CoreExport Thread : public Pipe, public Extensible
public: public:
/* Handle for this thread */ /* Handle for this thread */
pthread_t Handle; pthread_t handle;
/** Threads constructor /** Threads constructor
*/ */
+8 -6
View File
@@ -4,8 +4,10 @@
* Contact us at team@anope.org * Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef TIMERS_H #ifndef TIMERS_H
@@ -33,14 +35,14 @@ class CoreExport Timer
bool repeat; bool repeat;
public: public:
/** Default constructor, initializes the triggering time /** Constructor, initializes the triggering time
* @param time_from_now The number of seconds from now to trigger the timer * @param time_from_now The number of seconds from now to trigger the timer
* @param now The time now * @param now The time now
* @param repeating Repeat this timer every time_from_now if this is true * @param repeating Repeat this timer every time_from_now if this is true
*/ */
Timer(long time_from_now, time_t now = Anope::CurTime, bool repeating = false); Timer(long time_from_now, time_t now = Anope::CurTime, bool repeating = false);
/** Default destructor, removes the timer from the list /** Destructor, removes the timer from the list
*/ */
virtual ~Timer(); virtual ~Timer();
@@ -91,14 +93,14 @@ class CoreExport TimerManager
static std::vector<Timer *> Timers; static std::vector<Timer *> Timers;
public: public:
/** Add a timer to the list /** Add a timer to the list
* @param T A Timer derived class to add * @param t A Timer derived class to add
*/ */
static void AddTimer(Timer *T); static void AddTimer(Timer *t);
/** Deletes a timer /** Deletes a timer
* @param T A Timer derived class to delete * @param t A Timer derived class to delete
*/ */
static void DelTimer(Timer *T); static void DelTimer(Timer *t);
/** Tick all pending timers /** Tick all pending timers
* @param ctime The current time * @param ctime The current time
+9
View File
@@ -7,6 +7,7 @@
* *
* Based on the original code of Epona by Lara. * Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church. * Based on the original code of Services by Andy Church.
*
*/ */
#ifndef UPLINK_H #ifndef UPLINK_H
@@ -14,6 +15,12 @@
#include "sockets.h" #include "sockets.h"
namespace Uplink
{
extern void Connect();
}
/* This is the socket to our uplink */
class UplinkSocket : public ConnectionSocket, public BufferedSocket class UplinkSocket : public ConnectionSocket, public BufferedSocket
{ {
public: public:
@@ -23,9 +30,11 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
void OnConnect(); void OnConnect();
void OnError(const Anope::string &); void OnError(const Anope::string &);
/* A message sent over the uplink socket */
class CoreExport Message class CoreExport Message
{ {
private: private:
/* The source of the message, can be a server (Me), or any user (one of our bots) */
const Server *server; const Server *server;
const User *user; const User *user;
std::stringstream buffer; std::stringstream buffer;
+88 -55
View File
@@ -1,8 +1,14 @@
/* /*
* Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org> *
* Copyright (C) 2008-2012 Anope Team <team@anope.org> * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/ */
#ifndef USERS_H #ifndef USERS_H
@@ -19,18 +25,15 @@ typedef Anope::hash_map<User *> user_map;
extern CoreExport user_map UserListByNick, UserListByUID; extern CoreExport user_map UserListByNick, UserListByUID;
class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2> extern CoreExport int OperCount;
{ extern CoreExport unsigned MaxUserCount;
public: extern CoreExport time_t MaxUserTime;
ChannelStatus();
Anope::string BuildCharPrefixList() const;
Anope::string BuildModePrefixList() const;
};
/* One per channel per user. Channel and status */
struct ChannelContainer struct ChannelContainer
{ {
Channel *chan; Channel *chan;
ChannelStatus *Status; ChannelStatus *status;
ChannelContainer(Channel *c) : chan(c) { } ChannelContainer(Channel *c) : chan(c) { }
virtual ~ChannelContainer() { } virtual ~ChannelContainer() { }
@@ -38,7 +41,6 @@ struct ChannelContainer
typedef std::list<ChannelContainer *> UChannelList; typedef std::list<ChannelContainer *> UChannelList;
/* Online user and channel data. */ /* Online user and channel data. */
class CoreExport User : public virtual Base, public Extensible, public CommandReply class CoreExport User : public virtual Base, public Extensible, public CommandReply
{ {
@@ -46,36 +48,55 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
Anope::string vident; Anope::string vident;
Anope::string ident; Anope::string ident;
Anope::string uid; Anope::string uid;
bool OnAccess; /* If the user is on the access list of the nick theyre on */ /* If the user is on the access list of the nick theyre on */
Flags<UserModeName, UMODE_END * 2> modes; /* Bitset of mode names the user has set on them */ bool on_access;
std::map<UserModeName, Anope::string> Params; /* Map of user modes and the params this user has */ /* Bitset of mode names the user has set on them */
serialize_obj<NickCore> nc; /* NickCore account the user is currently loggged in as */ Flags<UserModeName> modes;
/* Map of user modes and the params this user has */
std::map<UserModeName, Anope::string> mode_params;
/* NickCore account the user is currently loggged in as, if they are logged in */
Serialize::Reference<NickCore> nc;
/* # of invalid password attempts */
unsigned short invalid_pw_count;
/* Time of last invalid password */
time_t invalid_pw_time;
public: // XXX: exposing a tiny bit too much public: // XXX: exposing a tiny bit too much
Anope::string nick; /* User's current nick */ /* User's current nick */
Anope::string nick;
Anope::string host; /* User's real hostname */ /* User's real hostname */
Anope::string vhost; /* User's virtual hostname */ Anope::string host;
Anope::string chost; /* User's cloaked hostname */ /* User's virtual hostname */
Anope::string realname; /* Realname */ Anope::string vhost;
Anope::string fingerprint; /* SSL Fingerprint */ /* User's cloaked hostname */
Anope::string ip; /* User's IP */ Anope::string chost;
Server *server; /* Server user is connected to */ /* Realname */
time_t signon; /* When the user signed on. Set on connect and never modified. */ Anope::string realname;
time_t timestamp; /* Timestamp of the nick. Updated when the nick changes. */ /* SSL Fingerprint */
bool SuperAdmin; /* is SuperAdmin on or off? */ Anope::string fingerprint;
/* User's IP */
Anope::string ip;
/* Server user is connected to */
Server *server;
/* When the user signed on. Set on connect and never modified. */
time_t signon;
/* Timestamp of the nick. Updated when the nick changes. */
time_t timestamp;
/* Is the user as super admin? */
bool super_admin;
/* Channels the user is in */ /* Channels the user is in */
UChannelList chans; UChannelList chans;
unsigned short invalid_pw_count; /* # of invalid password attempts */ /* Last time this user sent a memo command used */
time_t invalid_pw_time; /* Time of last invalid password */ time_t lastmemosend;
/* Last time this user registered */
time_t lastmemosend; /* Last time MS SEND command used */ time_t lastnickreg;
time_t lastnickreg; /* Last time NS REGISTER cmd used */ /* Last time this user sent an email */
time_t lastmail; /* Last time this user sent a mail */ time_t lastmail;
/****************************************************************/
/** Create a new user object, initialising necessary fields and /** Create a new user object, initialising necessary fields and
* adds it to the hash * adds it to the hash
@@ -152,7 +173,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/ */
const Anope::string &GetIdent() const; const Anope::string &GetIdent() const;
/** Get the full mask ( nick!ident@realhost ) of a user /** Get the full mask (nick!ident@realhost) of a user
*/ */
Anope::string GetMask() const; Anope::string GetMask() const;
@@ -201,16 +222,16 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
virtual NickCore *Account() const; virtual NickCore *Account() const;
/** Check if the user is identified for their nick /** Check if the user is identified for their nick
* @param CheckNick True to check if the user is identified to the nickname they are on too * @param check_nick True to check if the user is identified to the nickname they are on too
* @return true or false * @return true or false
*/ */
bool IsIdentified(bool CheckNick = false) const; bool IsIdentified(bool check_nick = false) const;
/** Check if the user is recognized for their nick (on the nicks access list) /** Check if the user is recognized for their nick (on the nicks access list)
* @param CheckSecure Only returns true if the user has secure off * @param check_nick Only returns true if the user has secure off
* @return true or false * @return true or false
*/ */
bool IsRecognized(bool CheckSecure = true) const; bool IsRecognized(bool check_nick = true) const;
/** Check if the user is a services oper /** Check if the user is a services oper
* @return true if they are an oper * @return true if they are an oper
@@ -243,7 +264,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param um The user mode * @param um The user mode
* @param Param The param, if there is one * @param Param The param, if there is one
*/ */
void SetModeInternal(UserMode *um, const Anope::string &Param = ""); void SetModeInternal(UserMode *um, const Anope::string &param = "");
/** Remove a mode internally on the user, the IRCd is not informed /** Remove a mode internally on the user, the IRCd is not informed
* @param um The user mode * @param um The user mode
@@ -255,14 +276,14 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param um The user mode * @param um The user mode
* @param Param Optional param for the mode * @param Param Optional param for the mode
*/ */
void SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param = ""); void SetMode(const BotInfo *bi, UserMode *um, const Anope::string &param = "");
/** Set a mode on the user /** Set a mode on the user
* @param bi The client setting the mode * @param bi The client setting the mode
* @param Name The mode name * @param name The mode name
* @param Param Optional param for the mode * @param Param Optional param for the mode
*/ */
void SetMode(const BotInfo *bi, UserModeName Name, const Anope::string &Param = ""); void SetMode(const BotInfo *bi, UserModeName name, const Anope::string &param = "");
/** Remove a mode on the user /** Remove a mode on the user
* @param bi The client setting the mode * @param bi The client setting the mode
@@ -272,9 +293,9 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/** Remove a mode from the user /** Remove a mode from the user
* @param bi The client setting the mode * @param bi The client setting the mode
* @param Name The mode name * @param name The mode name
*/ */
void RemoveMode(const BotInfo *bi, UserModeName Name); void RemoveMode(const BotInfo *bi, UserModeName name);
/** Set a string of modes on a user /** Set a string of modes on a user
* @param bi The client setting the modes * @param bi The client setting the modes
@@ -316,16 +337,28 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param reason The reason for the kill * @param reason The reason for the kill
*/ */
void KillInternal(const Anope::string &source, const Anope::string &reason); void KillInternal(const Anope::string &source, const Anope::string &reason);
/* Returns a mask that will most likely match any address the
* user will have from that location. For IP addresses, wildcards the
* appropriate subnet mask (e.g. 35.1.1.1 -> 35.*; 128.2.1.1 -> 128.2.*);
* for named addresses, wildcards the leftmost part of the name unless the
* name only contains two parts. If the username begins with a ~, delete
* it.
*/
Anope::string Mask() const;
/** Notes the usage of an incorrect password. If too many
* incorrect passwords are used the user might be killed.
* @return true if the user was killed
*/
bool BadPassword();
/** Finds a user by nick, or possibly UID
* @param name The nick, or possibly UID, to lookup
* @param nick_only set to true to only look up by nick, not UID
* @return the user, if they exist
*/
static User* Find(const Anope::string &name, bool nick_only = false);
}; };
extern CoreExport int32_t opcnt;
extern CoreExport uint32_t maxusercnt, usercnt;
extern CoreExport time_t maxusertime;
extern CoreExport User *finduser(const Anope::string &nick);
extern CoreExport bool matches_list(Channel *c, User *user, ChannelModeName mode);
extern CoreExport Anope::string create_mask(User *u);
#endif // USERS_H #endif // USERS_H
+17 -14
View File
@@ -1,29 +1,31 @@
/* OperServ support /*
* *
* (C) 2008-2012 Anope Team * (C) 2008-2012 Anope Team
* Contact us at team@anope.org * Contact us at team@anope.org
* *
* Please read COPYING and README for further details. * Please read COPYING and README for further details.
*
*/ */
#ifndef OPER_H #ifndef XLINE_H
#define OPER_H #define XLINE_H
#include "serialize.h" #include "serialize.h"
#include "service.h" #include "service.h"
/* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
class CoreExport XLine : public Serializable class CoreExport XLine : public Serializable
{ {
void InitRegex(); void InitRegex();
public: public:
Anope::string Mask; Anope::string mask;
Regex *regex; Regex *regex;
Anope::string By; Anope::string by;
time_t Created; time_t created;
time_t Expires; time_t expires;
Anope::string Reason; Anope::string reason;
XLineManager *manager; XLineManager *manager;
Anope::string UID; Anope::string id;
XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = ""); XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = "");
@@ -40,17 +42,18 @@ class CoreExport XLine : public Serializable
bool HasNickOrReal() const; bool HasNickOrReal() const;
bool IsRegex() const; bool IsRegex() const;
Serialize::Data serialize() const anope_override; Serialize::Data Serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &data); static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
}; };
/* Managers XLines. There is one XLineManager per type of XLine. */
class CoreExport XLineManager : public Service class CoreExport XLineManager : public Service
{ {
char type; char type;
/* List of XLines in this XLineManager */ /* List of XLines in this XLineManager */
serialize_checker<std::vector<XLine *> > XLines; Serialize::Checker<std::vector<XLine *> > xlines;
/* Akills can have the same IDs, sometimes */ /* Akills can have the same IDs, sometimes */
static serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID; static Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
public: public:
/* List of XLine managers we check users against in XLineManager::CheckAll */ /* List of XLine managers we check users against in XLineManager::CheckAll */
static std::list<XLineManager *> XLineManagers; static std::list<XLineManager *> XLineManagers;
@@ -174,4 +177,4 @@ class CoreExport XLineManager : public Service
virtual void SendDel(XLine *x) = 0; virtual void SendDel(XLine *x) = 0;
}; };
#endif // OPER_H #endif // XLINE_H
+5 -5
View File
@@ -27,20 +27,20 @@ class CommandBSAssign : public Command
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
const Anope::string &nick = params[1]; const Anope::string &nick = params[1];
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(BOT_ASSIGN_READONLY); source.Reply(BOT_ASSIGN_READONLY);
return; return;
} }
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
return; return;
} }
BotInfo *bi = findbot(nick); BotInfo *bi = BotInfo::Find(nick, true);
if (!bi) if (!bi)
{ {
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); source.Reply(BOT_DOES_NOT_EXIST, nick.c_str());
@@ -95,13 +95,13 @@ class CommandBSUnassign : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(BOT_ASSIGN_READONLY); source.Reply(BOT_ASSIGN_READONLY);
return; return;
} }
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+12 -12
View File
@@ -19,10 +19,10 @@ class BadwordsDelCallback : public NumberList
CommandSource &source; CommandSource &source;
ChannelInfo *ci; ChannelInfo *ci;
Command *c; Command *c;
unsigned Deleted; unsigned deleted;
bool override; bool override;
public: public:
BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0), override(false) BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false)
{ {
if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration"))
this->override = true; this->override = true;
@@ -30,12 +30,12 @@ class BadwordsDelCallback : public NumberList
~BadwordsDelCallback() ~BadwordsDelCallback()
{ {
if (!Deleted) if (!deleted)
source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str()); source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str());
else if (Deleted == 1) else if (deleted == 1)
source.Reply(_("Deleted 1 entry from %s bad words list."), ci->name.c_str()); source.Reply(_("Deleted 1 entry from %s bad words list."), ci->name.c_str());
else else
source.Reply(_("Deleted %d entries from %s bad words list."), Deleted, ci->name.c_str()); source.Reply(_("Deleted %d entries from %s bad words list."), deleted, ci->name.c_str());
} }
void HandleNumber(unsigned Number) anope_override void HandleNumber(unsigned Number) anope_override
@@ -44,7 +44,7 @@ class BadwordsDelCallback : public NumberList
return; return;
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word;
++Deleted; ++deleted;
ci->EraseBadWord(Number - 1); ci->EraseBadWord(Number - 1);
} }
}; };
@@ -58,7 +58,7 @@ class CommandBSBadwords : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST";
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Word").addColumn("Type"); list.AddColumn("Number").AddColumn("Word").AddColumn("Type");
if (!ci->GetBadWordCount()) if (!ci->GetBadWordCount())
{ {
@@ -86,7 +86,7 @@ class CommandBSBadwords : public Command
entry["Number"] = stringify(Number); entry["Number"] = stringify(Number);
entry["Word"] = bw->word; entry["Word"] = bw->word;
entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : "")); entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : ""));
this->list.addEntry(entry); this->list.AddEntry(entry);
} }
} }
nl_list(list, ci, word); nl_list(list, ci, word);
@@ -105,11 +105,11 @@ class CommandBSBadwords : public Command
entry["Number"] = stringify(i + 1); entry["Number"] = stringify(i + 1);
entry["Word"] = bw->word; entry["Word"] = bw->word;
entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : "")); entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : ""));
list.addEntry(entry); list.AddEntry(entry);
} }
} }
if (list.isEmpty()) if (list.IsEmpty())
source.Reply(_("No matching entries on %s badword list."), ci->name.c_str()); source.Reply(_("No matching entries on %s badword list."), ci->name.c_str());
else else
{ {
@@ -241,7 +241,7 @@ class CommandBSBadwords : public Command
return; return;
} }
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -254,7 +254,7 @@ class CommandBSBadwords : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, channel bad words list modification is temporarily disabled.")); source.Reply(_("Sorry, channel bad words list modification is temporarily disabled."));
return; return;
+31 -72
View File
@@ -23,7 +23,7 @@ class CommandBSBot : public Command
const Anope::string &host = params[3]; const Anope::string &host = params[3];
const Anope::string &real = params[4]; const Anope::string &real = params[4];
if (findbot(nick)) if (BotInfo::Find(nick, true))
{ {
source.Reply(_("Bot \002%s\002 already exists."), nick.c_str()); source.Reply(_("Bot \002%s\002 already exists."), nick.c_str());
return; return;
@@ -47,46 +47,30 @@ class CommandBSBot : public Command
return; return;
} }
/* Check the nick is valid re RFC 2812 */ if (!IRCD->IsNickValid(nick))
if (isdigit(nick[0]) || nick[0] == '-')
{
source.Reply(_("Bot Nicks may only contain valid nick characters."));
return;
}
for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i)
if (!isvalidnick(nick[i]))
{
source.Reply(_("Bot Nicks may only contain valid nick characters."));
return;
}
/* check for hardcored ircd forbidden nicks */
if (!ircdproto->IsNickValid(nick))
{ {
source.Reply(_("Bot Nicks may only contain valid nick characters.")); source.Reply(_("Bot Nicks may only contain valid nick characters."));
return; return;
} }
/* Check the host is valid */ /* Check the host is valid */
if (!IsValidHost(host)) if (!IRCD->IsHostValid(host))
{ {
source.Reply(_("Bot Hosts may only contain valid host characters.")); source.Reply(_("Bot Hosts may only contain valid host characters."));
return; return;
} }
for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) if (!IRCD->IsIdentValid(user))
if (!isalnum(user[i])) {
{ source.Reply(_("Bot Idents may only contain valid characters."));
source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen); return;
return; }
}
/* We check whether the nick is registered, and inform the user /* We check whether the nick is registered, and inform the user
* if so. You need to drop the nick manually before you can use * if so. You need to drop the nick manually before you can use
* it as a bot nick from now on -GD * it as a bot nick from now on -GD
*/ */
if (findnick(nick)) if (NickAlias::Find(nick))
{ {
source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); source.Reply(NICK_ALREADY_REGISTERED, nick.c_str());
return; return;
@@ -116,16 +100,16 @@ class CommandBSBot : public Command
return; return;
} }
BotInfo *bi = findbot(oldnick); BotInfo *bi = BotInfo::Find(oldnick, true);
if (!bi) if (!bi)
{ {
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
return; return;
} }
if (!oldnick.equals_ci(nick) && nickIsServices(oldnick, false)) if (bi->HasFlag(BI_CONF))
{ {
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); source.Reply(_("Bot %s is not changable."), bi->nick.c_str());
return; return;
} }
@@ -147,12 +131,6 @@ class CommandBSBot : public Command
return; return;
} }
if (!oldnick.equals_ci(nick) && nickIsServices(nick, false))
{
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
return;
}
/* Checks whether there *are* changes. /* Checks whether there *are* changes.
* Case sensitive because we may want to change just the case. * Case sensitive because we may want to change just the case.
* And we must finally check that the nick is not already * And we must finally check that the nick is not already
@@ -164,42 +142,25 @@ class CommandBSBot : public Command
return; return;
} }
/* Check the nick is valid re RFC 2812 */ if (!IRCD->IsNickValid(nick))
if (isdigit(nick[0]) || nick[0] == '-')
{ {
source.Reply(_("Bot Nicks may only contain valid nick characters.")); source.Reply(_("Bot Nicks may only contain valid nick characters."));
return; return;
} }
for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i) if (!host.empty() && !IRCD->IsHostValid(host))
if (!isvalidnick(nick[i]))
{
source.Reply(_("Bot Nicks may only contain valid nick characters."));
return;
}
/* check for hardcored ircd forbidden nicks */
if (!ircdproto->IsNickValid(nick))
{
source.Reply(_("Bot Nicks may only contain valid nick characters."));
return;
}
if (!host.empty() && !IsValidHost(host))
{ {
source.Reply(_("Bot Hosts may only contain valid host characters.")); source.Reply(_("Bot Hosts may only contain valid host characters."));
return; return;
} }
if (!user.empty()) if (!user.empty() && !IRCD->IsIdentValid(user))
for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) {
if (!isalnum(user[i])) source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen);
{ return;
source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen); }
return;
}
if (!nick.equals_ci(bi->nick) && findbot(nick)) if (!nick.equals_ci(bi->nick) && BotInfo::Find(nick, true))
{ {
source.Reply(_("Bot \002%s\002 already exists."), nick.c_str()); source.Reply(_("Bot \002%s\002 already exists."), nick.c_str());
return; return;
@@ -211,7 +172,7 @@ class CommandBSBot : public Command
* if so. You need to drop the nick manually before you can use * if so. You need to drop the nick manually before you can use
* it as a bot nick from now on -GD * it as a bot nick from now on -GD
*/ */
if (findnick(nick)) if (NickAlias::Find(nick))
{ {
source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); source.Reply(NICK_ALREADY_REGISTERED, nick.c_str());
return; return;
@@ -219,19 +180,17 @@ class CommandBSBot : public Command
/* The new nick is really different, so we remove the Q line for the old nick. */ /* The new nick is really different, so we remove the Q line for the old nick. */
XLine x_del(bi->nick); XLine x_del(bi->nick);
ircdproto->SendSQLineDel(&x_del); IRCD->SendSQLineDel(&x_del);
/* Add a Q line for the new nick */ /* Add a Q line for the new nick */
XLine x(nick, "Reserved for services"); XLine x(nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x); IRCD->SendSQLine(NULL, &x);
} }
if (!user.empty()) if (!user.empty())
ircdproto->SendQuit(bi, "Quit: Be right back"); IRCD->SendQuit(bi, "Quit: Be right back");
else else
{ IRCD->SendNickChange(bi, nick);
ircdproto->SendChangeBotNick(bi, nick);
}
if (!nick.equals_cs(bi->nick)) if (!nick.equals_cs(bi->nick))
bi->SetNewNick(nick); bi->SetNewNick(nick);
@@ -245,7 +204,7 @@ class CommandBSBot : public Command
if (!user.empty()) if (!user.empty())
{ {
ircdproto->SendClientIntroduction(bi); IRCD->SendClientIntroduction(bi);
bi->RejoinAll(); bi->RejoinAll();
} }
@@ -266,16 +225,16 @@ class CommandBSBot : public Command
return; return;
} }
BotInfo *bi = findbot(nick); BotInfo *bi = BotInfo::Find(nick, true);
if (!bi) if (!bi)
{ {
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); source.Reply(BOT_DOES_NOT_EXIST, nick.c_str());
return; return;
} }
if (nickIsServices(nick, false)) if (bi->HasFlag(BI_CONF))
{ {
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); source.Reply(_("Bot %s is not deletable."), bi->nick.c_str());
return; return;
} }
@@ -284,7 +243,7 @@ class CommandBSBot : public Command
Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; Log(LOG_ADMIN, source, this) << "DEL " << bi->nick;
source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str());
bi->destroy(); bi->Destroy();
return; return;
} }
public: public:
@@ -300,7 +259,7 @@ class CommandBSBot : public Command
{ {
const Anope::string &cmd = params[0]; const Anope::string &cmd = params[0];
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, bot modification is temporarily disabled.")); source.Reply(_("Sorry, bot modification is temporarily disabled."));
return; return;
+2 -2
View File
@@ -27,7 +27,7 @@ class CommandBSBotList : public Command
unsigned count = 0; unsigned count = 0;
ListFormatter list; ListFormatter list;
list.addColumn("Nick").addColumn("Mask"); list.AddColumn("Nick").AddColumn("Mask");
for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
{ {
@@ -39,7 +39,7 @@ class CommandBSBotList : public Command
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Nick"] = (bi->HasFlag(BI_PRIVATE) ? "* " : "") + bi->nick; entry["Nick"] = (bi->HasFlag(BI_PRIVATE) ? "* " : "") + bi->nick;
entry["Mask"] = bi->GetIdent() + "@" + bi->host; entry["Mask"] = bi->GetIdent() + "@" + bi->host;
list.addEntry(entry); list.AddEntry(entry);
} }
} }
+4 -4
View File
@@ -26,7 +26,7 @@ class CommandBSSay : public Command
{ {
const Anope::string &text = params[1]; const Anope::string &text = params[1];
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -57,7 +57,7 @@ class CommandBSSay : public Command
return; return;
} }
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); IRCD->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str());
ci->bi->lastmsg = Anope::CurTime; ci->bi->lastmsg = Anope::CurTime;
// XXX need a way to find if someone is overriding this // XXX need a way to find if someone is overriding this
@@ -88,7 +88,7 @@ class CommandBSAct : public Command
{ {
Anope::string message = params[1]; Anope::string message = params[1];
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -117,7 +117,7 @@ class CommandBSAct : public Command
while ((i = message.find(1)) && i != Anope::string::npos) while ((i = message.find(1)) && i != Anope::string::npos)
message.erase(i, 1); message.erase(i, 1);
ircdproto->SendAction(ci->bi, ci->name, "%s", message.c_str()); IRCD->SendAction(ci->bi, ci->name, "%s", message.c_str());
ci->bi->lastmsg = Anope::CurTime; ci->bi->lastmsg = Anope::CurTime;
// XXX Need to be able to find if someone is overriding this. // XXX Need to be able to find if someone is overriding this.
+6 -6
View File
@@ -44,7 +44,7 @@ class CommandBSInfo : public Command
{ {
if (!buf.empty()) if (!buf.empty())
buf += ", "; buf += ", ";
buf += translate(nc, option); buf += Language::Translate(nc, option);
} }
} }
@@ -59,7 +59,7 @@ class CommandBSInfo : public Command
{ {
const Anope::string &query = params[0]; const Anope::string &query = params[0];
const BotInfo *bi = findbot(query); const BotInfo *bi = BotInfo::Find(query, true);
ChannelInfo *ci; ChannelInfo *ci;
InfoFormatter info(source.nc); InfoFormatter info(source.nc);
@@ -68,7 +68,7 @@ class CommandBSInfo : public Command
source.Reply(_("Information for bot \002%s\002:"), bi->nick.c_str()); source.Reply(_("Information for bot \002%s\002:"), bi->nick.c_str());
info[_("Mask")] = bi->GetIdent() + "@" + bi->host; info[_("Mask")] = bi->GetIdent() + "@" + bi->host;
info[_("Real name")] = bi->realname; info[_("Real name")] = bi->realname;
info[_("Created")] = do_strftime(bi->created); info[_("Created")] = Anope::strftime(bi->created);
info[_("Options")] = bi->HasFlag(BI_PRIVATE) ? _("Private") : _("None"); info[_("Options")] = bi->HasFlag(BI_PRIVATE) ? _("Private") : _("None");
info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)"; info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)";
@@ -87,7 +87,7 @@ class CommandBSInfo : public Command
} }
} }
else if ((ci = cs_findchan(query))) else if ((ci = ChannelInfo::Find(query)))
{ {
if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration")) if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration"))
{ {
@@ -98,8 +98,8 @@ class CommandBSInfo : public Command
source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); source.Reply(CHAN_INFO_HEADER, ci->name.c_str());
info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet"; info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet";
Anope::string enabled = translate(source.nc, _("Enabled")); Anope::string enabled = Language::Translate(source.nc, _("Enabled"));
Anope::string disabled = translate(source.nc, _("Disabled")); Anope::string disabled = Language::Translate(source.nc, _("Disabled"));
if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) if (ci->botflags.HasFlag(BS_KICK_BADWORDS))
{ {
+6 -8
View File
@@ -30,9 +30,9 @@ class CommandBSKick : public Command
const Anope::string &value = params[2]; const Anope::string &value = params[2];
const Anope::string &ttb = params.size() > 3 ? params[3] : ""; const Anope::string &ttb = params.size() > 3 ? params[3] : "";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (readonly) if (Anope::ReadOnly)
source.Reply(_("Sorry, kicker configuration is temporarily disabled.")); source.Reply(_("Sorry, kicker configuration is temporarily disabled."));
else if (ci == NULL) else if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -736,14 +736,12 @@ class BSKick : public Module
/* Should not use == here because bd.ttb[ttbtype] could possibly be > ci->ttb[ttbtype] /* Should not use == here because bd.ttb[ttbtype] could possibly be > ci->ttb[ttbtype]
* if the TTB was changed after it was not set (0) before and the user had already been * if the TTB was changed after it was not set (0) before and the user had already been
* kicked a few times. Bug #1056 - Adam */ * kicked a few times. Bug #1056 - Adam */
Anope::string mask;
bd.ttb[ttbtype] = 0; bd.ttb[ttbtype] = 0;
get_idealban(ci, u, mask); Anope::string mask = ci->GetIdealBan(u);
if (ci->c) ci->c->SetMode(NULL, CMODE_BAN, mask);
ci->c->SetMode(NULL, CMODE_BAN, mask);
FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask)); FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask));
} }
} }
@@ -756,7 +754,7 @@ class BSKick : public Module
if (!ci || !ci->bi || !ci->c || !u || u->server->IsULined() || !ci->c->FindUser(u)) if (!ci || !ci->bi || !ci->c || !u || u->server->IsULined() || !ci->c->FindUser(u))
return; return;
Anope::string fmt = translate(u, message); Anope::string fmt = Language::Translate(u, message);
va_start(args, message); va_start(args, message);
vsnprintf(buf, sizeof(buf), fmt.c_str(), args); vsnprintf(buf, sizeof(buf), fmt.c_str(), args);
va_end(args); va_end(args);
@@ -895,7 +893,7 @@ class BSKick : public Module
bool mustkick = false; bool mustkick = false;
/* Normalize the buffer */ /* Normalize the buffer */
Anope::string nbuf = normalizeBuffer(realbuf); Anope::string nbuf = Anope::NormalizeBuffer(realbuf);
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
{ {
+1 -1
View File
@@ -41,7 +41,7 @@ class CommandBSSet : public Command
const CommandInfo &info = it->second; const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0) if (c_name.find_ci(this_name + " ") == 0)
{ {
service_reference<Command> command("Command", info.name); ServiceReference<Command> command("Command", info.name);
if (command) if (command)
{ {
source.command = it->first; source.command = it->first;
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandBSSetDontKickOps : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandBSSetDontKickOps : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, bot option setting is temporarily disabled.")); source.Reply(_("Sorry, bot option setting is temporarily disabled."));
return; return;
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandBSSetDontKickVoices : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandBSSetDontKickVoices : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, bot option setting is temporarily disabled.")); source.Reply(_("Sorry, bot option setting is temporarily disabled."));
return; return;
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandBSSetFantasy : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1]; const Anope::string &value = params[1];
if (ci == NULL) if (ci == NULL)
@@ -39,7 +39,7 @@ class CommandBSSetFantasy : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, bot option setting is temporarily disabled.")); source.Reply(_("Sorry, bot option setting is temporarily disabled."));
return; return;
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandBSSetGreet : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1]; const Anope::string &value = params[1];
if (ci == NULL) if (ci == NULL)
@@ -39,7 +39,7 @@ class CommandBSSetGreet : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, bot option setting is temporarily disabled.")); source.Reply(_("Sorry, bot option setting is temporarily disabled."));
return; return;
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandBSSetNoBot : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1]; const Anope::string &value = params[1];
if (ci == NULL) if (ci == NULL)
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandBSSetPrivate : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
BotInfo *bi = findbot(params[0]); BotInfo *bi = BotInfo::Find(params[0], true);
const Anope::string &value = params[1]; const Anope::string &value = params[1];
if (bi == NULL) if (bi == NULL)
+35 -35
View File
@@ -36,12 +36,12 @@ class AccessChanAccess : public ChanAccess
return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name); return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name);
} }
Anope::string Serialize() const Anope::string AccessSerialize() const
{ {
return stringify(this->level); return stringify(this->level);
} }
void Unserialize(const Anope::string &data) anope_override void AccessUnserialize(const Anope::string &data) anope_override
{ {
this->level = convertTo<int>(data); this->level = convertTo<int>(data);
} }
@@ -119,7 +119,7 @@ class CommandCSAccess : public Command
bool override = false; bool override = false;
if ((!highest || *highest <= tmp_access) && !u_access.Founder) if ((!highest || *highest <= tmp_access) && !u_access.founder)
{ {
if (source.HasPriv("chanserv/access/modify")) if (source.HasPriv("chanserv/access/modify"))
override = true; override = true;
@@ -130,9 +130,9 @@ class CommandCSAccess : public Command
} }
} }
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask))
{ {
User *targ = finduser(mask); User *targ = User::Find(mask, true);
if (targ != NULL) if (targ != NULL)
mask = "*!*@" + targ->GetDisplayedHost(); mask = "*!*@" + targ->GetDisplayedHost();
else else
@@ -148,7 +148,7 @@ class CommandCSAccess : public Command
if (mask.equals_ci(access->mask)) if (mask.equals_ci(access->mask))
{ {
/* Don't allow lowering from a level >= u_level */ /* Don't allow lowering from a level >= u_level */
if ((!highest || *access >= *highest) && !u_access.Founder && !source.HasPriv("chanserv/access/modify")) if ((!highest || *access >= *highest) && !u_access.founder && !source.HasPriv("chanserv/access/modify"))
{ {
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
return; return;
@@ -164,7 +164,7 @@ class CommandCSAccess : public Command
return; return;
} }
service_reference<AccessProvider> provider("AccessProvider", "access/access"); ServiceReference<AccessProvider> provider("AccessProvider", "access/access");
if (!provider) if (!provider)
return; return;
AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create());
@@ -188,9 +188,9 @@ class CommandCSAccess : public Command
{ {
Anope::string mask = params[2]; Anope::string mask = params[2];
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask))
{ {
User *targ = finduser(mask); User *targ = User::Find(mask, true);
if (targ != NULL) if (targ != NULL)
mask = "*!*@" + targ->GetDisplayedHost(); mask = "*!*@" + targ->GetDisplayedHost();
else else
@@ -209,12 +209,12 @@ class CommandCSAccess : public Command
CommandSource &source; CommandSource &source;
ChannelInfo *ci; ChannelInfo *ci;
Command *c; Command *c;
unsigned Deleted; unsigned deleted;
Anope::string Nicks; Anope::string Nicks;
bool Denied; bool Denied;
bool override; bool override;
public: public:
AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), Denied(false), override(false) AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), Denied(false), override(false)
{ {
if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify"))
this->override = true; this->override = true;
@@ -222,18 +222,18 @@ class CommandCSAccess : public Command
~AccessDelCallback() ~AccessDelCallback()
{ {
if (Denied && !Deleted) if (Denied && !deleted)
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (!Deleted) else if (!deleted)
source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
else else
{ {
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks;
if (Deleted == 1) if (deleted == 1)
source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str()); source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str());
else else
source.Reply(_("Deleted %d entries from %s access list."), Deleted, ci->name.c_str()); source.Reply(_("Deleted %d entries from %s access list."), deleted, ci->name.c_str());
} }
} }
@@ -247,13 +247,13 @@ class CommandCSAccess : public Command
AccessGroup u_access = source.AccessFor(ci); AccessGroup u_access = source.AccessFor(ci);
const ChanAccess *u_highest = u_access.Highest(); const ChanAccess *u_highest = u_access.Highest();
if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(source.nc->display)) if ((!u_highest || *u_highest <= *access) && !u_access.founder && !this->override && !access->mask.equals_ci(source.nc->display))
{ {
Denied = true; Denied = true;
return; return;
} }
++Deleted; ++deleted;
if (!Nicks.empty()) if (!Nicks.empty())
Nicks += ", " + access->mask; Nicks += ", " + access->mask;
else else
@@ -277,12 +277,12 @@ class CommandCSAccess : public Command
ChanAccess *access = ci->GetAccess(i - 1); ChanAccess *access = ci->GetAccess(i - 1);
if (mask.equals_ci(access->mask)) if (mask.equals_ci(access->mask))
{ {
if (!access->mask.equals_ci(source.nc->display) && !u_access.Founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) if (!access->mask.equals_ci(source.nc->display) && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify"))
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else else
{ {
source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str()); source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str());
bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display);
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask;
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access));
@@ -333,7 +333,7 @@ class CommandCSAccess : public Command
if (access->last_seen == 0) if (access->last_seen == 0)
timebuf = "Never"; timebuf = "Never";
else else
timebuf = do_strftime(access->last_seen, NULL, true); timebuf = Anope::strftime(access->last_seen, NULL, true);
} }
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
@@ -342,7 +342,7 @@ class CommandCSAccess : public Command
entry["Mask"] = access->mask; entry["Mask"] = access->mask;
entry["By"] = access->creator; entry["By"] = access->creator;
entry["Last seen"] = timebuf; entry["Last seen"] = timebuf;
this->list.addEntry(entry); this->list.AddEntry(entry);
} }
} }
nl_list(list, ci, nick); nl_list(list, ci, nick);
@@ -367,7 +367,7 @@ class CommandCSAccess : public Command
if (access->last_seen == 0) if (access->last_seen == 0)
timebuf = "Never"; timebuf = "Never";
else else
timebuf = do_strftime(access->last_seen, NULL, true); timebuf = Anope::strftime(access->last_seen, NULL, true);
} }
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
@@ -376,11 +376,11 @@ class CommandCSAccess : public Command
entry["Mask"] = access->mask; entry["Mask"] = access->mask;
entry["By"] = access->creator; entry["By"] = access->creator;
entry["Last seen"] = timebuf; entry["Last seen"] = timebuf;
list.addEntry(entry); list.AddEntry(entry);
} }
} }
if (list.isEmpty()) if (list.IsEmpty())
source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
else else
{ {
@@ -407,7 +407,7 @@ class CommandCSAccess : public Command
} }
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Level").addColumn("Mask"); list.AddColumn("Number").AddColumn("Level").AddColumn("Mask");
this->ProcessList(source, ci, params, list); this->ProcessList(source, ci, params, list);
} }
@@ -420,7 +420,7 @@ class CommandCSAccess : public Command
} }
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Level").addColumn("Mask").addColumn("By").addColumn("Last seen"); list.AddColumn("Number").AddColumn("Level").AddColumn("Mask").AddColumn("By").AddColumn("Last seen");
this->ProcessList(source, ci, params, list); this->ProcessList(source, ci, params, list);
} }
@@ -460,7 +460,7 @@ class CommandCSAccess : public Command
const Anope::string &nick = params.size() > 2 ? params[2] : ""; const Anope::string &nick = params.size() > 2 ? params[2] : "";
const Anope::string &s = params.size() > 3 ? params[3] : ""; const Anope::string &s = params.size() > 3 ? params[3] : "";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -480,7 +480,7 @@ class CommandCSAccess : public Command
has_access = true; has_access = true;
else if (is_del) else if (is_del)
{ {
const NickAlias *na = findnick(nick); const NickAlias *na = NickAlias::Find(nick);
if (na && na->nc == source.GetAccount()) if (na && na->nc == source.GetAccount())
has_access = true; has_access = true;
} }
@@ -492,7 +492,7 @@ class CommandCSAccess : public Command
this->OnSyntaxError(source, cmd); this->OnSyntaxError(source, cmd);
else if (!has_access) else if (!has_access)
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (readonly && !is_list) else if (Anope::ReadOnly && !is_list)
source.Reply(_("Sorry, channel access list modification is temporarily disabled.")); source.Reply(_("Sorry, channel access list modification is temporarily disabled."));
else if (cmd.equals_ci("ADD")) else if (cmd.equals_ci("ADD"))
this->DoAdd(source, ci, params); this->DoAdd(source, ci, params);
@@ -652,7 +652,7 @@ class CommandCSLevels : public Command
source.Reply(_("Access level settings for channel %s:"), ci->name.c_str()); source.Reply(_("Access level settings for channel %s:"), ci->name.c_str());
ListFormatter list; ListFormatter list;
list.addColumn("Name").addColumn("Level"); list.AddColumn("Name").AddColumn("Level");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
@@ -671,7 +671,7 @@ class CommandCSLevels : public Command
else else
entry["Level"] = stringify(j); entry["Level"] = stringify(j);
list.addEntry(entry); list.AddEntry(entry);
} }
std::vector<Anope::string> replies; std::vector<Anope::string> replies;
@@ -709,7 +709,7 @@ class CommandCSLevels : public Command
const Anope::string &what = params.size() > 2 ? params[2] : ""; const Anope::string &what = params.size() > 2 ? params[2] : "";
const Anope::string &s = params.size() > 3 ? params[3] : ""; const Anope::string &s = params.size() > 3 ? params[3] : "";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -744,7 +744,7 @@ class CommandCSLevels : public Command
source.Reply(_("The following feature/function names are understood.")); source.Reply(_("The following feature/function names are understood."));
ListFormatter list; ListFormatter list;
list.addColumn("Name").addColumn("Description"); list.AddColumn("Name").AddColumn("Description");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
for (unsigned i = 0; i < privs.size(); ++i) for (unsigned i = 0; i < privs.size(); ++i)
@@ -752,8 +752,8 @@ class CommandCSLevels : public Command
const Privilege &p = privs[i]; const Privilege &p = privs[i];
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Name"] = p.name; entry["Name"] = p.name;
entry["Description"] = translate(source.nc, p.desc.c_str()); entry["Description"] = Language::Translate(source.nc, p.desc.c_str());
list.addEntry(entry); list.AddEntry(entry);
} }
std::vector<Anope::string> replies; std::vector<Anope::string> replies;
+24 -24
View File
@@ -52,7 +52,7 @@ class CommandCSAKick : public Command
{ {
Anope::string mask = params[2]; Anope::string mask = params[2];
Anope::string reason = params.size() > 3 ? params[3] : ""; Anope::string reason = params.size() > 3 ? params[3] : "";
const NickAlias *na = findnick(mask); const NickAlias *na = NickAlias::Find(mask);
NickCore *nc = NULL; NickCore *nc = NULL;
const AutoKick *akick; const AutoKick *akick;
@@ -178,34 +178,34 @@ class CommandCSAKick : public Command
CommandSource &source; CommandSource &source;
ChannelInfo *ci; ChannelInfo *ci;
Command *c; Command *c;
unsigned Deleted; unsigned deleted;
public: public:
AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0) AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0)
{ {
} }
~AkickDelCallback() ~AkickDelCallback()
{ {
bool override = !source.AccessFor(ci).HasPriv("AKICK"); bool override = !source.AccessFor(ci).HasPriv("AKICK");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << deleted << (deleted == 1 ? " entry" : " entries");
if (!Deleted) if (!deleted)
source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
else if (Deleted == 1) else if (deleted == 1)
source.Reply(_("Deleted 1 entry from %s autokick list."), ci->name.c_str()); source.Reply(_("Deleted 1 entry from %s autokick list."), ci->name.c_str());
else else
source.Reply(_("Deleted %d entries from %s autokick list."), Deleted, ci->name.c_str()); source.Reply(_("Deleted %d entries from %s autokick list."), deleted, ci->name.c_str());
} }
void HandleNumber(unsigned Number) anope_override void HandleNumber(unsigned number) anope_override
{ {
if (!Number || Number > ci->GetAkickCount()) if (!number || number > ci->GetAkickCount())
return; return;
FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1))); FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(number - 1)));
++Deleted; ++deleted;
ci->EraseAkick(Number - 1); ci->EraseAkick(number - 1);
} }
} }
delcallback(source, ci, this, mask); delcallback(source, ci, this, mask);
@@ -213,7 +213,7 @@ class CommandCSAKick : public Command
} }
else else
{ {
const NickAlias *na = findnick(mask); const NickAlias *na = NickAlias::Find(mask);
const NickCore *nc = na ? *na->nc : NULL; const NickCore *nc = na ? *na->nc : NULL;
for (i = 0, end = ci->GetAkickCount(); i < end; ++i) for (i = 0, end = ci->GetAkickCount(); i < end; ++i)
@@ -266,11 +266,11 @@ class CommandCSAKick : public Command
Anope::string timebuf, lastused; Anope::string timebuf, lastused;
if (akick->addtime) if (akick->addtime)
timebuf = do_strftime(akick->addtime, NULL, false); timebuf = Anope::strftime(akick->addtime, NULL, false);
else else
timebuf = UNKNOWN; timebuf = UNKNOWN;
if (akick->last_used) if (akick->last_used)
lastused = do_strftime(akick->last_used, NULL, false); lastused = Anope::strftime(akick->last_used, NULL, false);
else else
lastused = UNKNOWN; lastused = UNKNOWN;
@@ -281,7 +281,7 @@ class CommandCSAKick : public Command
entry["Created"] = timebuf; entry["Created"] = timebuf;
entry["Last used"] = lastused; entry["Last used"] = lastused;
entry["Reason"] = akick->reason; entry["Reason"] = akick->reason;
this->list.addEntry(entry); this->list.AddEntry(entry);
} }
} }
nl_list(list, ci, mask); nl_list(list, ci, mask);
@@ -303,11 +303,11 @@ class CommandCSAKick : public Command
Anope::string timebuf, lastused; Anope::string timebuf, lastused;
if (akick->addtime) if (akick->addtime)
timebuf = do_strftime(akick->addtime); timebuf = Anope::strftime(akick->addtime);
else else
timebuf = UNKNOWN; timebuf = UNKNOWN;
if (akick->last_used) if (akick->last_used)
lastused = do_strftime(akick->last_used); lastused = Anope::strftime(akick->last_used);
else else
lastused = UNKNOWN; lastused = UNKNOWN;
@@ -318,11 +318,11 @@ class CommandCSAKick : public Command
entry["Created"] = timebuf; entry["Created"] = timebuf;
entry["Last used"] = lastused; entry["Last used"] = lastused;
entry["Reason"] = akick->reason; entry["Reason"] = akick->reason;
list.addEntry(entry); list.AddEntry(entry);
} }
} }
if (list.isEmpty()) if (list.IsEmpty())
source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
else else
{ {
@@ -347,7 +347,7 @@ class CommandCSAKick : public Command
} }
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Mask").addColumn("Reason"); list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
this->ProcessList(source, ci, params, list); this->ProcessList(source, ci, params, list);
} }
@@ -360,7 +360,7 @@ class CommandCSAKick : public Command
} }
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Mask").addColumn("Creator").addColumn("Created").addColumn("Last used").addColumn("Reason"); list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Last used").AddColumn("Reason");
this->ProcessList(source, ci, params, list); this->ProcessList(source, ci, params, list);
} }
@@ -416,7 +416,7 @@ class CommandCSAKick : public Command
Anope::string cmd = params[1]; Anope::string cmd = params[1];
Anope::string mask = params.size() > 2 ? params[2] : ""; Anope::string mask = params.size() > 2 ? params[2] : "";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -427,7 +427,7 @@ class CommandCSAKick : public Command
this->OnSyntaxError(source, cmd); this->OnSyntaxError(source, cmd);
else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify")) else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify"))
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && readonly) else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && Anope::ReadOnly)
source.Reply(_("Sorry, channel autokick list modification is temporarily disabled.")); source.Reply(_("Sorry, channel autokick list modification is temporarily disabled."));
else if (cmd.equals_ci("ADD")) else if (cmd.equals_ci("ADD"))
this->DoAdd(source, ci, params); this->DoAdd(source, ci, params);
+1 -1
View File
@@ -52,7 +52,7 @@ class CommandCSAppendTopic : public Command
{ {
const Anope::string &newtopic = params[1]; const Anope::string &newtopic = params[1];
Channel *c = findchan(params[0]);; Channel *c = Channel::Find(params[0]);;
if (!c) if (!c)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
+5 -6
View File
@@ -29,7 +29,7 @@ class CommandCSBan : public Command
const Anope::string &target = params[1]; const Anope::string &target = params[1];
const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; const Anope::string &reason = params.size() > 2 ? params[2] : "Requested";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandCSBan : public Command
Channel *c = ci->c; Channel *c = ci->c;
User *u = source.GetUser(); User *u = source.GetUser();
User *u2 = finduser(target); User *u2 = User::Find(target, true);
AccessGroup u_access = source.AccessFor(ci); AccessGroup u_access = source.AccessFor(ci);
@@ -56,14 +56,13 @@ class CommandCSBan : public Command
if (u != u2 && ci->HasFlag(CI_PEACE) && u2_access >= u_access) if (u != u2 && ci->HasFlag(CI_PEACE) && u2_access >= u_access)
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (matches_list(ci->c, u2, CMODE_EXCEPT)) else if (ci->c->MatchesList(u2, CMODE_EXCEPT))
source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str());
else if (u2->IsProtected()) else if (u2->IsProtected())
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else else
{ {
Anope::string mask; Anope::string mask = ci->GetIdealBan(u2);
get_idealban(ci, u2, mask);
// XXX need a way to detect if someone is overriding // XXX need a way to detect if someone is overriding
Log(LOG_COMMAND, source, this, ci) << "for " << mask; Log(LOG_COMMAND, source, this, ci) << "for " << mask;
@@ -99,7 +98,7 @@ class CommandCSBan : public Command
if (u != uc->user && ci->HasFlag(CI_PEACE) && u2_access >= u_access) if (u != uc->user && ci->HasFlag(CI_PEACE) && u2_access >= u_access)
continue; continue;
else if (matches_list(ci->c, uc->user, CMODE_EXCEPT)) else if (ci->c->MatchesList(uc->user, CMODE_EXCEPT))
continue; continue;
else if (uc->user->IsProtected()) else if (uc->user->IsProtected())
continue; continue;
+1 -1
View File
@@ -26,7 +26,7 @@ class CommandCSClearUsers : public Command
{ {
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
Channel *c = findchan(chan); Channel *c = Channel::Find(chan);
Anope::string modebuf; Anope::string modebuf;
if (!c) if (!c)
+6 -6
View File
@@ -29,7 +29,7 @@ public:
Anope::string what = params.size() > 2 ? params[2] : ""; Anope::string what = params.size() > 2 ? params[2] : "";
User *u = source.GetUser(); User *u = source.GetUser();
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -42,7 +42,7 @@ public:
return; return;
} }
ChannelInfo *target_ci = cs_findchan(target); ChannelInfo *target_ci = ChannelInfo::Find(target);
if (!target_ci) if (!target_ci)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, target.c_str());
@@ -59,11 +59,11 @@ public:
if (what.empty()) if (what.empty())
{ {
target_ci->destroy(); target_ci->Destroy();
target_ci = new ChannelInfo(*ci); target_ci = new ChannelInfo(*ci);
target_ci->name = target; target_ci->name = target;
(*RegisteredChannelList)[target_ci->name] = target_ci; (*RegisteredChannelList)[target_ci->name] = target_ci;
target_ci->c = findchan(target_ci->name); target_ci->c = Channel::Find(target_ci->name);
if (target_ci->c) if (target_ci->c)
{ {
target_ci->c->ci = target_ci; target_ci->c->ci = target_ci;
@@ -88,7 +88,7 @@ public:
target_ci->c->SetMode(NULL, CMODE_PERM); target_ci->c->SetMode(NULL, CMODE_PERM);
if (target_ci->bi && target_ci->c->FindUser(target_ci->bi) == NULL) if (target_ci->bi && target_ci->c->FindUser(target_ci->bi) == NULL)
target_ci->bi->Join(target_ci->c, &Config->BotModeList); target_ci->bi->Join(target_ci->c, &ModeManager::DefaultBotModes);
} }
if (target_ci->c && !target_ci->c->topic.empty()) if (target_ci->c && !target_ci->c->topic.empty())
@@ -117,7 +117,7 @@ public:
newaccess->creator = taccess->creator; newaccess->creator = taccess->creator;
newaccess->last_seen = taccess->last_seen; newaccess->last_seen = taccess->last_seen;
newaccess->created = taccess->created; newaccess->created = taccess->created;
newaccess->Unserialize(taccess->Serialize()); newaccess->AccessUnserialize(taccess->AccessSerialize());
target_ci->AddAccess(newaccess); target_ci->AddAccess(newaccess);
} }
+3 -3
View File
@@ -26,13 +26,13 @@ class CommandCSDrop : public Command
{ {
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
if (readonly) if (Anope::ReadOnly)
{ {
source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE? source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE?
return; return;
} }
ChannelInfo *ci = cs_findchan(chan); ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -57,7 +57,7 @@ class CommandCSDrop : public Command
FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci)); FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci));
Channel *c = ci->c; Channel *c = ci->c;
ci->destroy(); ci->Destroy();
source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str()); source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str());
+7 -9
View File
@@ -50,7 +50,7 @@ class CommandCSEnforce : public Command
Log(LOG_COMMAND, source, this) << "to enforce secureops"; Log(LOG_COMMAND, source, this) << "to enforce secureops";
/* Dirty hack to allow chan_set_correct_modes to work ok. /* Dirty hack to allow Channel::SetCorrectModes to work ok.
* We pretend like SECUREOPS is on so it doesn't ignore that * We pretend like SECUREOPS is on so it doesn't ignore that
* part of the code. This way we can enforce SECUREOPS even * part of the code. This way we can enforce SECUREOPS even
* if it's off. * if it's off.
@@ -66,7 +66,7 @@ class CommandCSEnforce : public Command
{ {
UserContainer *uc = *it; UserContainer *uc = *it;
chan_set_correct_modes(uc->user, c, 0, false); c->SetCorrectModes(uc->user, false, false);
} }
if (hadsecureops) if (hadsecureops)
@@ -95,9 +95,8 @@ class CommandCSEnforce : public Command
{ {
User *user = users[i]; User *user = users[i];
Anope::string mask; Anope::string mask = ci->GetIdealBan(user);
get_idealban(ci, user, mask); Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
c->SetMode(NULL, CMODE_BAN, mask); c->SetMode(NULL, CMODE_BAN, mask);
c->Kick(NULL, user, "%s", reason.c_str()); c->Kick(NULL, user, "%s", reason.c_str());
} }
@@ -106,7 +105,6 @@ class CommandCSEnforce : public Command
void DoCModeR(CommandSource &source, Channel *c) void DoCModeR(CommandSource &source, Channel *c)
{ {
ChannelInfo *ci = c->ci; ChannelInfo *ci = c->ci;
Anope::string mask;
if (!ci) if (!ci)
return; return;
@@ -127,8 +125,8 @@ class CommandCSEnforce : public Command
{ {
User *user = users[i]; User *user = users[i];
get_idealban(ci, user, mask); Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN); Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
if (!c->HasMode(CMODE_REGISTEREDONLY)) if (!c->HasMode(CMODE_REGISTEREDONLY))
c->SetMode(NULL, CMODE_BAN, mask); c->SetMode(NULL, CMODE_BAN, mask);
c->Kick(NULL, user, "%s", reason.c_str()); c->Kick(NULL, user, "%s", reason.c_str());
@@ -145,7 +143,7 @@ class CommandCSEnforce : public Command
{ {
const Anope::string &what = params.size() > 1 ? params[1] : ""; const Anope::string &what = params.size() > 1 ? params[1] : "";
Channel *c = findchan(params[0]); Channel *c = Channel::Find(params[0]);
if (!c) if (!c)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
+16 -16
View File
@@ -15,7 +15,7 @@
struct EntryMsg : Serializable struct EntryMsg : Serializable
{ {
serialize_obj<ChannelInfo> ci; Serialize::Reference<ChannelInfo> ci;
Anope::string creator; Anope::string creator;
Anope::string message; Anope::string message;
time_t when; time_t when;
@@ -28,31 +28,31 @@ struct EntryMsg : Serializable
this->when = ct; this->when = ct;
} }
Serialize::Data serialize() const anope_override Serialize::Data Serialize() const anope_override
{ {
Serialize::Data data; Serialize::Data data;
data["ci"] << this->ci->name; data["ci"] << this->ci->name;
data["creator"] << this->creator; data["creator"] << this->creator;
data["message"] << this->message; data["message"] << this->message;
data["when"].setType(Serialize::DT_INT) << this->when; data["when"].SetType(Serialize::DT_INT) << this->when;
return data; return data;
} }
static Serializable* unserialize(Serializable *obj, Serialize::Data &data); static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
}; };
static unsigned MaxEntries = 0; static unsigned MaxEntries = 0;
struct EntryMessageList : serialize_checker<std::vector<EntryMsg *> >, ExtensibleItem struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >, ExtensibleItem
{ {
EntryMessageList() : serialize_checker<std::vector<EntryMsg *> >("EntryMsg") { } EntryMessageList() : Serialize::Checker<std::vector<EntryMsg *> >("EntryMsg") { }
}; };
Serializable* EntryMsg::unserialize(Serializable *obj, Serialize::Data &data) Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data)
{ {
ChannelInfo *ci = cs_findchan(data["ci"].astr()); ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr());
if (!ci) if (!ci)
return NULL; return NULL;
@@ -99,7 +99,7 @@ class CommandEntryMessage : public Command
source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str()); source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str());
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Creator").addColumn("Created").addColumn("Message"); list.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Message");
for (unsigned i = 0; i < (*messages)->size(); ++i) for (unsigned i = 0; i < (*messages)->size(); ++i)
{ {
EntryMsg *msg = (*messages)->at(i); EntryMsg *msg = (*messages)->at(i);
@@ -107,9 +107,9 @@ class CommandEntryMessage : public Command
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Number"] = stringify(i + 1); entry["Number"] = stringify(i + 1);
entry["Creator"] = msg->creator; entry["Creator"] = msg->creator;
entry["Created"] = do_strftime(msg->when); entry["Created"] = Anope::strftime(msg->when);
entry["Message"] = msg->message; entry["Message"] = msg->message;
list.addEntry(entry); list.AddEntry(entry);
} }
std::vector<Anope::string> replies; std::vector<Anope::string> replies;
@@ -159,7 +159,7 @@ class CommandEntryMessage : public Command
unsigned i = convertTo<unsigned>(message); unsigned i = convertTo<unsigned>(message);
if (i > 0 && i <= (*messages)->size()) if (i > 0 && i <= (*messages)->size())
{ {
(*messages)->at(i - 1)->destroy(); (*messages)->at(i - 1)->Destroy();
(*messages)->erase((*messages)->begin() + i - 1); (*messages)->erase((*messages)->begin() + i - 1);
if ((*messages)->empty()) if ((*messages)->empty())
ci->Shrink("cs_entrymsg"); ci->Shrink("cs_entrymsg");
@@ -182,7 +182,7 @@ class CommandEntryMessage : public Command
if (messages != NULL) if (messages != NULL)
{ {
for (unsigned i = 0; i < (*messages)->size(); ++i) for (unsigned i = 0; i < (*messages)->size(); ++i)
(*messages)->at(i)->destroy(); (*messages)->at(i)->Destroy();
(*messages)->clear(); (*messages)->clear();
ci->Shrink("cs_entrymsg"); ci->Shrink("cs_entrymsg");
} }
@@ -203,7 +203,7 @@ class CommandEntryMessage : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -258,11 +258,11 @@ class CommandEntryMessage : public Command
class CSEntryMessage : public Module class CSEntryMessage : public Module
{ {
SerializeType entrymsg_type; Serialize::Type entrymsg_type;
CommandEntryMessage commandentrymsg; CommandEntryMessage commandentrymsg;
public: public:
CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), entrymsg_type("EntryMsg", EntryMsg::unserialize), commandentrymsg(this) CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this)
{ {
this->SetAuthor("Anope"); this->SetAuthor("Anope");
+3 -3
View File
@@ -66,7 +66,7 @@ class CSStats : public Module
{ {
CommandCSStats commandcsstats; CommandCSStats commandcsstats;
CommandCSGStats commandcsgstats; CommandCSGStats commandcsgstats;
service_reference<SQLProvider> sql; ServiceReference<SQLProvider> sql;
MySQLInterface sqlinterface; MySQLInterface sqlinterface;
Anope::string prefix; Anope::string prefix;
public: public:
@@ -86,7 +86,7 @@ class CSStats : public Module
ConfigReader config; ConfigReader config;
prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
this->sql = service_reference<SQLProvider>("SQLProvider", engine); this->sql = ServiceReference<SQLProvider>("SQLProvider", engine);
} }
SQLResult RunQuery(const SQLQuery &query) SQLResult RunQuery(const SQLQuery &query)
@@ -108,7 +108,7 @@ class CSStats : public Module
Anope::string display; Anope::string display;
if (params.empty()) if (params.empty())
display = source.nc->display; display = source.nc->display;
else if (const NickAlias *na = findnick(params[0])) else if (const NickAlias *na = NickAlias::Find(params[0]))
display = na->nc->display; display = na->nc->display;
else else
{ {
+2 -2
View File
@@ -93,7 +93,7 @@ class CSTop : public Module
CommandCSGTop commandcsgtop; CommandCSGTop commandcsgtop;
CommandCSTop10 commandcstop10; CommandCSTop10 commandcstop10;
CommandCSGTop10 commandcsgtop10; CommandCSGTop10 commandcsgtop10;
service_reference<SQLProvider> sql; ServiceReference<SQLProvider> sql;
MySQLInterface sqlinterface; MySQLInterface sqlinterface;
Anope::string prefix; Anope::string prefix;
@@ -115,7 +115,7 @@ class CSTop : public Module
ConfigReader config; ConfigReader config;
prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
this->sql = service_reference<SQLProvider>("SQLProvider", engine); this->sql = ServiceReference<SQLProvider>("SQLProvider", engine);
} }
SQLResult RunQuery(const SQLQuery &query) SQLResult RunQuery(const SQLQuery &query)
+15 -15
View File
@@ -32,12 +32,12 @@ class FlagsChanAccess : public ChanAccess
return false; return false;
} }
Anope::string Serialize() const Anope::string AccessSerialize() const
{ {
return Anope::string(this->flags.begin(), this->flags.end()); return Anope::string(this->flags.begin(), this->flags.end());
} }
void Unserialize(const Anope::string &data) anope_override void AccessUnserialize(const Anope::string &data) anope_override
{ {
for (unsigned i = data.length(); i > 0; --i) for (unsigned i = data.length(); i > 0; --i)
this->flags.insert(data[i - 1]); this->flags.insert(data[i - 1]);
@@ -46,7 +46,7 @@ class FlagsChanAccess : public ChanAccess
static Anope::string DetermineFlags(const ChanAccess *access) static Anope::string DetermineFlags(const ChanAccess *access)
{ {
if (access->provider->name == "access/flags") if (access->provider->name == "access/flags")
return access->Serialize(); return access->AccessSerialize();
std::set<char> buffer; std::set<char> buffer;
@@ -86,9 +86,9 @@ class CommandCSFlags : public Command
AccessGroup u_access = source.AccessFor(ci); AccessGroup u_access = source.AccessFor(ci);
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask))
{ {
User *targ = finduser(mask); User *targ = User::Find(mask, true);
if (targ != NULL) if (targ != NULL)
mask = "*!*@" + targ->GetDisplayedHost(); mask = "*!*@" + targ->GetDisplayedHost();
else else
@@ -191,7 +191,7 @@ class CommandCSFlags : public Command
return; return;
} }
service_reference<AccessProvider> provider("AccessProvider", "access/flags"); ServiceReference<AccessProvider> provider("AccessProvider", "access/flags");
if (!provider) if (!provider)
return; return;
FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
@@ -209,8 +209,8 @@ class CommandCSFlags : public Command
FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access));
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize(); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize();
source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->Serialize().c_str()); source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str());
return; return;
} }
@@ -227,7 +227,7 @@ class CommandCSFlags : public Command
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Mask").addColumn("Flags").addColumn("Creator").addColumn("Created"); list.AddColumn("Number").AddColumn("Mask").AddColumn("Flags").AddColumn("Creator").AddColumn("Created");
unsigned count = 0; unsigned count = 0;
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
@@ -257,11 +257,11 @@ class CommandCSFlags : public Command
entry["Mask"] = access->mask; entry["Mask"] = access->mask;
entry["Flags"] = FlagsChanAccess::DetermineFlags(access); entry["Flags"] = FlagsChanAccess::DetermineFlags(access);
entry["Creator"] = access->creator; entry["Creator"] = access->creator;
entry["Created"] = do_strftime(access->created, source.nc, true); entry["Created"] = Anope::strftime(access->created, source.nc, true);
list.addEntry(entry); list.AddEntry(entry);
} }
if (list.isEmpty()) if (list.IsEmpty())
source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
else else
{ {
@@ -311,7 +311,7 @@ class CommandCSFlags : public Command
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
const Anope::string &cmd = params[1]; const Anope::string &cmd = params[1];
ChannelInfo *ci = cs_findchan(chan); ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
@@ -329,7 +329,7 @@ class CommandCSFlags : public Command
if (!has_access) if (!has_access)
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (readonly && !is_list) else if (Anope::ReadOnly && !is_list)
source.Reply(_("Sorry, channel access list modification is temporarily disabled.")); source.Reply(_("Sorry, channel access list modification is temporarily disabled."));
else if (cmd.equals_ci("MODIFY")) else if (cmd.equals_ci("MODIFY"))
this->DoModify(source, ci, params); this->DoModify(source, ci, params);
@@ -374,7 +374,7 @@ class CommandCSFlags : public Command
Privilege *p = PrivilegeManager::FindPrivilege(it->second); Privilege *p = PrivilegeManager::FindPrivilege(it->second);
if (p == NULL) if (p == NULL)
continue; continue;
source.Reply(" %c - %s", it->first, translate(source.nc, p->desc.c_str())); source.Reply(" %c - %s", it->first, Language::Translate(source.nc, p->desc.c_str()));
} }
return true; return true;
+1 -1
View File
@@ -26,7 +26,7 @@ class CommandCSGetKey : public Command
{ {
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+5 -5
View File
@@ -22,7 +22,7 @@ class CommandCSInfo : public Command
if (!buf.empty()) if (!buf.empty())
buf += ", "; buf += ", ";
buf += translate(nc, str); buf += Language::Translate(nc, str);
} }
} }
@@ -39,7 +39,7 @@ class CommandCSInfo : public Command
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
NickCore *nc = source.nc; NickCore *nc = source.nc;
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -65,8 +65,8 @@ class CommandCSInfo : public Command
if (!ci->desc.empty()) if (!ci->desc.empty())
info["Description"] = ci->desc; info["Description"] = ci->desc;
info["Registered"] = do_strftime(ci->time_registered); info["Registered"] = Anope::strftime(ci->time_registered);
info["Last used"] = do_strftime(ci->last_used); info["Last used"] = Anope::strftime(ci->last_used);
const ModeLock *secret = ci->GetMLock(CMODE_SECRET); const ModeLock *secret = ci->GetMLock(CMODE_SECRET);
if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode(CMODE_SECRET))))) if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode(CMODE_SECRET)))))
@@ -103,7 +103,7 @@ class CommandCSInfo : public Command
info["Mode lock"] = ml; info["Mode lock"] = ml;
if (!ci->HasFlag(CI_NO_EXPIRE)) if (!ci->HasFlag(CI_NO_EXPIRE))
info["Expires on"] = do_strftime(ci->last_used + Config->CSExpire); info["Expires on"] = Anope::strftime(ci->last_used + Config->CSExpire);
} }
if (ci->HasFlag(CI_SUSPENDED)) if (ci->HasFlag(CI_SUSPENDED))
{ {
+3 -3
View File
@@ -27,7 +27,7 @@ class CommandCSInvite : public Command
const Anope::string &chan = params[0]; const Anope::string &chan = params[0];
User *u = source.GetUser(); User *u = source.GetUser();
Channel *c = findchan(chan); Channel *c = Channel::Find(chan);
if (!c) if (!c)
{ {
@@ -52,7 +52,7 @@ class CommandCSInvite : public Command
if (params.size() == 1) if (params.size() == 1)
u2 = u; u2 = u;
else else
u2 = finduser(params[1]); u2 = User::Find(params[1], true);
if (!u2) if (!u2)
{ {
@@ -71,7 +71,7 @@ class CommandCSInvite : public Command
{ {
bool override = !source.AccessFor(ci).HasPriv("INVITE"); bool override = !source.AccessFor(ci).HasPriv("INVITE");
ircdproto->SendInvite(ci->WhoSends(), c, u2); IRCD->SendInvite(ci->WhoSends(), c, u2);
if (u2 != u) if (u2 != u)
{ {
source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str()); source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str());
+3 -3
View File
@@ -30,9 +30,9 @@ class CommandCSKick : public Command
const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; const Anope::string &reason = params.size() > 2 ? params[2] : "Requested";
User *u = source.GetUser(); User *u = source.GetUser();
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
Channel *c = findchan(params[0]); Channel *c = Channel::Find(params[0]);
User *u2 = finduser(target); User *u2 = User::Find(target, true);
if (!c) if (!c)
{ {
+5 -4
View File
@@ -33,8 +33,9 @@ class CommandCSList : public Command
if (pattern[0] == '#') if (pattern[0] == '#')
{ {
Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */ Anope::string n1, n2;
n2 = myStrGetTokenRemainder(pattern, '-', 1); sepstream(pattern.substr(1), '-').GetToken(n1, 0);
sepstream(pattern, '-').GetToken(n2, 1);
try try
{ {
@@ -72,7 +73,7 @@ class CommandCSList : public Command
source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str()); source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str());
ListFormatter list; ListFormatter list;
list.addColumn("Name").addColumn("Description"); list.AddColumn("Name").AddColumn("Description");
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
{ {
@@ -99,7 +100,7 @@ class CommandCSList : public Command
entry["Description"] = "[Suspended]"; entry["Description"] = "[Suspended]";
else else
entry["Description"] = ci->desc; entry["Description"] = ci->desc;
list.addEntry(entry); list.AddEntry(entry);
} }
++count; ++count;
} }
+11 -11
View File
@@ -28,7 +28,7 @@ public:
{ {
const Anope::string &channel = params[0]; const Anope::string &channel = params[0];
ChannelInfo *ci = cs_findchan(channel); ChannelInfo *ci = ChannelInfo::Find(channel);
if (ci == NULL) if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/set")) else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/set"))
@@ -40,7 +40,7 @@ public:
else else
{ {
ListFormatter list; ListFormatter list;
list.addColumn("Number").addColumn("Service").addColumn("Command").addColumn("Method").addColumn(""); list.AddColumn("Number").AddColumn("Service").AddColumn("Command").AddColumn("Method").AddColumn("");
for (unsigned i = 0; i < ci->log_settings->size(); ++i) for (unsigned i = 0; i < ci->log_settings->size(); ++i)
{ {
@@ -52,7 +52,7 @@ public:
entry["Command"] = log->command_name; entry["Command"] = log->command_name;
entry["Method"] = log->method; entry["Method"] = log->method;
entry[""] = log->extra; entry[""] = log->extra;
list.addEntry(entry); list.AddEntry(entry);
} }
source.Reply(_("Log list for %s:"), ci->name.c_str()); source.Reply(_("Log list for %s:"), ci->name.c_str());
@@ -79,7 +79,7 @@ public:
Anope::string service = command.substr(0, sl), Anope::string service = command.substr(0, sl),
command_name = command.substr(sl + 1); command_name = command.substr(sl + 1);
BotInfo *bi = findbot(service); BotInfo *bi = BotInfo::Find(service, true);
if (bi == NULL || bi->commands.count(command_name) == 0) if (bi == NULL || bi->commands.count(command_name) == 0)
{ {
@@ -87,7 +87,7 @@ public:
return; return;
} }
service_reference<Command> c_service("Command", bi->commands[command_name].name); ServiceReference<Command> c_service("Command", bi->commands[command_name].name);
if (!c_service) if (!c_service)
{ {
source.Reply(_("%s is not a valid command."), command.c_str()); source.Reply(_("%s is not a valid command."), command.c_str());
@@ -117,7 +117,7 @@ public:
{ {
if (log->extra == extra) if (log->extra == extra)
{ {
log->destroy(); log->Destroy();
ci->log_settings->erase(ci->log_settings->begin() + i - 1); ci->log_settings->erase(ci->log_settings->begin() + i - 1);
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra;
source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str()); source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
@@ -194,7 +194,7 @@ class CSLog : public Module
void OnLog(Log *l) anope_override void OnLog(Log *l) anope_override
{ {
if (l->Type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced())
return; return;
for (unsigned i = l->ci->log_settings->size(); i > 0; --i) for (unsigned i = l->ci->log_settings->size(); i > 0; --i)
@@ -207,13 +207,13 @@ class CSLog : public Module
if (log->method.equals_ci("MESSAGE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL) if (log->method.equals_ci("MESSAGE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
{ {
ircdproto->SendPrivmsg(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); IRCD->SendPrivmsg(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str());
l->ci->bi->lastmsg = Anope::CurTime; l->ci->bi->lastmsg = Anope::CurTime;
} }
else if (log->method.equals_ci("NOTICE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL) else if (log->method.equals_ci("NOTICE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
ircdproto->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); IRCD->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str());
else if (log->method.equals_ci("MEMO") && memoserv && l->ci->WhoSends() != NULL) else if (log->method.equals_ci("MEMO") && MemoServService && l->ci->WhoSends() != NULL)
memoserv->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true); MemoServService->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true);
} }
} }
} }
+22 -22
View File
@@ -17,7 +17,7 @@ class CommandCSMode : public Command
{ {
bool CanSet(CommandSource &source, ChannelInfo *ci, ChannelMode *cm) bool CanSet(CommandSource &source, ChannelInfo *ci, ChannelMode *cm)
{ {
if (!ci || !cm || cm->Type != MODE_STATUS) if (!ci || !cm || cm->type != MODE_STATUS)
return false; return false;
const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" }; const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" };
@@ -30,7 +30,7 @@ class CommandCSMode : public Command
if (access.HasPriv(accesses[i])) if (access.HasPriv(accesses[i]))
{ {
ChannelMode *cm2 = ModeManager::FindChannelModeByName(modes[i]); ChannelMode *cm2 = ModeManager::FindChannelModeByName(modes[i]);
if (cm2 == NULL || cm2->Type != MODE_STATUS) if (cm2 == NULL || cm2->type != MODE_STATUS)
continue; continue;
ChannelModeStatus *cms2 = anope_dynamic_static_cast<ChannelModeStatus *>(cm2); ChannelModeStatus *cms2 = anope_dynamic_static_cast<ChannelModeStatus *>(cm2);
if (cms2->Level > u_level) if (cms2->Level > u_level)
@@ -82,15 +82,15 @@ class CommandCSMode : public Command
} }
Anope::string mode_param; Anope::string mode_param;
if (((cm->Type == MODE_STATUS || cm->Type == MODE_LIST) && !sep.GetToken(mode_param)) || (cm->Type == MODE_PARAM && adding && !sep.GetToken(mode_param))) if (((cm->type == MODE_STATUS || cm->type == MODE_LIST) && !sep.GetToken(mode_param)) || (cm->type == MODE_PARAM && adding && !sep.GetToken(mode_param)))
source.Reply(_("Missing parameter for mode %c."), cm->ModeChar); source.Reply(_("Missing parameter for mode %c."), cm->mchar);
else else
{ {
ci->SetMLock(cm, adding, mode_param, source.GetNick()); ci->SetMLock(cm, adding, mode_param, source.GetNick());
if (!mode_param.empty()) if (!mode_param.empty())
mode_param = " " + mode_param; mode_param = " " + mode_param;
source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->mchar, mode_param.c_str(), ci->name.c_str());
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->mchar << mode_param;
} }
} }
} }
@@ -132,19 +132,19 @@ class CommandCSMode : public Command
} }
Anope::string mode_param; Anope::string mode_param;
if (!cm->Type == MODE_REGULAR && !sep.GetToken(mode_param)) if (!cm->type == MODE_REGULAR && !sep.GetToken(mode_param))
source.Reply(_("Missing parameter for mode %c."), cm->ModeChar); source.Reply(_("Missing parameter for mode %c."), cm->mchar);
else else
{ {
if (ci->RemoveMLock(cm, adding, mode_param)) if (ci->RemoveMLock(cm, adding, mode_param))
{ {
if (!mode_param.empty()) if (!mode_param.empty())
mode_param = " " + mode_param; mode_param = " " + mode_param;
source.Reply(_("%c%c%s has been unlocked from %s."), adding == 1 ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); source.Reply(_("%c%c%s has been unlocked from %s."), adding == 1 ? '+' : '-', cm->mchar, mode_param.c_str(), ci->name.c_str());
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param;
} }
else else
source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->ModeChar, ci->name.c_str()); source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->mchar, ci->name.c_str());
} }
} }
} }
@@ -159,7 +159,7 @@ class CommandCSMode : public Command
else else
{ {
ListFormatter list; ListFormatter list;
list.addColumn("Mode").addColumn("Param").addColumn("Creator").addColumn("Created"); list.AddColumn("Mode").AddColumn("Param").AddColumn("Creator").AddColumn("Created");
for (ChannelInfo::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it) for (ChannelInfo::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
{ {
@@ -169,11 +169,11 @@ class CommandCSMode : public Command
continue; continue;
ListFormatter::ListEntry entry; ListFormatter::ListEntry entry;
entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->ModeChar); entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->mchar);
entry["Param"] = ml->param; entry["Param"] = ml->param;
entry["Creator"] = ml->setter; entry["Creator"] = ml->setter;
entry["Created"] = do_strftime(ml->created, source.nc, false); entry["Created"] = Anope::strftime(ml->created, source.nc, false);
list.addEntry(entry); list.AddEntry(entry);
} }
source.Reply(_("Mode locks for %s:"), ci->name.c_str()); source.Reply(_("Mode locks for %s:"), ci->name.c_str());
@@ -218,7 +218,7 @@ class CommandCSMode : public Command
ChannelMode *cm = ModeManager::ChannelModes[j]; ChannelMode *cm = ModeManager::ChannelModes[j];
if (!u || cm->CanSet(u)) if (!u || cm->CanSet(u))
{ {
if (cm->Type == MODE_REGULAR || (!adding && cm->Type == MODE_PARAM)) if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM))
{ {
if (adding) if (adding)
ci->c->SetMode(NULL, cm); ci->c->SetMode(NULL, cm);
@@ -234,7 +234,7 @@ class CommandCSMode : public Command
ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
if (!cm || (u && !cm->CanSet(u))) if (!cm || (u && !cm->CanSet(u)))
continue; continue;
switch (cm->Type) switch (cm->type)
{ {
case MODE_REGULAR: case MODE_REGULAR:
if (adding) if (adding)
@@ -257,13 +257,13 @@ class CommandCSMode : public Command
if (!this->CanSet(source, ci, cm)) if (!this->CanSet(source, ci, cm))
{ {
source.Reply(_("You do not have access to set mode %c."), cm->ModeChar); source.Reply(_("You do not have access to set mode %c."), cm->mchar);
break; break;
} }
AccessGroup u_access = source.AccessFor(ci); AccessGroup u_access = source.AccessFor(ci);
if (str_is_wildcard(param)) if (param.find_first_of("*?") != Anope::string::npos)
{ {
for (CUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) for (CUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{ {
@@ -288,7 +288,7 @@ class CommandCSMode : public Command
} }
else else
{ {
User *target = finduser(param); User *target = User::Find(param, true);
if (target == NULL) if (target == NULL)
{ {
source.Reply(NICK_X_NOT_IN_USE, param.c_str()); source.Reply(NICK_X_NOT_IN_USE, param.c_str());
@@ -316,7 +316,7 @@ class CommandCSMode : public Command
ci->c->SetMode(NULL, cm, param); ci->c->SetMode(NULL, cm, param);
else else
{ {
std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = ci->c->GetModeList(cm->Name); std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = ci->c->GetModeList(cm->name);
for (; its.first != its.second;) for (; its.first != its.second;)
{ {
const Anope::string &mask = its.first->second; const Anope::string &mask = its.first->second;
@@ -343,7 +343,7 @@ class CommandCSMode : public Command
{ {
const Anope::string &subcommand = params[1]; const Anope::string &subcommand = params[1];
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (!ci || !ci->c) if (!ci || !ci->c)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
+2 -2
View File
@@ -18,8 +18,8 @@ class CommandModeBase : public Command
void do_mode(CommandSource &source, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, const Anope::string &level, const Anope::string &levelself) void do_mode(CommandSource &source, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, const Anope::string &level, const Anope::string &levelself)
{ {
User *u = source.GetUser(); User *u = source.GetUser();
User *u2 = finduser(nick); User *u2 = User::Find(nick, true);
Channel *c = findchan(chan); Channel *c = Channel::Find(chan);
if (!c) if (!c)
{ {
+5 -5
View File
@@ -29,10 +29,10 @@ class CommandCSRegister : public Command
User *u = source.GetUser(); User *u = source.GetUser();
NickCore *nc = source.nc; NickCore *nc = source.nc;
Channel *c = findchan(params[0]); Channel *c = Channel::Find(params[0]);
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (readonly) if (Anope::ReadOnly)
source.Reply(_("Sorry, channel registration is temporarily disabled.")); source.Reply(_("Sorry, channel registration is temporarily disabled."));
else if (nc->HasFlag(NI_UNCONFIRMED)) else if (nc->HasFlag(NI_UNCONFIRMED))
source.Reply(_("You must confirm your account before you can register a channel.")); source.Reply(_("You must confirm your account before you can register a channel."));
@@ -40,7 +40,7 @@ class CommandCSRegister : public Command
source.Reply(_("Local channels cannot be registered.")); source.Reply(_("Local channels cannot be registered."));
else if (chan[0] != '#') else if (chan[0] != '#')
source.Reply(CHAN_SYMBOL_REQUIRED); source.Reply(CHAN_SYMBOL_REQUIRED);
else if (!ircdproto->IsChannelValid(chan)) else if (!IRCD->IsChannelValid(chan))
source.Reply(CHAN_X_INVALID, chan.c_str()); source.Reply(CHAN_X_INVALID, chan.c_str());
else if (ci) else if (ci)
source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str()); source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str());
@@ -55,7 +55,7 @@ class CommandCSRegister : public Command
if (!chdesc.empty()) if (!chdesc.empty())
ci->desc = chdesc; ci->desc = chdesc;
for (ChannelInfo::ModeList::iterator it = def_mode_locks.begin(), it_end = def_mode_locks.end(); it != it_end; ++it) for (ChannelInfo::ModeList::iterator it = ModeManager::DefaultModeLocks.begin(), it_end = ModeManager::DefaultModeLocks.end(); it != it_end; ++it)
{ {
ModeLock *ml = new ModeLock(*it->second); ModeLock *ml = new ModeLock(*it->second);
ml->setter = source.GetNick(); ml->setter = source.GetNick();
+1 -1
View File
@@ -43,7 +43,7 @@ class CommandCSSASet : public Command
const CommandInfo &info = it->second; const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0) if (c_name.find_ci(this_name + " ") == 0)
{ {
service_reference<Command> command("Command", info.name); ServiceReference<Command> command("Command", info.name);
if (command) if (command)
{ {
source.command = it->first; source.command = it->first;
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSASetNoexpire : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+22 -22
View File
@@ -38,7 +38,7 @@ struct SeenInfo : Serializable
{ {
} }
Serialize::Data serialize() const anope_override Serialize::Data Serialize() const anope_override
{ {
Serialize::Data data; Serialize::Data data;
@@ -48,12 +48,12 @@ struct SeenInfo : Serializable
data["nick2"] << nick2; data["nick2"] << nick2;
data["channel"] << channel; data["channel"] << channel;
data["message"] << message; data["message"] << message;
data["last"].setType(Serialize::DT_INT) << last; data["last"].SetType(Serialize::DT_INT) << last;
return data; return data;
} }
static Serializable* unserialize(Serializable *obj, Serialize::Data &data) static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
{ {
SeenInfo *s; SeenInfo *s;
if (obj) if (obj)
@@ -95,8 +95,8 @@ static SeenInfo *FindInfo(const Anope::string &nick)
static bool ShouldHide(const Anope::string &channel, User *u) static bool ShouldHide(const Anope::string &channel, User *u)
{ {
Channel *targetchan = findchan(channel); Channel *targetchan = Channel::Find(channel);
const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : cs_findchan(channel); const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : ChannelInfo::Find(channel);
if (targetchan && targetchan->HasMode(CMODE_SECRET)) if (targetchan && targetchan->HasMode(CMODE_SECRET))
return true; return true;
@@ -137,7 +137,7 @@ class CommandOSSeen : public Command
else if (params[0].equals_ci("CLEAR")) else if (params[0].equals_ci("CLEAR"))
{ {
time_t time = 0; time_t time = 0;
if ((params.size() < 2) || (0 >= (time = dotime(params[1])))) if ((params.size() < 2) || (0 >= (time = Anope::DoTime(params[1]))))
{ {
this->OnSyntaxError(source, params[0]); this->OnSyntaxError(source, params[0]);
return; return;
@@ -151,14 +151,14 @@ class CommandOSSeen : public Command
++it; ++it;
if (time < buf->second->last) if (time < buf->second->last)
{ {
Log(LOG_DEBUG) << buf->first << " was last seen " << do_strftime(buf->second->last) << ", deleting entry"; Log(LOG_DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry";
buf->second->destroy(); buf->second->Destroy();
database.erase(buf); database.erase(buf);
counter++; counter++;
} }
} }
Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << do_strftime(time, NULL, true); Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true);
source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, do_strftime(time, source.nc, true).c_str()); source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, Anope::strftime(time, source.nc, true).c_str());
} }
else else
this->SendSyntax(source); this->SendSyntax(source);
@@ -199,7 +199,7 @@ class CommandSeen : public Command
return; return;
} }
if (findbot(target) != NULL) if (BotInfo::Find(target, true) != NULL)
{ {
source.Reply(_("%s is a client on services."), target.c_str()); source.Reply(_("%s is a client on services."), target.c_str());
return; return;
@@ -218,15 +218,15 @@ class CommandSeen : public Command
return; return;
} }
User *u2 = finduser(target); User *u2 = User::Find(target, true);
Anope::string onlinestatus; Anope::string onlinestatus;
if (u2) if (u2)
onlinestatus = "."; onlinestatus = ".";
else else
onlinestatus = Anope::printf(_(" but %s mysteriously dematerialized."), target.c_str()); onlinestatus = Anope::printf(_(" but %s mysteriously dematerialized."), target.c_str());
Anope::string timebuf = duration(Anope::CurTime - info->last, source.nc); Anope::string timebuf = Anope::Duration(Anope::CurTime - info->last, source.nc);
Anope::string timebuf2 = do_strftime(info->last, source.nc, true); Anope::string timebuf2 = Anope::strftime(info->last, source.nc, true);
if (info->type == NEW) if (info->type == NEW)
{ {
@@ -235,7 +235,7 @@ class CommandSeen : public Command
} }
else if (info->type == NICK_TO) else if (info->type == NICK_TO)
{ {
u2 = finduser(info->nick2); u2 = User::Find(info->nick2, true);
if (u2) if (u2)
onlinestatus = Anope::printf( _(". %s is still online."), u2->nick.c_str()); onlinestatus = Anope::printf( _(". %s is still online."), u2->nick.c_str());
else else
@@ -309,8 +309,8 @@ class DataBasePurger : public CallBack
if ((Anope::CurTime - cur->second->last) > purgetime) if ((Anope::CurTime - cur->second->last) > purgetime)
{ {
Log(LOG_DEBUG) << cur->first << " was last seen " << do_strftime(cur->second->last) << ", purging entry"; Log(LOG_DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entry";
cur->second->destroy(); cur->second->Destroy();
database.erase(cur); database.erase(cur);
} }
} }
@@ -320,12 +320,12 @@ class DataBasePurger : public CallBack
class CSSeen : public Module class CSSeen : public Module
{ {
SerializeType seeninfo_type; Serialize::Type seeninfo_type;
CommandSeen commandseen; CommandSeen commandseen;
CommandOSSeen commandosseen; CommandOSSeen commandosseen;
DataBasePurger purger; DataBasePurger purger;
public: public:
CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), seeninfo_type("SeenInfo", SeenInfo::unserialize), commandseen(this), commandosseen(this), purger(this) CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this)
{ {
this->SetAuthor("Anope"); this->SetAuthor("Anope");
@@ -344,14 +344,14 @@ class CSSeen : public Module
void OnReload() anope_override void OnReload() anope_override
{ {
ConfigReader config; ConfigReader config;
purgetime = dotime(config.ReadValue("cs_seen", "purgetime", "30d", 0)); purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0));
expiretimeout = dotime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0)); expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0));
if (purger.GetSecs() != expiretimeout) if (purger.GetSecs() != expiretimeout)
purger.SetSecs(expiretimeout); purger.SetSecs(expiretimeout);
} }
void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override void OnUserConnect(Reference<User> &u, bool &exempt) anope_override
{ {
if (u) if (u)
UpdateUser(u, NEW, u->nick, "", "", ""); UpdateUser(u, NEW, u->nick, "", "", "");
+1 -1
View File
@@ -43,7 +43,7 @@ class CommandCSSet : public Command
const CommandInfo &info = it->second; const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0) if (c_name.find_ci(this_name + " ") == 0)
{ {
service_reference<Command> command("Command", info.name); ServiceReference<Command> command("Command", info.name);
if (command) if (command)
{ {
source.command = it->first; source.command = it->first;
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetAutoOp : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetBanType : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetChanstats : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (!ci) if (!ci)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetDescription : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandCSSetFounder : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -48,7 +48,7 @@ class CommandCSSetFounder : public Command
return; return;
} }
const NickAlias *na = findnick(params[1]); const NickAlias *na = NickAlias::Find(params[1]);
if (!na) if (!na)
{ {
source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str()); source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetKeepTopic : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+7 -7
View File
@@ -14,7 +14,7 @@
struct CSMiscData : ExtensibleItem, Serializable struct CSMiscData : ExtensibleItem, Serializable
{ {
serialize_obj<ChannelInfo> ci; Serialize::Reference<ChannelInfo> ci;
Anope::string name; Anope::string name;
Anope::string data; Anope::string data;
@@ -22,7 +22,7 @@ struct CSMiscData : ExtensibleItem, Serializable
{ {
} }
Serialize::Data serialize() const anope_override Serialize::Data Serialize() const anope_override
{ {
Serialize::Data sdata; Serialize::Data sdata;
@@ -33,9 +33,9 @@ struct CSMiscData : ExtensibleItem, Serializable
return sdata; return sdata;
} }
static Serializable* unserialize(Serializable *obj, Serialize::Data &data) static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
{ {
ChannelInfo *ci = cs_findchan(data["ci"].astr()); ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr());
if (ci == NULL) if (ci == NULL)
return NULL; return NULL;
@@ -75,7 +75,7 @@ class CommandCSSetMisc : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -108,12 +108,12 @@ class CommandCSSetMisc : public Command
class CSSetMisc : public Module class CSSetMisc : public Module
{ {
SerializeType csmiscdata_type; Serialize::Type csmiscdata_type;
CommandCSSetMisc commandcssetmisc; CommandCSSetMisc commandcssetmisc;
public: public:
CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
csmiscdata_type("CSMiscData", CSMiscData::unserialize), commandcssetmisc(this) csmiscdata_type("CSMiscData", CSMiscData::Unserialize), commandcssetmisc(this)
{ {
this->SetAuthor("Anope"); this->SetAuthor("Anope");
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetPeace : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+9 -12
View File
@@ -24,7 +24,7 @@ class CommandCSSetPersist : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -60,21 +60,19 @@ class CommandCSSetPersist : public Command
ci->bi->Join(c); ci->bi->Join(c);
} }
/* No botserv bot, no channel mode */ /* No botserv bot, no channel mode, give them ChanServ.
/* Give them ChanServ * Yes, this works fine with no Config->BotServ.
* Yes, this works fine with no Config->s_BotServ
*/ */
if (!ci->bi && !cm) if (!ci->bi && !cm)
{ {
BotInfo *bi = findbot(Config->ChanServ); if (!ChanServ)
if (!bi)
{ {
source.Reply(_("ChanServ is required to enable persist on this network.")); source.Reply(_("ChanServ is required to enable persist on this network."));
return; return;
} }
bi->Assign(NULL, ci); ChanServ->Assign(NULL, ci);
if (!ci->c->FindUser(bi)) if (!ci->c->FindUser(ChanServ))
bi->Join(ci->c); ChanServ->Join(ci->c);
} }
/* Set the perm mode */ /* Set the perm mode */
@@ -111,14 +109,13 @@ class CommandCSSetPersist : public Command
*/ */
if (!cm && Config->BotServ.empty() && ci->bi) if (!cm && Config->BotServ.empty() && ci->bi)
{ {
BotInfo *bi = findbot(Config->ChanServ); if (!ChanServ)
if (!bi)
{ {
source.Reply(_("ChanServ is required to enable persist on this network.")); source.Reply(_("ChanServ is required to enable persist on this network."));
return; return;
} }
/* Unassign bot */ /* Unassign bot */
bi->UnAssign(NULL, ci); ChanServ->UnAssign(NULL, ci);
} }
} }
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetPrivate : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -23,7 +23,7 @@ class CommandCSSetRestricted : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetSecure : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetSecureFounder : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetSecureOps : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetSignKick : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+2 -2
View File
@@ -24,7 +24,7 @@ class CommandCSSetSuccessor : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -55,7 +55,7 @@ class CommandCSSetSuccessor : public Command
if (params.size() > 1) if (params.size() > 1)
{ {
const NickAlias *na = findnick(params[1]); const NickAlias *na = NickAlias::Find(params[1]);
if (!na) if (!na)
{ {
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetTopicLock : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+6 -6
View File
@@ -26,7 +26,7 @@ public:
{ {
const Anope::string &channel = params[0]; const Anope::string &channel = params[0];
ChannelInfo *ci = cs_findchan(channel); ChannelInfo *ci = ChannelInfo::Find(channel);
if (ci == NULL) if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/access/modify")) else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/access/modify"))
@@ -38,20 +38,20 @@ public:
nick = params[1]; nick = params[1];
AccessGroup ag; AccessGroup ag;
User *u = finduser(nick); User *u = User::Find(nick, true);
NickAlias *na = NULL; NickAlias *na = NULL;
if (u != NULL) if (u != NULL)
ag = ci->AccessFor(u); ag = ci->AccessFor(u);
else else
{ {
na = findnick(nick); na = NickAlias::Find(nick);
if (na != NULL) if (na != NULL)
ag = ci->AccessFor(na->nc); ag = ci->AccessFor(na->nc);
} }
if (ag.SuperAdmin) if (ag.super_admin)
source.Reply(_("\2%s\2 is a super administrator."), nick.c_str()); source.Reply(_("\2%s\2 is a super administrator."), nick.c_str());
else if (ag.Founder) else if (ag.founder)
source.Reply(_("\2%s\2 is the channel founder."), nick.c_str()); source.Reply(_("\2%s\2 is the channel founder."), nick.c_str());
else if (ag.empty()) else if (ag.empty())
source.Reply(_("\2%s\2 has no access on \2%s\2."), nick.c_str(), ci->name.c_str()); source.Reply(_("\2%s\2 has no access on \2%s\2."), nick.c_str(), ci->name.c_str());
@@ -63,7 +63,7 @@ public:
{ {
ChanAccess *acc = ag[i]; ChanAccess *acc = ag[i];
source.Reply(_("\2%s\2 matches access entry %s, which has privilege %s."), nick.c_str(), acc->mask.c_str(), acc->Serialize().c_str()); source.Reply(_("\2%s\2 matches access entry %s, which has privilege %s."), nick.c_str(), acc->mask.c_str(), acc->AccessSerialize().c_str());
} }
} }
+13 -13
View File
@@ -22,7 +22,7 @@ struct ChanSuspend : ExtensibleItem, Serializable
{ {
} }
Serialize::Data serialize() const anope_override Serialize::Data Serialize() const anope_override
{ {
Serialize::Data sd; Serialize::Data sd;
@@ -32,9 +32,9 @@ struct ChanSuspend : ExtensibleItem, Serializable
return sd; return sd;
} }
static Serializable* unserialize(Serializable *obj, Serialize::Data &sd) static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd)
{ {
ChannelInfo *ci = cs_findchan(sd["chan"].astr()); ChannelInfo *ci = ChannelInfo::Find(sd["chan"].astr());
if (ci == NULL) if (ci == NULL)
return NULL; return NULL;
@@ -77,7 +77,7 @@ class CommandCSSuspend : public Command
expiry.clear(); expiry.clear();
} }
else else
expiry_secs = dotime(expiry); expiry_secs = Anope::DoTime(expiry);
if (Config->ForceForbidReason && reason.empty()) if (Config->ForceForbidReason && reason.empty())
{ {
@@ -85,10 +85,10 @@ class CommandCSSuspend : public Command
return; return;
} }
if (readonly) if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE); source.Reply(READ_ONLY_MODE);
ChannelInfo *ci = cs_findchan(chan); ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
@@ -113,7 +113,7 @@ class CommandCSSuspend : public Command
} }
for (unsigned i = 0; i < users.size(); ++i) for (unsigned i = 0; i < users.size(); ++i)
ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : translate(users[i], _("This channel has been suspended."))); ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : Language::Translate(users[i], _("This channel has been suspended.")));
} }
if (expiry_secs > 0) if (expiry_secs > 0)
@@ -125,7 +125,7 @@ class CommandCSSuspend : public Command
ci->Extend("cs_suspend_expire", cs); ci->Extend("cs_suspend_expire", cs);
} }
Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never");
source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str()); source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str());
FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci));
@@ -161,10 +161,10 @@ class CommandCSUnSuspend : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
if (readonly) if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE); source.Reply(READ_ONLY_MODE);
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -206,13 +206,13 @@ class CommandCSUnSuspend : public Command
class CSSuspend : public Module class CSSuspend : public Module
{ {
SerializeType chansuspend_type; Serialize::Type chansuspend_type;
CommandCSSuspend commandcssuspend; CommandCSSuspend commandcssuspend;
CommandCSUnSuspend commandcsunsuspend; CommandCSUnSuspend commandcsunsuspend;
public: public:
CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
chansuspend_type("ChanSuspend", ChanSuspend::unserialize), commandcssuspend(this), commandcsunsuspend(this) chansuspend_type("ChanSuspend", ChanSuspend::Unserialize), commandcssuspend(this), commandcsunsuspend(this)
{ {
this->SetAuthor("Anope"); this->SetAuthor("Anope");
@@ -247,7 +247,7 @@ class CSSuspend : public Module
ci->Shrink("suspend_by"); ci->Shrink("suspend_by");
ci->Shrink("suspend_reason"); ci->Shrink("suspend_reason");
Log(LOG_NORMAL, "expire", findbot(Config->ChanServ)) << "Expiring suspend for " << ci->name; Log(LOG_NORMAL, "expire", ChanServ) << "Expiring suspend for " << ci->name;
} }
} }
}; };
+2 -2
View File
@@ -22,7 +22,7 @@ class CommandCSSync : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -35,7 +35,7 @@ class CommandCSSync : public Command
Log(LOG_COMMAND, source, this, ci); Log(LOG_COMMAND, source, this, ci);
for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
chan_set_correct_modes((*it)->user, ci->c, 1, false); ci->c->SetCorrectModes((*it)->user, true, false);
source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str()); source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str());
} }
+8 -9
View File
@@ -22,7 +22,7 @@ static Module *me;
class TempBan : public CallBack class TempBan : public CallBack
{ {
private: private:
dynamic_reference<Channel> chan; Reference<Channel> chan;
Anope::string mask; Anope::string mask;
public: public:
@@ -46,7 +46,7 @@ class CommandCSTBan : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
Channel *c = findchan(params[0]); Channel *c = Channel::Find(params[0]);
const Anope::string &nick = params[1]; const Anope::string &nick = params[1];
const Anope::string &time = params[2]; const Anope::string &time = params[2];
@@ -58,23 +58,22 @@ class CommandCSTBan : public Command
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
else if (!source.AccessFor(c->ci).HasPriv("BAN")) else if (!source.AccessFor(c->ci).HasPriv("BAN"))
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else if (!(u2 = finduser(nick))) else if (!(u2 = User::Find(nick, true)))
source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
else if (matches_list(c, u2, CMODE_EXCEPT)) else if (c->MatchesList(u2, CMODE_EXCEPT))
source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), c->ci->name.c_str()); source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), c->ci->name.c_str());
else if (u2->IsProtected()) else if (u2->IsProtected())
source.Reply(ACCESS_DENIED); source.Reply(ACCESS_DENIED);
else else
{ {
time_t t = dotime(time); time_t t = Anope::DoTime(time);
Anope::string mask; Anope::string mask = c->ci->GetIdealBan(u2);
get_idealban(c->ci, u2, mask);
c->SetMode(NULL, CMODE_BAN, mask); c->SetMode(NULL, CMODE_BAN, mask);
new TempBan(t, c, mask); new TempBan(t, c, mask);
Log(LOG_COMMAND, source, this, c->ci) << "for " << mask << " to expire in " << duration(t); Log(LOG_COMMAND, source, this, c->ci) << "for " << mask << " to expire in " << Anope::Duration(t);
source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), duration(t).c_str()); source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), Anope::Duration(t).c_str());
} }
return; return;
+1 -1
View File
@@ -27,7 +27,7 @@ class CommandCSTopic : public Command
const Anope::string &topic = params.size() > 1 ? params[1] : ""; const Anope::string &topic = params.size() > 1 ? params[1] : "";
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+3 -3
View File
@@ -24,7 +24,7 @@ class CommandCSUnban : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{ {
ChannelInfo *ci = cs_findchan(params[0]); ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) if (ci == NULL)
{ {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -45,7 +45,7 @@ class CommandCSUnban : public Command
User *u2 = source.GetUser(); User *u2 = source.GetUser();
if (params.size() > 1) if (params.size() > 1)
u2 = finduser(params[1]); u2 = User::Find(params[1], true);
if (!u2) if (!u2)
{ {
@@ -55,7 +55,7 @@ class CommandCSUnban : public Command
Log(LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; Log(LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
common_unban(ci, u2, source.GetUser() == u2); ci->c->Unban(u2, source.GetUser() == u2);
if (u2 == source.GetUser()) if (u2 == source.GetUser())
source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str()); source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str());
else else

Some files were not shown because too many files have changed in this diff Show More