1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +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 Services by Andy Church.
*
*
*/
#ifndef ACCESS_H
@@ -25,19 +24,25 @@ enum
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
{
Anope::string name;
Anope::string desc;
/* Rank relative to other privileges */
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;
};
class CoreExport PrivilegeManager
{
static std::vector<Privilege> privs;
static std::vector<Privilege> Privileges;
public:
static void AddPrivilege(Privilege p);
static void RemovePrivilege(Privilege &p);
@@ -46,25 +51,34 @@ class CoreExport PrivilegeManager
static void ClearPrivileges();
};
/* A provider of access. Only used for creating ChanAccesses, as
* they contain pure virtual functions.
*/
class CoreExport AccessProvider : public Service
{
public:
AccessProvider(Module *o, const Anope::string &n);
AccessProvider(Module *owner, const Anope::string &name);
virtual ~AccessProvider();
/** Creates a new ChanAccess entry using this provider.
* @return The new entry
*/
virtual ChanAccess *Create() = 0;
private:
static std::list<AccessProvider *> providers;
static std::list<AccessProvider *> Providers;
public:
static const std::list<AccessProvider *>& GetProviders();
};
/* Represents one entry of an access list on a channel. */
class CoreExport ChanAccess : public Serializable
{
public:
/* The provider that created this access entry */
AccessProvider *provider;
serialize_obj<ChannelInfo> ci;
/* Channel this access entry is on */
Serialize::Reference<ChannelInfo> ci;
Anope::string mask;
Anope::string creator;
time_t last_seen;
@@ -73,29 +87,69 @@ class CoreExport ChanAccess : public Serializable
ChanAccess(AccessProvider *p);
virtual ~ChanAccess();
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const anope_override;
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 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;
};
/* 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 *>
{
public:
/* Channel these access entries are on */
const ChannelInfo *ci;
/* Account these entries affect, if any */
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();
/** 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;
/** 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;
/* Comparison operators to other AccessGroups */
bool operator>(const AccessGroup &other) const;
bool operator<(const AccessGroup &other) const;
bool operator>=(const AccessGroup &other) const;
+113 -67
View File
@@ -7,8 +7,7 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*
*/
#ifndef ACCOUNT_H
@@ -23,10 +22,8 @@
typedef Anope::hash_map<NickAlias *> nickalias_map;
typedef Anope::hash_map<NickCore *> nickcore_map;
extern CoreExport serialize_checker<nickalias_map> NickAliasList;
extern CoreExport serialize_checker<nickcore_map> NickCoreList;
/* NickServ nickname structures. */
extern CoreExport Serialize::Checker<nickalias_map> NickAliasList;
extern CoreExport Serialize::Checker<nickcore_map> NickCoreList;
/** Flags set on NickAliases
*/
@@ -50,10 +47,6 @@ enum NickNameFlag
NS_END
};
const Anope::string NickNameFlagStrings[] = {
"BEGIN", "NO_EXPIRE", "HELD", "COLLIDED", ""
};
/** Flags set on NickCores
*/
enum NickCoreFlag
@@ -101,40 +94,36 @@ enum NickCoreFlag
NI_END
};
const Anope::string NickCoreFlagStrings[] = {
"BEGIN", "KILLPROTECT", "SECURE", "MSG", "MEMO_HARDMAX", "MEMO_SIGNON", "MEMO_RECEIVE",
"PRIVATE", "HIDE_EMAIL", "HIDE_MASK", "HIDE_QUIT", "KILL_QUICK", "KILL_IMMED",
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "UNCONFIRMED", "STATS", ""
};
/* 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>
/* A registered nickname.
* It matters that Base is here before Extensible (it is inherited by Serializable)
*/
class CoreExport NickAlias : public Serializable, public Extensible, public Flags<NickNameFlag>
{
Anope::string vhost_ident, vhost_host, vhost_creator;
time_t vhost_created;
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 nickcore The nickcore for this nick
*/
NickAlias(const Anope::string &nickname, NickCore *nickcore);
/** Default destructor
*/
~NickAlias();
Anope::string nick; /* Nickname */
Anope::string last_quit; /* Last quit message */
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 &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Release a nick
* 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
*/
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) */
class CoreExport NickCore : public Serializable, public Extensible, public Flags<NickCoreFlag, NI_END>
/* A registered account. Each account must have a NickAlias with the same nick as the
* 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:
/** Default constructor
* @param display The display nick
*/
NickCore(const Anope::string &nickdisplay);
/** Default destructor
*/
~NickCore();
std::list<User *> Users;
Anope::string display; /* How the nick is displayed */
Anope::string pass; /* Password of the nicks */
Anope::string email; /* E-mail associated to the nick */
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 */
/* Name of the account. Find(display)->nc == this. */
Anope::string display;
/* User password in form of hashm:data */
Anope::string pass;
Anope::string email;
/* Greet associated with the account, sometimes sent when the user joins a channel */
Anope::string greet;
/* Locale name of the language of the user. Empty means default language */
Anope::string language;
/* 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. */
std::vector<Anope::string> access;
/* SSL certificate list. Users who have a matching certificate may be automatically logged in */
std::vector<Anope::string> cert;
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;
/* 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;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
/* Number of channels registered by this account */
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.
* @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();
/** 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
*
* @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.
*/
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
{
/* Owner of this request, used to cleanup requests if a module is unloaded
* while a reqyest us pending */
Module *owner;
Anope::string account;
Anope::string password;
@@ -316,35 +350,47 @@ class CoreExport IdentifyRequest
bool dispatched;
bool success;
static std::set<IdentifyRequest *> requests;
static std::set<IdentifyRequest *> Requests;
protected:
IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass);
virtual ~IdentifyRequest();
public:
/* One of these is called when the request goes through */
virtual void OnSuccess() = 0;
virtual void OnFail() = 0;
const Anope::string &GetAccount() const { return account; }
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);
/** Releases a held request
* @param m The module releaseing the hold
*/
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);
/** 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();
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
+190 -34
View File
@@ -1,4 +1,5 @@
/*
*
* (C) 2003-2012 Anope Team
* 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 Services by Andy Church.
*
*/
#ifndef ANOPE_H
@@ -304,11 +306,52 @@ namespace Anope
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.
* Use this unless you need very specific time checks
*/
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 VersionShort();
extern CoreExport string VersionBuildString();
@@ -316,6 +359,29 @@ namespace Anope
extern CoreExport int VersionMinor();
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.
* @param str The string to check against the pattern (e.g. foobar)
* @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);
/** 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.
** After the format parameter, the function expects at least as many
** additional arguments as specified in format.
@@ -368,6 +448,48 @@ namespace Anope
* @return An error message
*/
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.
@@ -394,23 +516,52 @@ class CoreExport sepstream
/** Create a sepstream and fill it with the provided data
*/
sepstream(const Anope::string &source, char seperator);
virtual ~sepstream() { }
/** Fetch the next token from the stream
* @param token The next token from the stream is placed here
* @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
* @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
* @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
@@ -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
{
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
* where T is an enum.
*/
template<typename T, size_t Size = 32> class Flags
template<typename T> class Flags
{
protected:
std::bitset<Size> Flag_Values;
const Anope::string *Flag_Strings;
std::vector<bool> flags_values;
static const Anope::string *flags_strings;
public:
Flags() : Flag_Strings(NULL) { }
Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
/** 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
* @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
* @param Value The flag
* @param value The flag
* @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
@@ -640,14 +787,23 @@ template<typename T, size_t Size = 32> class Flags
*/
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
*/
void ClearFlags()
{
Flag_Values.reset();
flags_values.clear();
}
static const Anope::string* GetFlagStrings()
{
return flags_strings;
}
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> 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)))
ret.push_back(this->Flag_Strings[i]);
ret.push_back(this->flags_strings[i]);
return ret;
}
@@ -685,9 +841,9 @@ template<typename T, size_t Size = 32> class Flags
{
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)
if (this->Flag_Strings[i] == strings[j])
if (this->flags_strings[i] == strings[j])
this->SetFlag(static_cast<T>(i));
}
};
+24 -14
View File
@@ -4,6 +4,7 @@
* Copyright (C) 2008-2012 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
*
*/
#ifndef BASE_H
@@ -16,48 +17,57 @@
class CoreExport Base
{
/* References to this base class */
std::set<dynamic_reference_base *> References;
std::set<ReferenceBase *> references;
public:
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:
bool invalid;
public:
dynamic_reference_base() : invalid(false) { }
dynamic_reference_base(const dynamic_reference_base &other) : invalid(other.invalid) { }
virtual ~dynamic_reference_base() { }
ReferenceBase() : invalid(false) { }
ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
virtual ~ReferenceBase() { }
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>
class dynamic_reference : public dynamic_reference_base
class Reference : public ReferenceBase
{
protected:
T *ref;
public:
dynamic_reference() : ref(NULL)
Reference() : ref(NULL)
{
}
dynamic_reference(T *obj) : ref(obj)
Reference(T *obj) : ref(obj)
{
if (ref)
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())
ref->AddReference(this);
}
virtual ~dynamic_reference()
virtual ~Reference()
{
if (operator bool())
ref->DelReference(this);
@@ -105,12 +115,12 @@ class dynamic_reference : public dynamic_reference_base
this->ref->AddReference(this);
}
inline bool operator<(const dynamic_reference<T> &other) const
inline bool operator<(const Reference<T> &other) const
{
return this < &other;
}
inline bool operator==(const dynamic_reference<T> &other)
inline bool operator==(const Reference<T> &other)
{
if (!this->invalid)
return this->ref == other;
+25 -19
View File
@@ -1,8 +1,10 @@
/*
*
* Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
* Copyright (C) 2008-2012 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
*
*/
#ifndef BOTS_H
@@ -16,7 +18,7 @@
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
*/
@@ -24,8 +26,6 @@ enum BotFlag
{
BI_BEGIN,
/* This bot is a core bot. NickServ, ChanServ, etc */
BI_CORE,
/* This bot can only be assigned by IRCops */
BI_PRIVATE,
/* This bot is defined in the config */
@@ -34,17 +34,21 @@ enum BotFlag
BI_END
};
static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF", "" };
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable
/* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable
{
public:
time_t created; /* Birth date ;) */
time_t lastmsg; /* Last time we said something */
CommandInfo::map commands; /* Commands, actual name to service name */
Anope::string botmodes; /* Modes the bot should have as configured in service:modes */
std::vector<Anope::string> botchannels; /* Channels the bot should be in as configured in service:channels */
bool introduced; /* Whether or not this bot is introduced */
time_t created;
/* Last time this bot said something (via privmsg) */
time_t lastmsg;
/* Map of actual command names -> service name/permission required */
CommandInfo::map commands;
/* 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.
* @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();
Serialize::Data serialize() const;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
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
*/
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
-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
*
* Please read COPYING and README for further details.
*
*/
#ifndef CHANNELS_H
@@ -18,10 +19,12 @@ typedef Anope::hash_map<Channel *> channel_map;
extern CoreExport channel_map ChannelList;
/* A user container, there is one of these per user per channel. */
struct UserContainer : public Extensible
{
User *user;
ChannelStatus *Status;
/* Status the user has in the channel */
ChannelStatus *status;
UserContainer(User *u) : user(u) { }
virtual ~UserContainer() { }
@@ -39,9 +42,7 @@ enum ChannelFlag
CH_SYNCING
};
const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" };
class CoreExport Channel : public virtual Base, public Extensible, public Flags<ChannelFlag, 3>
class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag>
{
public:
typedef std::multimap<ChannelModeName, Anope::string> ModeList;
@@ -51,27 +52,27 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
ModeList modes;
public:
/** Default constructor
* @param name The channel name
* @param ts The time the channel was created
*/
Channel(const Anope::string &nname, time_t ts = Anope::CurTime);
/* Channel name */
Anope::string name;
/* Set if this channel is registered. ci->c == this. Contains information relevant to the registered channel */
Serialize::Reference<ChannelInfo> ci;
/* When the channel was created */
time_t creation_time;
/** Default destructor
*/
~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 */
/* Users in the channel */
CUserList users;
Anope::string topic; /* Current topic of the channel */
Anope::string topic_setter; /* Who set the topic */
time_t topic_ts; /* The timestamp associated with the topic. Not necessarually anywhere close to Anope::CurTime */
time_t topic_time; /* The actual time the topic was set, probably close to Anope::CurTime */
/* Current topic of the channel */
Anope::string topic;
/* Who set the topic */
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 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 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).
* 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
* @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
* @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
* Use the overloaded function for ChannelModeStatus* to check for no status
* @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
*/
bool HasUserStatus(const User *u, ChannelModeName Name) const;
bool HasUserStatus(const User *u, ChannelModeName name) const;
/** See if a channel has a mode
* @param Name The mode name
* @param name The mode name
* @return The number of modes set
* @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
* @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
*/
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
* @param setter The setter
* @param cm The mode
* @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
* @param setter The Setter
* @param cm The mode
* @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
* @param bi The client setting the modes
* @param cm 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
* @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 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
* @param bi The client setting the modes
* @param cm 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
* @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 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
* @param Name The mode
* @param Target a string to put the param into
* @return true on success
/** Get a modes parameter for the channel
* @param name The mode
* @param target a string to put the param into
* @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
* @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
*/
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
* @param source The setter
* @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
* @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
*/
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
+12 -12
View File
@@ -22,20 +22,20 @@ enum CommandFlag
CFLAG_STRIP_CHANNEL
};
const Anope::string CommandFlagStrings[] = {
"CFLAG_ALLOW_UNREGISTERED",
"CFLAG_STRIP_CHANNEL",
""
};
/* Used in BotInfo::commands */
struct CommandInfo
{
typedef Anope::map<CommandInfo> map;
/* Service name of the command */
Anope::string name;
/* Permission required to execute the command */
Anope::string permission;
};
/* Where the replies from commands go to. User inheits from this and is the normal
* source of a CommandReply
*/
struct CommandReply
{
virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0;
@@ -47,16 +47,16 @@ class CoreExport CommandSource
/* The nick executing the command */
Anope::string nick;
/* User executing the command, may be NULL */
dynamic_reference<User> u;
Reference<User> u;
public:
/* The account executing the command */
dynamic_reference<NickCore> nc;
Reference<NickCore> nc;
/* Where the reply should go */
CommandReply *reply;
/* Channel the command was executed on (fantasy) */
dynamic_reference<Channel> c;
Reference<Channel> c;
/* The service this command is on */
dynamic_reference<BotInfo> service;
Reference<BotInfo> service;
/* The actual name of the command being executed */
Anope::string command;
/* The permission of the command being executed */
@@ -88,9 +88,9 @@ class CoreExport Command : public Service, public Flags<CommandFlag>
public:
/* Maximum paramaters accepted by this command */
size_t MaxParams;
size_t max_params;
/* Minimum parameters required to use this command */
size_t MinParams;
size_t min_params;
/* Module which owns us */
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 Services by Andy Church.
*
*
*/
#ifndef CONFIG_H
@@ -207,23 +206,6 @@ typedef bool (*MultiValidator)(ServerConfig *, const Anope::string &, const Anop
*/
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
*/
class ConfigurationFile
@@ -463,8 +445,6 @@ class CoreExport ServerConfig
bool UseServerSideTopicLock;
/* Default botmodes on channels, defaults to ao */
Anope::string BotModes;
/* THe actual modes */
ChannelStatus BotModeList;
/* How long to wait between connection attempts */
int RetryWait;
/* If services should hide unprivileged commands */
@@ -517,7 +497,7 @@ class CoreExport ServerConfig
/* Don't allow nicks to use /ns group to regroup nicks */
bool NSNoGroupChange;
/* Default flags for newly registered nicks */
Flags<NickCoreFlag, NI_END> NSDefFlags;
Flags<NickCoreFlag> NSDefFlags;
/* All languages Anope is aware about */
Anope::string Languages;
/* Default language used by services */
@@ -578,7 +558,7 @@ class CoreExport ServerConfig
/* Core ChanServ modules */
Anope::string ChanCoreModules;
/* Default flags for newly registered channels */
Flags<ChannelInfoFlag, CI_END> CSDefFlags;
Flags<ChannelInfoFlag> CSDefFlags;
/* Max number of channels a user can own */
unsigned CSMaxReg;
/* Time before a channel expires */
@@ -741,7 +721,7 @@ class ConfigException : public CoreException
#define CONF_FILE_NOT_FOUND 0x000200
/** 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.
* Constructing the class using one parameter allows you to specify a path to your own configuration
* file, otherwise, inspircd.conf is read.
@@ -836,7 +816,7 @@ class CoreExport ConfigReader
int EnumerateValues(const Anope::string &, int);
};
extern ConfigurationFile services_conf;
extern ConfigurationFile ServicesConf;
extern CoreExport ServerConfig *Config;
#endif // CONFIG_H
+4 -4
View File
@@ -23,21 +23,21 @@ class ClientSocket;
class Command;
class CommandSource;
class ConnectionSocket;
class DNSPacket;
class dynamic_reference_base;
namespace DNS { class Packet; }
class Entry;
class IdentifyRequest;
class InfoFormatter;
class IRCDProto;
class ListenSocket;
class Log;
class LogInfo;
class Memo;
class Message;
class MessageSource;
class Module;
class NickAlias;
class NickCore;
class OperType;
class ReferenceBase;
class Regex;
class Serializable;
class Server;
@@ -48,7 +48,7 @@ class User;
class XLine;
class XLineManager;
struct BadWord;
struct DNSQuery;
namespace DNS { struct Query; }
struct Exception;
struct MemoInfo;
struct ModeLock;
+247 -236
View File
@@ -8,260 +8,271 @@
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#ifndef DNS_H
#define DNS_H
#include "sockets.h"
#include "timers.h"
#include "extern.h"
#include "config.h"
/** Valid query types
*/
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
*/
enum
{
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
namespace DNS
{
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
/** Valid query types
*/
enum QueryType
{
public:
virtual ~ReplySocket() { }
virtual void Reply(DNSPacket *p) = 0;
/* Nothing */
QUERY_NONE,
/* 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 */
class TCPSocket : public ListenSocket
/** Flags that can be AND'd into DNSPacket::flags to receive certain values
*/
enum
{
/* A TCP client */
class Client : public ClientSocket, public Timer, public ReplySocket
QUERYFLAGS_QR = 0x8000,
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;
DNSPacket *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(DNSPacket *p) anope_override;
virtual ~ReplySocket() { }
virtual void Reply(Packet *p) = 0;
};
/* 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:
TCPSocket(const Anope::string &ip, int port);
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; }
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(const Anope::string &ip, int port);
ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override;
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 */
class UDPSocket : public ReplySocket
{
std::deque<DNSPacket *> packets;
public:
UDPSocket(const Anope::string &ip, int port);
~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;
extern CoreExport Manager *Engine;
} // namespace DNS
#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.
*
*/
#ifndef EXTENSIBLE_H
@@ -9,19 +12,28 @@
#include "anope.h"
/* All items added to Extensible must inherit from this.
*/
class CoreExport ExtensibleItem
{
public:
ExtensibleItem();
virtual ~ExtensibleItem();
virtual void OnDelete();
virtual ~ExtensibleItem() { }
/* 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
{
ExtensibleItemClass(const T& t) : T(t) { }
};
/* Used to attach arbitrary objects to this object using unique keys */
class CoreExport Extensible
{
private:
@@ -33,7 +45,7 @@ class CoreExport 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
*/
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) 2009-2012 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
*
* These classes have been copied from InspIRCd and modified
* for use in Anope.
*
*
*/
#ifndef HASHCOMP_H
@@ -28,13 +25,15 @@ namespace Anope
{
class string;
/* Casemap in use by Anope. ci::string's comparation functions use this (and thus Anope::string) */
extern std::locale casemap;
template<typename charT>
class ascii_ctype : public std::ctype<charT>
/* ASCII case insensitive ctype. */
template<typename char_type>
class ascii_ctype : public std::ctype<char_type>
{
public:
charT do_toupper(charT c) const anope_override
char_type do_toupper(char_type c) const anope_override
{
if (c >= 'a' && c <= 'z')
return c - 32;
@@ -42,7 +41,7 @@ namespace Anope
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')
return c + 32;
@@ -51,29 +50,30 @@ namespace Anope
}
};
template<typename charT>
class rfc1459_ctype : public ascii_ctype<charT>
/* rfc1459 case insensitive ctype, { = [, } = ], and | = \ */
template<typename char_type>
class rfc1459_ctype : public ascii_ctype<char_type>
{
public:
charT do_toupper(charT c) const anope_override
char_type do_toupper(char_type c) const anope_override
{
if (c == '{' || c == '}' || c == '|')
return c - 32;
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 == '\\')
return c + 32;
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
{
+57 -1
View File
@@ -1,11 +1,67 @@
/* Commonly used language strings
/*
*
* (C) 2008-2012 Anope Team
* Contact us at team@anope.org
*
* 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 BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
#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 Services by Andy Church.
*
*
*/
#ifndef LISTS_H
@@ -48,9 +47,9 @@ class CoreExport NumberList
void Process();
/** 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
* Return false to immediatly stop processing the list and return
@@ -71,9 +70,9 @@ class CoreExport ListFormatter
std::vector<Anope::string> columns;
std::vector<ListEntry> entries;
public:
ListFormatter &addColumn(const Anope::string &name);
void addEntry(const ListEntry &entry);
bool isEmpty() const;
ListFormatter &AddColumn(const Anope::string &name);
void AddEntry(const ListEntry &entry);
bool IsEmpty() const;
void Process(std::vector<Anope::string> &);
};
+33 -19
View File
@@ -18,8 +18,13 @@
enum LogType
{
/* Used whenever an administrator uses an administrative comand */
LOG_ADMIN,
/* Used whenever an administrator overides something, such as adding
* access to a channel where they don't have permission to.
*/
LOG_OVERRIDE,
/* Any other command usage */
LOG_COMMAND,
LOG_SERVER,
LOG_CHANNEL,
@@ -37,30 +42,37 @@ enum LogType
struct LogFile
{
Anope::string filename;
public:
std::ofstream stream;
LogFile(const Anope::string &name);
Anope::string GetName() const;
};
/* Represents a single log message */
class CoreExport Log
{
public:
/* Bot that should log this message */
const BotInfo *bi;
/* For commands, the user executing the command */
Anope::string nick;
/* For commands, the user executing the command, but might not always exist */
const User *u;
/* For commands, the account executing teh command, but will not always exist */
const NickCore *nc;
/* For commands, the command being executed */
Command *c;
/* Used for LOG_CHANNEL */
Channel *chan;
/* For commands, the channel the command was executed on, will not always exist */
const ChannelInfo *ci;
/* For LOG_SERVER */
Server *s;
/* For LOG_MODULE */
Module *m;
LogType Type;
Anope::string Category;
std::list<Anope::string> Sources;
LogType type;
Anope::string category;
std::list<Anope::string> sources;
std::stringstream buf;
@@ -93,22 +105,23 @@ class CoreExport Log
}
};
/* Configured in the configuration file, actually does the message logging */
class CoreExport LogInfo
{
public:
std::list<Anope::string> Targets;
std::map<Anope::string, LogFile *> Logfiles;
std::list<Anope::string> Sources;
int LogAge;
std::list<Anope::string> Admin;
std::list<Anope::string> Override;
std::list<Anope::string> Commands;
std::list<Anope::string> Servers;
std::list<Anope::string> Users;
std::list<Anope::string> Channels;
std::list<Anope::string> Normal;
bool RawIO;
bool Debug;
std::list<Anope::string> targets;
std::map<Anope::string, LogFile *> logfiles;
std::list<Anope::string> sources;
int log_age;
std::list<Anope::string> admin;
std::list<Anope::string> override;
std::list<Anope::string> commands;
std::list<Anope::string> servers;
std::list<Anope::string> users;
std::list<Anope::string> channels;
std::list<Anope::string> normal;
bool raw_io;
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;
/* Logs the message l if configured to */
void ProcessMessage(const Log *l);
};
+32 -19
View File
@@ -18,28 +18,41 @@
#include "threadengine.h"
#include "serialize.h"
extern CoreExport bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message);
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
namespace Mail
{
private:
Anope::string SendMailPath;
Anope::string SendFrom;
Anope::string MailTo;
Anope::string Addr;
Anope::string Subject;
Anope::string Message;
bool DontQuoteAddresses;
extern CoreExport bool Send(User *from, NickCore *to, const BotInfo *service, const Anope::string &subject, const Anope::string &message);
extern CoreExport bool Send(NickCore *to, const Anope::string &subject, const Anope::string &message);
extern CoreExport bool Validate(const Anope::string &email);
bool Success;
public:
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);
/* A email message being sent */
class Message : public Thread
{
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
+8 -11
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#ifndef MEMO_H
@@ -27,30 +26,28 @@ enum MemoFlag
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
{
public:
Memo();
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
Anope::string owner;
time_t time; /* When it was sent */
/* When it was sent */
time_t time;
Anope::string sender;
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
{
int16_t memomax;
serialize_checker<std::vector<Memo *> > memos;
Serialize::Checker<std::vector<Memo *> > memos;
std::vector<Anope::string> ignores;
MemoInfo();
+150 -115
View File
@@ -1,126 +1,161 @@
/*
*
* (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"
/* Common IRCD messages.
* Protocol modules may chose to include some, none, or all of these handlers
* 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); }
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 CoreIRCDMessageCapab : IRCDMessage
{
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 Error : IRCDMessage
{
Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { }
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); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
typedef std::pair<ChannelStatus, User *> SJoinUser;
/** Handle a SJOIN.
* @param source The source of the SJOIN
* @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);
};
struct CoreExport Kick : IRCDMessage
{
Kick(Module *creator, const Anope::string &mname = "KICK") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
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) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
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 CoreIRCDMessageError : IRCDMessage
{
CoreIRCDMessageError(const Anope::string &mname = "ERROR") : IRCDMessage(mname, 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
struct CoreExport CoreIRCDMessageJoin : IRCDMessage
{
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 CoreIRCDMessageKick : IRCDMessage
{
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;
};
struct CoreExport CoreIRCDMessageKill : IRCDMessage
{
CoreIRCDMessageKill(const Anope::string &mname = "KILL") : IRCDMessage(mname, 2) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
struct CoreExport CoreIRCDMessageMOTD : IRCDMessage
{
CoreIRCDMessageMOTD(const Anope::string &mname = "MOTD") : IRCDMessage(mname, 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
};
struct CoreExport CoreIRCDMessagePart : IRCDMessage
{
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 CoreIRCDMessagePing : IRCDMessage
{
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 CoreIRCDMessagePrivmsg : IRCDMessage
{
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 CoreIRCDMessageQuit : IRCDMessage
{
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 CoreIRCDMessageSQuit : IRCDMessage
{
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 CoreIRCDMessageStats : IRCDMessage
{
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 CoreIRCDMessageTime : IRCDMessage
{
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 CoreIRCDMessageTopic : IRCDMessage
{
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 CoreIRCDMessageVersion : IRCDMessage
{
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 CoreIRCDMessageWhois : IRCDMessage
{
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;
};
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) { }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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
};
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
*/
enum ChannelModeName
@@ -64,29 +52,6 @@ enum ChannelModeName
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
*/
enum ModeType
@@ -105,9 +70,7 @@ enum ModeType
*/
enum ModeClass
{
/* Channel mode */
MC_CHANNEL,
/* User mode */
MC_USER
};
@@ -116,22 +79,19 @@ enum ModeClass
class CoreExport Mode : public Base
{
public:
/* Class of mode this is */
ModeClass Class;
/* Mode char for this */
char ModeChar;
/* Type of mode this is */
ModeType Type;
/* Class of mode this is (user/channel) */
ModeClass mclass;
/* Mode char for this, eg 'b' */
char mchar;
/* Type of mode this is, eg MODE_LIST */
ModeType type;
/** Default constructor
* @param mClass The type of mode this is
* @param modeChar The mode char
/** constructor
* @param mclass The type of mode this is
* @param mc The mode char
* @param type The mode type
*/
Mode(ModeClass mClass, char modeChar, ModeType type);
/** Default destructor
*/
Mode(ModeClass mclass, char mc, ModeType type);
virtual ~Mode();
};
@@ -141,16 +101,13 @@ class CoreExport UserMode : public Mode
{
public:
/* Mode name */
UserModeName Name;
UserModeName name;
/** Default constructor
* @param nName The mode name
* @param modeChar The mode char
*/
UserMode(UserModeName mName, char modeChar);
/** Default destructor
/** constructor
* @param name The mode name
* @param mc The mode char
*/
UserMode(UserModeName name, char mc);
virtual ~UserMode();
/** Returns the mode name as a string
@@ -161,11 +118,11 @@ class CoreExport UserMode : public Mode
class CoreExport UserModeParam : public UserMode
{
public:
/** Default constructor
* @param mName The mode name
* @param modeChar The mode char
/** constructor
* @param name The mode name
* @param mc The mode char
*/
UserModeParam(UserModeName mName, char modeChar);
UserModeParam(UserModeName name, char mc);
/** Check if the param is valid
* @param value The param
@@ -180,16 +137,13 @@ class CoreExport ChannelMode : public Mode
{
public:
/* Mode name */
ChannelModeName Name;
ChannelModeName name;
/** Default constructor
* @param mName The mode name
* @param modeChar The mode char
*/
ChannelMode(ChannelModeName mName, char modeChar);
/** Default destructor
/** constructor
* @param name The mode name
* @param mc The mode char
*/
ChannelMode(ChannelModeName name, char mc);
virtual ~ChannelMode();
/** Can a user set this mode, used for mlock
@@ -209,13 +163,13 @@ class CoreExport ChannelMode : public Mode
class CoreExport ChannelModeList : public ChannelMode
{
public:
/** Default constructor
* @param mName The mode name
* @param modeChar The mode char
/** constructor
* @param name The mode name
* @param mc The mode char
*/
ChannelModeList(ChannelModeName mName, char modeChar);
ChannelModeList(ChannelModeName name, char mc);
/** Default destructor
/** destructor
*/
virtual ~ChannelModeList();
@@ -251,19 +205,19 @@ class CoreExport ChannelModeList : public ChannelMode
class CoreExport ChannelModeParam : public ChannelMode
{
public:
/** Default constructor
* @param mName The mode name
* @param modeChar The mode char
* @param MinusArg true if this mode sends no arg when unsetting
/** constructor
* @param name The mode name
* @param mc The mode char
* @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();
/* Should we send an arg when unsetting this mode? */
bool MinusNoArg;
bool minus_no_arg;
/** Is the param valid
* @param value The param
@@ -284,25 +238,33 @@ class CoreExport ChannelModeStatus : public ChannelMode
*/
unsigned short Level;
/** Default constructor
* @param mName The mode name
* @param modeChar The mode char
/** constructor
* @param name The mode name
* @param mc The mode char
* @param mSymbol The symbol for the mode, eg @ %
* @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();
};
/* 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)
*/
class CoreExport ChannelModeKey : public ChannelModeParam
{
public:
ChannelModeKey(char modeChar) : ChannelModeParam(CMODE_KEY, modeChar) { }
ChannelModeKey(char mc) : ChannelModeParam(CMODE_KEY, mc) { }
bool IsValid(const Anope::string &value) const anope_override;
};
@@ -313,7 +275,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
class CoreExport ChannelModeAdmin : public ChannelMode
{
public:
ChannelModeAdmin(char modeChar) : ChannelMode(CMODE_ADMINONLY, modeChar) { }
ChannelModeAdmin(char mc) : ChannelMode(CMODE_ADMINONLY, mc) { }
/* Opers only */
bool CanSet(User *u) const anope_override;
@@ -325,7 +287,7 @@ class CoreExport ChannelModeAdmin : public ChannelMode
class CoreExport ChannelModeOper : public ChannelMode
{
public:
ChannelModeOper(char modeChar) : ChannelMode(CMODE_OPERONLY, modeChar) { }
ChannelModeOper(char mc) : ChannelMode(CMODE_OPERONLY, mc) { }
/* Opers only */
bool CanSet(User *u) const anope_override;
@@ -337,7 +299,7 @@ class CoreExport ChannelModeOper : public ChannelMode
class CoreExport ChannelModeRegistered : public ChannelMode
{
public:
ChannelModeRegistered(char modeChar) : ChannelMode(CMODE_REGISTERED, modeChar) { }
ChannelModeRegistered(char mc) : ChannelMode(CMODE_REGISTERED, mc) { }
/* No one mlocks +r */
bool CanSet(User *u) const anope_override;
@@ -355,17 +317,17 @@ class StackerInfo
/** Add a mode to this object
* @param mode The mode
* @param Set true if setting, false if unsetting
* @param Param The param for the mode
* @param set true if setting, false if unsetting
* @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
* and do things such as MLOCK.
* 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
{
@@ -385,6 +347,13 @@ class CoreExport ModeManager
static std::vector<ChannelMode *> ChannelModes;
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
* @param um A UserMode or UserMode derived class
* @return true on success, false on error
@@ -397,29 +366,39 @@ class CoreExport ModeManager
*/
static bool AddChannelMode(ChannelMode *cm);
/** Find a channel mode
* @param Mode The mode
* @return The mode class
/** Remove a user mode from Anope
* @param um A UserMode to remove
*/
static ChannelMode *FindChannelModeByChar(char Mode);
static void RemoveUserMode(UserMode *um);
/** Find a user mode
* @param Mode The mode
* @return The mode class
/** Remove a channel mode from Anope
* @param um A ChanneMode to remove
*/
static UserMode *FindUserModeByChar(char Mode);
static void RemoveChannelMode(ChannelMode *cm);
/** Find a channel mode
* @param Mode The modename
* @param mode The mode
* @return The mode class
*/
static ChannelMode *FindChannelModeByName(ChannelModeName Name);
static ChannelMode *FindChannelModeByChar(char mode);
/** Find a user mode
* @param Mode The modename
* @param mode The mode
* @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
* @param name The mode name
@@ -434,37 +413,44 @@ class CoreExport ModeManager
static UserMode *FindUserModeByString(const Anope::string &name);
/** Gets the channel mode char for a symbol (eg + returns v)
* @param Value The symbol
* @param symbol The symbol
* @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
* @param bi The client to set the modes from
* @param c The channel
* @param cm The channel mode
* @param Set true for setting, false for removing
* @param Param The param, if there is one
* @param set true for setting, false for removing
* @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
* @param bi The client to set the modes from
* @param u The user
* @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
*/
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
*/
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(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
@@ -493,10 +479,10 @@ class CoreExport Entry : public Flags<EntryType>
Anope::string nick, user, host;
/** 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 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
* @return The mask
+5 -3
View File
@@ -18,13 +18,11 @@
#include "anope.h"
#include "base.h"
#include "bots.h"
#include "botserv.h"
#include "channels.h"
#include "commands.h"
#include "config.h"
#include "dns.h"
#include "extensible.h"
#include "extern.h"
#include "hashcomp.h"
#include "language.h"
#include "lists.h"
@@ -34,7 +32,6 @@
#include "messages.h"
#include "modes.h"
#include "modules.h"
#include "oper.h"
#include "opertype.h"
#include "protocol.h"
#include "regexpr.h"
@@ -50,9 +47,14 @@
#include "timers.h"
#include "uplink.h"
#include "users.h"
#include "xline.h"
#include "chanserv.h"
#include "botserv.h"
#include "global.h"
#include "hostserv.h"
#include "memoserv.h"
#include "nickserv.h"
#include "operserv.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 Services by Andy Church.
*
*/
#include "serialize.h"
@@ -31,7 +32,7 @@
{ \
return new x(modname, creator); \
} \
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
{ \
return TRUE; \
} \
@@ -120,7 +121,6 @@ enum EventReturn
EVENT_ALLOW
};
enum ModuleReturn
{
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 */
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
{
private:
int Major;
int Minor;
int Patch;
int version_major;
int version_minor;
int version_patch;
public:
/** Constructor
* @param vMajor The major version numbber
* @param vMinor The minor version numbber
* @param vPatch The patch version numbber
* @param major The major version numbber
* @param minor The minor version numbber
* @param patch The patch version numbber
*/
ModuleVersion(int vMajor, int vMinor, int vPatch);
/** Destructor
*/
virtual ~ModuleVersion();
ModuleVersion(int major, int minor, int patch);
/** Get the major version of Anope this was built against
* @return The major version
@@ -200,7 +197,7 @@ class CoreExport Module : public Extensible
/** Callbacks used in this module
*/
std::list<CallBack *> CallBacks;
std::list<CallBack *> callbacks;
/** Handle for this module, obtained from dlopen()
*/
@@ -259,6 +256,14 @@ class CoreExport Module : public Extensible
*/
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.
* @param c The channel the user has been kicked from.
* @param target The user that has been kicked.
@@ -290,7 +295,7 @@ class CoreExport Module : public Extensible
* @param u The connecting user.
* @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.
* @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 ci The channel the user is requesting info for
* @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'.
* @param access THe access struct
@@ -763,9 +768,9 @@ class CoreExport Module : public Extensible
* @param source The user requesting info
* @param na The nick the user is requesting info from
* @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
* @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
* @param c The channel
* @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
* @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
* @param c The channel
* @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
* @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
* @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
* @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
* @param cm The mode
@@ -921,7 +926,7 @@ class CoreExport Module : public Extensible
* @param req The dns request
* @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,
* 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 void OnSerializeCheck(SerializeType *) { }
virtual void OnSerializeCheck(Serialize::Type *) { }
virtual void OnSerializableConstruct(Serializable *) { }
virtual void OnSerializableDestruct(Serializable *) { }
virtual void OnSerializableUpdate(Serializable *) { }
@@ -1012,6 +1017,10 @@ enum Implementation
class CoreExport ModuleManager
{
public:
/** List of all modules loaded in Anope
*/
static CoreExport std::list<Module *> Modules;
/** Event handler hooks.
* 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);
};
/** 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
{
+9 -1
View File
@@ -3,6 +3,7 @@
* Copyright (C) 2008-2012 Anope Team <team@anope.org>
*
* Please read COPYING and README for further details.
*
*/
#ifndef OPERTYPE_H
@@ -11,15 +12,22 @@
#include "services.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
{
/* The oper's nick */
Anope::string name;
/* The type of operator this operator is */
OperType *ot;
/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
bool require_oper;
Anope::string password;
Anope::string certfp;
/* True if this operator is set in the config */
bool config;
/* Hosts allowed to use this operator block */
std::vector<Anope::string> hosts;
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 Services by Andy Church.
*
*
*/
#ifndef PROTOCOL_H
@@ -16,14 +15,17 @@
#include "services.h"
#include "anope.h"
#include "service.h"
/* Encapsultes the IRCd protocol we are speaking. */
class CoreExport IRCDProto
{
Anope::string proto_name;
IRCDProto() { }
protected:
IRCDProto(const Anope::string &proto_name);
public:
virtual ~IRCDProto();
virtual void SendSVSKillInternal(const BotInfo *, User *, 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 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);
public:
virtual ~IRCDProto();
const Anope::string &GetProtocolName();
/* 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 */
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 *);
/** 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 *) { }
/** 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 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 SendMode(const BotInfo *bi, const Channel *dest, 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 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 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 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 SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
virtual void SendQuit(const User *u, const char *fmt, ...);
virtual void SendPing(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) { }
virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u);
/** Joins one of our users to a channel.
* @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, ...);
/** 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 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 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 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 SendSVSHold(const Anope::string &) { }
virtual void SendSVSHoldDel(const Anope::string &) { }
virtual void SendSGLineDel(const XLine *) { }
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 &) { }
/** Called right before we begin our burst, after we have handshaked successfully with the uplink/
* At this point none of our servesr, users, or channels exist on the uplink
*/
virtual void SendBOB() { }
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 bool IsNickValid(const Anope::string &) { return true; }
virtual bool IsChannelValid(const Anope::string &);
virtual void SendSquit(Server *, const Anope::string &message);
virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
virtual void SendLogin(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
*/
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
@@ -150,21 +237,16 @@ class CoreExport MessageSource
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;
unsigned param_count;
public:
static const std::vector<IRCDMessage *> *Find(const Anope::string &name);
IRCDMessage(const Anope::string &n, unsigned p = 0);
~IRCDMessage();
IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
unsigned GetParamCount() const;
virtual bool Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
};
extern CoreExport IRCDProto *ircdproto;
extern CoreExport IRCDProto *IRCD;
#endif // PROTOCOL_H
+124 -64
View File
@@ -1,15 +1,15 @@
/* Modular support
/*
*
* (C) 2008-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
*/
#ifndef REGCHANNEL_H
#define REGCHANNEL_H
#include "botserv.h"
#include "memo.h"
#include "modes.h"
#include "extensible.h"
@@ -20,7 +20,7 @@
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
*/
@@ -68,10 +68,57 @@ enum ChannelInfoFlag
CI_END
};
const Anope::string ChannelInfoFlagStrings[] = {
"BEGIN", "KEEPTOPIC", "SECUREOPS", "PRIVATE", "TOPICLOCK", "RESTRICTED",
"PEACE", "SECURE", "NO_EXPIRE", "MEMO_HARDMAX", "SECUREFOUNDER",
"SIGNKICK", "SIGNKICK_LEVEL", "SUSPENDED", "PERSIST", "STATS", "NOAUTOOP", ""
/* BotServ SET flags (ChannelInfo::botflags) */
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
};
/* 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
@@ -96,8 +143,8 @@ struct CoreExport BadWord : Serializable
BadWordType type;
BadWord() : Serializable("BadWord") { }
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
/** Flags for auto kick
@@ -108,31 +155,31 @@ enum AutoKickFlag
AK_ISNICK
};
const Anope::string AutoKickFlagString[] = { "AK_ISNICK", "" };
/* AutoKick data. */
class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable
{
public:
AutoKick();
serialize_obj<ChannelInfo> ci;
/* Only one of these can be in use */
/* Channel this autokick is on */
Serialize::Reference<ChannelInfo> ci;
/* Only one of these can be in use. if HasFlag(AK_ISNICK) then nc is in use */
Anope::string mask;
serialize_obj<NickCore> nc;
Serialize::Reference<NickCore> nc;
Anope::string reason;
Anope::string creator;
time_t addtime;
time_t last_used;
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
AutoKick();
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
struct CoreExport ModeLock : Serializable
{
public:
serialize_obj<ChannelInfo> ci;
Serialize::Reference<ChannelInfo> ci;
bool set;
ChannelModeName name;
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);
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
struct CoreExport LogSetting : Serializable
{
serialize_obj<ChannelInfo> ci;
Serialize::Reference<ChannelInfo> ci;
/* Our service name of the command */
Anope::string service_name;
/* The name of the client the command is on */
@@ -159,26 +206,52 @@ struct CoreExport LogSetting : Serializable
time_t created;
LogSetting() : Serializable("LogSetting") { }
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
/* 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:
serialize_obj<NickCore> founder; /* Channel founder */
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<BadWord *> > badwords; /* List of badwords */
Serialize::Reference<NickCore> founder; /* Channel founder */
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<BadWord *> > badwords; /* List of badwords */
std::map<Anope::string, int16_t> levels;
public:
typedef std::multimap<ChannelModeName, ModeLock *> ModeList;
serialize_checker<ModeList> mode_locks;
serialize_checker<std::vector<LogSetting *> > log_settings;
Serialize::Checker<ModeList> mode_locks;
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
*/
ChannelInfo(const Anope::string &chname);
@@ -188,38 +261,10 @@ class CoreExport ChannelInfo : public Serializable, public Extensible, public Fl
*/
ChannelInfo(const ChannelInfo &ci);
/** Default destructor
*/
~ChannelInfo();
Anope::string name; /* Channel name */
serialize_obj<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 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 &);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Change the founder of the channek
* @params nc The new founder
@@ -440,11 +485,26 @@ class CoreExport ChannelInfo : public Serializable, public Extensible, public Fl
/** Clear all privileges from the channel
*/
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 void update_cs_lastseen(User *user, ChannelInfo *ci);
extern CoreExport int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
#endif // REGCHANNEL_H
+119 -57
View File
@@ -25,54 +25,65 @@ namespace Serialize
DT_TEXT,
DT_INT
};
}
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)
class CoreExport stringstream : public std::stringstream
{
std::istringstream is(this->str());
is >> val;
return *this;
}
std::istream &operator>>(Anope::string &val);
private:
Serialize::DataType type;
unsigned _max;
bool operator==(const stringstream &other) const;
bool operator!=(const stringstream &other) const;
public:
stringstream();
stringstream(const stringstream &ss);
Anope::string astr() const;
stringstream &setType(Serialize::DataType t);
Serialize::DataType getType() const;
stringstream &setMax(unsigned m);
unsigned getMax() const;
};
template<typename T> std::istream &operator>>(T &val)
{
std::istringstream is(this->str());
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;
extern void RegisterTypes();
class Type;
template<typename T> class Checker;
template<typename T> class Reference;
}
extern void RegisterTypes();
class SerializeType;
/** A serialziable object. Serializable objects can be serialized into
* a map of stringstreams (Serialize::Data), and then reconstructed or
* updated later at any time.
*/
class CoreExport Serializable : public virtual Base
{
private:
static std::list<Serializable *> *serializable_items;
SerializeType *s_type;
/* A list of every serializable item in Anope.
* 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:
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;
/* The last time this object was commited to the database */
time_t last_commit_time;
Serializable();
@@ -85,10 +96,16 @@ class CoreExport Serializable : public virtual Base
Serializable &operator=(const Serializable &);
public:
/* Unique ID (per type, not globally) for this object */
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();
bool IsCached();
@@ -97,27 +114,43 @@ class CoreExport Serializable : public virtual Base
bool IsTSCached();
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();
};
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 &);
static std::vector<Anope::string> type_order;
static std::map<Anope::string, SerializeType *> types;
static std::vector<Anope::string> TypeOrder;
static std::map<Anope::string, Serialize::Type *> Types;
/* The name of this type, should be a class name */
Anope::string name;
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;
/* 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;
public:
/* Map of Serializable::id to Serializable objects */
std::map<unsigned int, Serializable *> objects;
/** Creates a new serializable type
@@ -125,44 +158,67 @@ class CoreExport SerializeType
* @param f Func to unserialize objects
* @param owner Owner of this type. Leave NULL for the core.
*/
SerializeType(const Anope::string &n, unserialize_func f, Module *owner = NULL);
~SerializeType();
Type(const Anope::string &n, unserialize_func f, Module *owner = NULL);
~Type();
/** Gets the name for this type
* @return The name, eg "NickAlias"
*/
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);
/** Check if this object type has any pending changes and update them.
*/
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;
/** Bumps object type timestamp to current time
*/
void UpdateTimestamp();
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();
};
/** 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>
class serialize_checker
class Serialize::Checker
{
Anope::string name;
T obj;
public:
serialize_checker(const Anope::string &n) : name(n) { }
Checker(const Anope::string &n) : name(n) { }
inline const T* operator->() const
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
return &this->obj;
}
inline T* operator->()
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
return &this->obj;
@@ -170,14 +226,14 @@ class serialize_checker
inline const T& operator*() const
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
return this->obj;
}
inline T& operator*()
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
return this->obj;
@@ -185,44 +241,50 @@ class serialize_checker
inline operator const T&() const
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
return this->obj;
}
inline operator T&()
{
static SerializeType *type = SerializeType::Find(this->name);
static Serialize::Type *type = Serialize::Type::Find(this->name);
if (type)
type->Check();
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>
class serialize_obj : public dynamic_reference_base
class Serialize::Reference : public ReferenceBase
{
protected:
T *ref;
public:
serialize_obj() : ref(NULL)
Reference() : ref(NULL)
{
}
serialize_obj(T *obj) : ref(obj)
Reference(T *obj) : ref(obj)
{
if (obj)
obj->AddReference(this);
}
serialize_obj(const serialize_obj<T> &other) : ref(other.ref)
Reference(const Reference<T> &other) : ref(other.ref)
{
if (*this)
this->ref->AddReference(this);
}
~serialize_obj()
~Reference()
{
if (*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
#define SERVERS_H
@@ -5,13 +17,25 @@
#include "anope.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 const Anope::string ts6_uid_retrieve();
extern CoreExport const Anope::string ts6_sid_retrieve();
namespace Servers
{
/* 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
*/
@@ -24,28 +48,26 @@ enum ServerFlag
SERVER_JUPED
};
const Anope::string ServerFlagStrings[] = { "SERVER_NONE", "SERVER_SYNCING", "SERVER_JUPED", "" };
/** Class representing a server
*/
class CoreExport Server : public Flags<ServerFlag>, public Extensible
{
private:
/* Server name */
Anope::string Name;
Anope::string name;
/* Hops between services and server */
unsigned int Hops;
unsigned int hops;
/* Server description */
Anope::string Description;
Anope::string description;
/* Server ID */
Anope::string SID;
Anope::string sid;
/* Links for this server */
std::vector<Server *> Links;
std::vector<Server *> links;
/* Uplink for this server */
Server *UplinkServer;
Server *uplink;
/* Reason this server was quit */
Anope::string QReason;
Anope::string quit_reason;
public:
/** Constructor
@@ -65,7 +87,7 @@ class CoreExport Server : public Flags<ServerFlag>, public Extensible
public:
/* Number of users on the server */
unsigned Users;
unsigned users;
/** Delete this server with a 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
* @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
* @return true or false
+70 -14
View File
@@ -1,4 +1,5 @@
/*
*
* (C) 2003-2012 Anope Team
* 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 Services by Andy Church.
*
*/
#ifndef SERVICE_H
@@ -15,18 +17,34 @@
#include "anope.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
{
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:
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);
if (it != services.end())
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = Services.find(t);
if (it != Services.end())
{
std::map<Anope::string, Service *>::iterator it2 = it->second.find(n);
if (it2 != it->second.end())
return it2->second;
Anope::string name = n;
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;
@@ -35,15 +53,31 @@ class CoreExport Service : public virtual Base
static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
{
std::vector<Anope::string> keys;
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = services.find(t);
if (it != services.end())
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = Services.find(t);
if (it != Services.end())
for (std::map<Anope::string, Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
keys.push_back(it2->first);
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;
/* Service type, which should be the class name (eg "Command") */
Anope::string type;
/* Service name, commands are usually named service/command */
Anope::string name;
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()
{
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())
throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
smap[this->name] = this;
@@ -66,29 +100,32 @@ class CoreExport Service : public virtual Base
void Unregister()
{
std::map<Anope::string, Service *> &smap = services[this->type];
std::map<Anope::string, Service *> &smap = Services[this->type];
smap.erase(this->name);
if (smap.empty())
services.erase(this->type);
Services.erase(this->type);
}
};
/** Like Reference, but used to refer to Services.
*/
template<typename T>
class service_reference : public dynamic_reference<T>
class ServiceReference : public Reference<T>
{
Anope::string type;
Anope::string name;
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)
{
this->name = n;
this->invalid = true;
}
operator bool() anope_override
@@ -100,6 +137,10 @@ class service_reference : public dynamic_reference<T>
}
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));
if (this->ref)
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
-10
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#ifndef SERVICES_H
@@ -66,13 +65,4 @@
# include "anope_windows.h"
#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
-1
View File
@@ -8,7 +8,6 @@
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
#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 Services by Andy Church.
*
*/
#ifndef SOCKETENGINE_H
@@ -17,7 +18,7 @@
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:
/* Map of 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 Services by Andy Church.
*
*/
#ifndef SOCKETS_H
@@ -104,12 +105,12 @@ class CoreExport cidr
class SocketException : public CoreException
{
public:
/** Default constructor for socket exceptions
/** Constructor for socket exceptions
* @param message Error message
*/
SocketException(const Anope::string &message) : CoreException(message) { }
/** Default destructor
/** Destructor
* @throws Nothing
*/
virtual ~SocketException() throw() { }
@@ -126,9 +127,6 @@ enum SocketFlag
SF_ACCEPTED
};
static const Anope::string SocketFlagStrings[] = { "SF_DEAD", "SF_WRITABLE", "SF_CONNECTING", "SF_CONNECTED", "SF_ACCEPTING", "SF_ACCEPTED", "" };
class CoreExport SocketIO
{
public:
@@ -189,29 +187,29 @@ class CoreExport Socket : public Flags<SocketFlag>
{
protected:
/* Socket FD */
int Sock;
int sock;
/* Is this an IPv6 socket? */
bool IPv6;
bool ipv6;
public:
/* Sockaddrs for bind() (if it's bound) */
sockaddrs bindaddr;
/* I/O functions used for this socket */
SocketIO *IO;
SocketIO *io;
/** Empty constructor, should not be called.
*/
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 ipv6 true if using ipv6
* @param type The socket type, defaults to 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();
@@ -225,7 +223,7 @@ class CoreExport Socket : public Flags<SocketFlag>
*/
bool IsIPv6() const;
/** Mark a socket as blockig
/** Mark a socket as blocking
* @return true if the socket is now blocking
*/
bool SetBlocking();
@@ -266,19 +264,14 @@ class CoreExport BufferedSocket : public virtual Socket
{
protected:
/* 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 */
Anope::string extrabuf;
/* How much data was received from this socket */
int RecvLen;
Anope::string extra_buf;
/* How much data was received from this socket on this recv() */
int recv_len;
public:
/** Constructor
*/
BufferedSocket();
/** Default destructor
*/
virtual ~BufferedSocket();
/** Called when there is something to be received for this socket
@@ -330,15 +323,11 @@ class CoreExport BinarySocket : public virtual Socket
~DataBlock();
};
std::deque<DataBlock *> WriteBuffer;
/* Data to be written out */
std::deque<DataBlock *> write_buffer;
public:
/** Constructor
*/
BinarySocket();
/** Default destructor
*/
virtual ~BinarySocket();
/** 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
*/
ListenSocket(const Anope::string &bindip, int port, bool ipv6);
/** Destructor
*/
virtual ~ListenSocket();
/** Process what has come in from the connection
@@ -435,7 +421,7 @@ class CoreExport ClientSocket : public virtual Socket
{
public:
/* Listen socket this connection came from */
ListenSocket *LS;
ListenSocket *ls;
/* Clients address */
sockaddrs clientaddr;
@@ -469,19 +455,14 @@ class CoreExport Pipe : public Socket
{
public:
/** 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();
/** Destructor
*/
~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;
@@ -489,13 +470,13 @@ class CoreExport Pipe : public Socket
*/
void Notify();
/** Overload to do something useful
/** Called after ProcessRead comes back from Notify(), overload to do something useful
*/
virtual void OnNotify() = 0;
};
extern CoreExport uint32_t TotalRead;
extern CoreExport uint32_t TotalWritten;
extern CoreExport SocketIO normalSocketIO;
extern CoreExport SocketIO NormalSocketIO;
#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
#define THREADENGINE_H
@@ -12,7 +24,7 @@ class CoreExport Thread : public Pipe, public Extensible
public:
/* Handle for this thread */
pthread_t Handle;
pthread_t handle;
/** Threads constructor
*/
+8 -6
View File
@@ -4,8 +4,10 @@
* 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 TIMERS_H
@@ -33,14 +35,14 @@ class CoreExport Timer
bool repeat;
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 now The time now
* @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);
/** Default destructor, removes the timer from the list
/** Destructor, removes the timer from the list
*/
virtual ~Timer();
@@ -91,14 +93,14 @@ class CoreExport TimerManager
static std::vector<Timer *> Timers;
public:
/** 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
* @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
* @param ctime The current time
+10 -1
View File
@@ -7,6 +7,7 @@
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#ifndef UPLINK_H
@@ -14,6 +15,12 @@
#include "sockets.h"
namespace Uplink
{
extern void Connect();
}
/* This is the socket to our uplink */
class UplinkSocket : public ConnectionSocket, public BufferedSocket
{
public:
@@ -22,10 +29,12 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
bool Read(const Anope::string &);
void OnConnect();
void OnError(const Anope::string &);
/* A message sent over the uplink socket */
class CoreExport Message
{
private:
/* The source of the message, can be a server (Me), or any user (one of our bots) */
const Server *server;
const User *user;
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.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#ifndef USERS_H
@@ -19,18 +25,15 @@ typedef Anope::hash_map<User *> user_map;
extern CoreExport user_map UserListByNick, UserListByUID;
class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2>
{
public:
ChannelStatus();
Anope::string BuildCharPrefixList() const;
Anope::string BuildModePrefixList() const;
};
extern CoreExport int OperCount;
extern CoreExport unsigned MaxUserCount;
extern CoreExport time_t MaxUserTime;
/* One per channel per user. Channel and status */
struct ChannelContainer
{
Channel *chan;
ChannelStatus *Status;
ChannelStatus *status;
ChannelContainer(Channel *c) : chan(c) { }
virtual ~ChannelContainer() { }
@@ -38,7 +41,6 @@ struct ChannelContainer
typedef std::list<ChannelContainer *> UChannelList;
/* Online user and channel data. */
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 ident;
Anope::string uid;
bool OnAccess; /* 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 */
std::map<UserModeName, Anope::string> Params; /* Map of user modes and the params this user has */
serialize_obj<NickCore> nc; /* NickCore account the user is currently loggged in as */
/* If the user is on the access list of the nick theyre on */
bool on_access;
/* Bitset of mode names the user has set on them */
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
Anope::string nick; /* User's current nick */
/* User's current nick */
Anope::string nick;
Anope::string host; /* User's real hostname */
Anope::string vhost; /* User's virtual hostname */
Anope::string chost; /* User's cloaked hostname */
Anope::string realname; /* Realname */
Anope::string fingerprint; /* SSL Fingerprint */
Anope::string ip; /* User's IP */
Server *server; /* Server user is connected to */
time_t signon; /* When the user signed on. Set on connect and never modified. */
time_t timestamp; /* Timestamp of the nick. Updated when the nick changes. */
bool SuperAdmin; /* is SuperAdmin on or off? */
/* User's real hostname */
Anope::string host;
/* User's virtual hostname */
Anope::string vhost;
/* User's cloaked hostname */
Anope::string chost;
/* Realname */
Anope::string realname;
/* SSL Fingerprint */
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 */
UChannelList chans;
unsigned short invalid_pw_count; /* # of invalid password attempts */
time_t invalid_pw_time; /* Time of last invalid password */
time_t lastmemosend; /* Last time MS SEND command used */
time_t lastnickreg; /* Last time NS REGISTER cmd used */
time_t lastmail; /* Last time this user sent a mail */
/****************************************************************/
/* Last time this user sent a memo command used */
time_t lastmemosend;
/* Last time this user registered */
time_t lastnickreg;
/* Last time this user sent an email */
time_t lastmail;
/** Create a new user object, initialising necessary fields and
* adds it to the hash
@@ -152,7 +173,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
*/
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;
@@ -201,16 +222,16 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
virtual NickCore *Account() const;
/** 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
*/
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)
* @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
*/
bool IsRecognized(bool CheckSecure = true) const;
bool IsRecognized(bool check_nick = true) const;
/** Check if the user is a services 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 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
* @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 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
* @param bi The client setting the mode
* @param Name The mode name
* @param name The mode name
* @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
* @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
* @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
* @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
*/
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
+17 -14
View File
@@ -1,29 +1,31 @@
/* OperServ support
/*
*
* (C) 2008-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
*/
#ifndef OPER_H
#define OPER_H
#ifndef XLINE_H
#define XLINE_H
#include "serialize.h"
#include "service.h"
/* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
class CoreExport XLine : public Serializable
{
void InitRegex();
public:
Anope::string Mask;
Anope::string mask;
Regex *regex;
Anope::string By;
time_t Created;
time_t Expires;
Anope::string Reason;
Anope::string by;
time_t created;
time_t expires;
Anope::string reason;
XLineManager *manager;
Anope::string UID;
Anope::string id;
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 IsRegex() const;
Serialize::Data serialize() const anope_override;
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
Serialize::Data Serialize() const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
/* Managers XLines. There is one XLineManager per type of XLine. */
class CoreExport XLineManager : public Service
{
char type;
/* 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 */
static serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
static Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
public:
/* List of XLine managers we check users against in XLineManager::CheckAll */
static std::list<XLineManager *> XLineManagers;
@@ -174,4 +177,4 @@ class CoreExport XLineManager : public Service
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 &nick = params[1];
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(BOT_ASSIGN_READONLY);
return;
}
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
return;
}
BotInfo *bi = findbot(nick);
BotInfo *bi = BotInfo::Find(nick, true);
if (!bi)
{
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
{
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(BOT_ASSIGN_READONLY);
return;
}
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+12 -12
View File
@@ -19,10 +19,10 @@ class BadwordsDelCallback : public NumberList
CommandSource &source;
ChannelInfo *ci;
Command *c;
unsigned Deleted;
unsigned deleted;
bool override;
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"))
this->override = true;
@@ -30,12 +30,12 @@ class BadwordsDelCallback : public NumberList
~BadwordsDelCallback()
{
if (!Deleted)
if (!deleted)
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());
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
@@ -44,7 +44,7 @@ class BadwordsDelCallback : public NumberList
return;
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word;
++Deleted;
++deleted;
ci->EraseBadWord(Number - 1);
}
};
@@ -58,7 +58,7 @@ class CommandBSBadwords : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST";
ListFormatter list;
list.addColumn("Number").addColumn("Word").addColumn("Type");
list.AddColumn("Number").AddColumn("Word").AddColumn("Type");
if (!ci->GetBadWordCount())
{
@@ -86,7 +86,7 @@ class CommandBSBadwords : public Command
entry["Number"] = stringify(Number);
entry["Word"] = bw->word;
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);
@@ -105,11 +105,11 @@ class CommandBSBadwords : public Command
entry["Number"] = stringify(i + 1);
entry["Word"] = bw->word;
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());
else
{
@@ -241,7 +241,7 @@ class CommandBSBadwords : public Command
return;
}
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -254,7 +254,7 @@ class CommandBSBadwords : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, channel bad words list modification is temporarily disabled."));
return;
+31 -72
View File
@@ -23,7 +23,7 @@ class CommandBSBot : public Command
const Anope::string &host = params[3];
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());
return;
@@ -47,46 +47,30 @@ class CommandBSBot : public Command
return;
}
/* Check the nick is valid re RFC 2812 */
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))
if (!IRCD->IsNickValid(nick))
{
source.Reply(_("Bot Nicks may only contain valid nick characters."));
return;
}
/* Check the host is valid */
if (!IsValidHost(host))
if (!IRCD->IsHostValid(host))
{
source.Reply(_("Bot Hosts may only contain valid host characters."));
return;
}
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;
}
if (!IRCD->IsIdentValid(user))
{
source.Reply(_("Bot Idents may only contain valid characters."));
return;
}
/* We check whether the nick is registered, and inform the user
* if so. You need to drop the nick manually before you can use
* it as a bot nick from now on -GD
*/
if (findnick(nick))
if (NickAlias::Find(nick))
{
source.Reply(NICK_ALREADY_REGISTERED, nick.c_str());
return;
@@ -116,16 +100,16 @@ class CommandBSBot : public Command
return;
}
BotInfo *bi = findbot(oldnick);
BotInfo *bi = BotInfo::Find(oldnick, true);
if (!bi)
{
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
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;
}
@@ -147,12 +131,6 @@ class CommandBSBot : public Command
return;
}
if (!oldnick.equals_ci(nick) && nickIsServices(nick, false))
{
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
return;
}
/* Checks whether there *are* changes.
* Case sensitive because we may want to change just the case.
* And we must finally check that the nick is not already
@@ -164,42 +142,25 @@ class CommandBSBot : public Command
return;
}
/* Check the nick is valid re RFC 2812 */
if (isdigit(nick[0]) || nick[0] == '-')
if (!IRCD->IsNickValid(nick))
{
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."));
return;
}
if (!host.empty() && !IsValidHost(host))
if (!host.empty() && !IRCD->IsHostValid(host))
{
source.Reply(_("Bot Hosts may only contain valid host characters."));
return;
}
if (!user.empty())
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;
}
if (!user.empty() && !IRCD->IsIdentValid(user))
{
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());
return;
@@ -211,7 +172,7 @@ class CommandBSBot : public Command
* if so. You need to drop the nick manually before you can use
* it as a bot nick from now on -GD
*/
if (findnick(nick))
if (NickAlias::Find(nick))
{
source.Reply(NICK_ALREADY_REGISTERED, nick.c_str());
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. */
XLine x_del(bi->nick);
ircdproto->SendSQLineDel(&x_del);
IRCD->SendSQLineDel(&x_del);
/* Add a Q line for the new nick */
XLine x(nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
IRCD->SendSQLine(NULL, &x);
}
if (!user.empty())
ircdproto->SendQuit(bi, "Quit: Be right back");
IRCD->SendQuit(bi, "Quit: Be right back");
else
{
ircdproto->SendChangeBotNick(bi, nick);
}
IRCD->SendNickChange(bi, nick);
if (!nick.equals_cs(bi->nick))
bi->SetNewNick(nick);
@@ -245,7 +204,7 @@ class CommandBSBot : public Command
if (!user.empty())
{
ircdproto->SendClientIntroduction(bi);
IRCD->SendClientIntroduction(bi);
bi->RejoinAll();
}
@@ -266,16 +225,16 @@ class CommandBSBot : public Command
return;
}
BotInfo *bi = findbot(nick);
BotInfo *bi = BotInfo::Find(nick, true);
if (!bi)
{
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str());
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;
}
@@ -284,7 +243,7 @@ class CommandBSBot : public Command
Log(LOG_ADMIN, source, this) << "DEL " << bi->nick;
source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str());
bi->destroy();
bi->Destroy();
return;
}
public:
@@ -300,7 +259,7 @@ class CommandBSBot : public Command
{
const Anope::string &cmd = params[0];
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot modification is temporarily disabled."));
return;
+2 -2
View File
@@ -27,7 +27,7 @@ class CommandBSBotList : public Command
unsigned count = 0;
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)
{
@@ -39,7 +39,7 @@ class CommandBSBotList : public Command
ListFormatter::ListEntry entry;
entry["Nick"] = (bi->HasFlag(BI_PRIVATE) ? "* " : "") + bi->nick;
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];
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -57,7 +57,7 @@ class CommandBSSay : public Command
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;
// XXX need a way to find if someone is overriding this
@@ -88,7 +88,7 @@ class CommandBSAct : public Command
{
Anope::string message = params[1];
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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)
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;
// 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())
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 BotInfo *bi = findbot(query);
const BotInfo *bi = BotInfo::Find(query, true);
ChannelInfo *ci;
InfoFormatter info(source.nc);
@@ -68,7 +68,7 @@ class CommandBSInfo : public Command
source.Reply(_("Information for bot \002%s\002:"), bi->nick.c_str());
info[_("Mask")] = bi->GetIdent() + "@" + bi->host;
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[_("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"))
{
@@ -98,8 +98,8 @@ class CommandBSInfo : public Command
source.Reply(CHAN_INFO_HEADER, ci->name.c_str());
info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet";
Anope::string enabled = translate(source.nc, _("Enabled"));
Anope::string disabled = translate(source.nc, _("Disabled"));
Anope::string enabled = Language::Translate(source.nc, _("Enabled"));
Anope::string disabled = Language::Translate(source.nc, _("Disabled"));
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 &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."));
else if (ci == NULL)
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]
* 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 */
Anope::string mask;
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));
}
}
@@ -756,7 +754,7 @@ class BSKick : public Module
if (!ci || !ci->bi || !ci->c || !u || u->server->IsULined() || !ci->c->FindUser(u))
return;
Anope::string fmt = translate(u, message);
Anope::string fmt = Language::Translate(u, message);
va_start(args, message);
vsnprintf(buf, sizeof(buf), fmt.c_str(), args);
va_end(args);
@@ -895,7 +893,7 @@ class BSKick : public Module
bool mustkick = false;
/* Normalize the buffer */
Anope::string nbuf = normalizeBuffer(realbuf);
Anope::string nbuf = Anope::NormalizeBuffer(realbuf);
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;
if (c_name.find_ci(this_name + " ") == 0)
{
service_reference<Command> command("Command", info.name);
ServiceReference<Command> command("Command", info.name);
if (command)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandBSSetDontKickOps : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandBSSetDontKickVoices : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
if (ci == NULL)
@@ -39,7 +39,7 @@ class CommandBSSetFantasy : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
if (ci == NULL)
@@ -39,7 +39,7 @@ class CommandBSSetGreet : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
const Anope::string &value = params[1];
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
{
BotInfo *bi = findbot(params[0]);
BotInfo *bi = BotInfo::Find(params[0], true);
const Anope::string &value = params[1];
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);
}
Anope::string Serialize() const
Anope::string AccessSerialize() const
{
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);
}
@@ -119,7 +119,7 @@ class CommandCSAccess : public Command
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"))
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)
mask = "*!*@" + targ->GetDisplayedHost();
else
@@ -148,7 +148,7 @@ class CommandCSAccess : public Command
if (mask.equals_ci(access->mask))
{
/* 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);
return;
@@ -164,7 +164,7 @@ class CommandCSAccess : public Command
return;
}
service_reference<AccessProvider> provider("AccessProvider", "access/access");
ServiceReference<AccessProvider> provider("AccessProvider", "access/access");
if (!provider)
return;
AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create());
@@ -188,9 +188,9 @@ class CommandCSAccess : public Command
{
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)
mask = "*!*@" + targ->GetDisplayedHost();
else
@@ -209,12 +209,12 @@ class CommandCSAccess : public Command
CommandSource &source;
ChannelInfo *ci;
Command *c;
unsigned Deleted;
unsigned deleted;
Anope::string Nicks;
bool Denied;
bool override;
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"))
this->override = true;
@@ -222,18 +222,18 @@ class CommandCSAccess : public Command
~AccessDelCallback()
{
if (Denied && !Deleted)
if (Denied && !deleted)
source.Reply(ACCESS_DENIED);
else if (!Deleted)
else if (!deleted)
source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
else
{
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());
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);
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;
return;
}
++Deleted;
++deleted;
if (!Nicks.empty())
Nicks += ", " + access->mask;
else
@@ -277,12 +277,12 @@ class CommandCSAccess : public Command
ChanAccess *access = ci->GetAccess(i - 1);
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);
else
{
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;
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access));
@@ -333,7 +333,7 @@ class CommandCSAccess : public Command
if (access->last_seen == 0)
timebuf = "Never";
else
timebuf = do_strftime(access->last_seen, NULL, true);
timebuf = Anope::strftime(access->last_seen, NULL, true);
}
ListFormatter::ListEntry entry;
@@ -342,7 +342,7 @@ class CommandCSAccess : public Command
entry["Mask"] = access->mask;
entry["By"] = access->creator;
entry["Last seen"] = timebuf;
this->list.addEntry(entry);
this->list.AddEntry(entry);
}
}
nl_list(list, ci, nick);
@@ -367,7 +367,7 @@ class CommandCSAccess : public Command
if (access->last_seen == 0)
timebuf = "Never";
else
timebuf = do_strftime(access->last_seen, NULL, true);
timebuf = Anope::strftime(access->last_seen, NULL, true);
}
ListFormatter::ListEntry entry;
@@ -376,11 +376,11 @@ class CommandCSAccess : public Command
entry["Mask"] = access->mask;
entry["By"] = access->creator;
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());
else
{
@@ -407,7 +407,7 @@ class CommandCSAccess : public Command
}
ListFormatter list;
list.addColumn("Number").addColumn("Level").addColumn("Mask");
list.AddColumn("Number").AddColumn("Level").AddColumn("Mask");
this->ProcessList(source, ci, params, list);
}
@@ -420,7 +420,7 @@ class CommandCSAccess : public Command
}
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);
}
@@ -460,7 +460,7 @@ class CommandCSAccess : public Command
const Anope::string &nick = params.size() > 2 ? params[2] : "";
const Anope::string &s = params.size() > 3 ? params[3] : "";
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -480,7 +480,7 @@ class CommandCSAccess : public Command
has_access = true;
else if (is_del)
{
const NickAlias *na = findnick(nick);
const NickAlias *na = NickAlias::Find(nick);
if (na && na->nc == source.GetAccount())
has_access = true;
}
@@ -492,7 +492,7 @@ class CommandCSAccess : public Command
this->OnSyntaxError(source, cmd);
else if (!has_access)
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."));
else if (cmd.equals_ci("ADD"))
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());
ListFormatter list;
list.addColumn("Name").addColumn("Level");
list.AddColumn("Name").AddColumn("Level");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
@@ -671,7 +671,7 @@ class CommandCSLevels : public Command
else
entry["Level"] = stringify(j);
list.addEntry(entry);
list.AddEntry(entry);
}
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 &s = params.size() > 3 ? params[3] : "";
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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."));
ListFormatter list;
list.addColumn("Name").addColumn("Description");
list.AddColumn("Name").AddColumn("Description");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
for (unsigned i = 0; i < privs.size(); ++i)
@@ -752,8 +752,8 @@ class CommandCSLevels : public Command
const Privilege &p = privs[i];
ListFormatter::ListEntry entry;
entry["Name"] = p.name;
entry["Description"] = translate(source.nc, p.desc.c_str());
list.addEntry(entry);
entry["Description"] = Language::Translate(source.nc, p.desc.c_str());
list.AddEntry(entry);
}
std::vector<Anope::string> replies;
+24 -24
View File
@@ -52,7 +52,7 @@ class CommandCSAKick : public Command
{
Anope::string mask = params[2];
Anope::string reason = params.size() > 3 ? params[3] : "";
const NickAlias *na = findnick(mask);
const NickAlias *na = NickAlias::Find(mask);
NickCore *nc = NULL;
const AutoKick *akick;
@@ -178,34 +178,34 @@ class CommandCSAKick : public Command
CommandSource &source;
ChannelInfo *ci;
Command *c;
unsigned Deleted;
unsigned deleted;
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()
{
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());
else if (Deleted == 1)
else if (deleted == 1)
source.Reply(_("Deleted 1 entry from %s autokick list."), ci->name.c_str());
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;
FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1)));
FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(number - 1)));
++Deleted;
ci->EraseAkick(Number - 1);
++deleted;
ci->EraseAkick(number - 1);
}
}
delcallback(source, ci, this, mask);
@@ -213,7 +213,7 @@ class CommandCSAKick : public Command
}
else
{
const NickAlias *na = findnick(mask);
const NickAlias *na = NickAlias::Find(mask);
const NickCore *nc = na ? *na->nc : NULL;
for (i = 0, end = ci->GetAkickCount(); i < end; ++i)
@@ -266,11 +266,11 @@ class CommandCSAKick : public Command
Anope::string timebuf, lastused;
if (akick->addtime)
timebuf = do_strftime(akick->addtime, NULL, false);
timebuf = Anope::strftime(akick->addtime, NULL, false);
else
timebuf = UNKNOWN;
if (akick->last_used)
lastused = do_strftime(akick->last_used, NULL, false);
lastused = Anope::strftime(akick->last_used, NULL, false);
else
lastused = UNKNOWN;
@@ -281,7 +281,7 @@ class CommandCSAKick : public Command
entry["Created"] = timebuf;
entry["Last used"] = lastused;
entry["Reason"] = akick->reason;
this->list.addEntry(entry);
this->list.AddEntry(entry);
}
}
nl_list(list, ci, mask);
@@ -303,11 +303,11 @@ class CommandCSAKick : public Command
Anope::string timebuf, lastused;
if (akick->addtime)
timebuf = do_strftime(akick->addtime);
timebuf = Anope::strftime(akick->addtime);
else
timebuf = UNKNOWN;
if (akick->last_used)
lastused = do_strftime(akick->last_used);
lastused = Anope::strftime(akick->last_used);
else
lastused = UNKNOWN;
@@ -318,11 +318,11 @@ class CommandCSAKick : public Command
entry["Created"] = timebuf;
entry["Last used"] = lastused;
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());
else
{
@@ -347,7 +347,7 @@ class CommandCSAKick : public Command
}
ListFormatter list;
list.addColumn("Number").addColumn("Mask").addColumn("Reason");
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
this->ProcessList(source, ci, params, list);
}
@@ -360,7 +360,7 @@ class CommandCSAKick : public Command
}
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);
}
@@ -416,7 +416,7 @@ class CommandCSAKick : public Command
Anope::string cmd = params[1];
Anope::string mask = params.size() > 2 ? params[2] : "";
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -427,7 +427,7 @@ class CommandCSAKick : public Command
this->OnSyntaxError(source, cmd);
else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify"))
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."));
else if (cmd.equals_ci("ADD"))
this->DoAdd(source, ci, params);
+1 -1
View File
@@ -52,7 +52,7 @@ class CommandCSAppendTopic : public Command
{
const Anope::string &newtopic = params[1];
Channel *c = findchan(params[0]);;
Channel *c = Channel::Find(params[0]);;
if (!c)
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 &reason = params.size() > 2 ? params[2] : "Requested";
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -38,7 +38,7 @@ class CommandCSBan : public Command
Channel *c = ci->c;
User *u = source.GetUser();
User *u2 = finduser(target);
User *u2 = User::Find(target, true);
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)
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());
else if (u2->IsProtected())
source.Reply(ACCESS_DENIED);
else
{
Anope::string mask;
get_idealban(ci, u2, mask);
Anope::string mask = ci->GetIdealBan(u2);
// XXX need a way to detect if someone is overriding
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)
continue;
else if (matches_list(ci->c, uc->user, CMODE_EXCEPT))
else if (ci->c->MatchesList(uc->user, CMODE_EXCEPT))
continue;
else if (uc->user->IsProtected())
continue;
+1 -1
View File
@@ -26,7 +26,7 @@ class CommandCSClearUsers : public Command
{
const Anope::string &chan = params[0];
Channel *c = findchan(chan);
Channel *c = Channel::Find(chan);
Anope::string modebuf;
if (!c)
+6 -6
View File
@@ -29,7 +29,7 @@ public:
Anope::string what = params.size() > 2 ? params[2] : "";
User *u = source.GetUser();
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -42,7 +42,7 @@ public:
return;
}
ChannelInfo *target_ci = cs_findchan(target);
ChannelInfo *target_ci = ChannelInfo::Find(target);
if (!target_ci)
{
source.Reply(CHAN_X_NOT_REGISTERED, target.c_str());
@@ -59,11 +59,11 @@ public:
if (what.empty())
{
target_ci->destroy();
target_ci->Destroy();
target_ci = new ChannelInfo(*ci);
target_ci->name = target;
(*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)
{
target_ci->c->ci = target_ci;
@@ -88,7 +88,7 @@ public:
target_ci->c->SetMode(NULL, CMODE_PERM);
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())
@@ -117,7 +117,7 @@ public:
newaccess->creator = taccess->creator;
newaccess->last_seen = taccess->last_seen;
newaccess->created = taccess->created;
newaccess->Unserialize(taccess->Serialize());
newaccess->AccessUnserialize(taccess->AccessSerialize());
target_ci->AddAccess(newaccess);
}
+3 -3
View File
@@ -26,13 +26,13 @@ class CommandCSDrop : public Command
{
const Anope::string &chan = params[0];
if (readonly)
if (Anope::ReadOnly)
{
source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE?
return;
}
ChannelInfo *ci = cs_findchan(chan);
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -57,7 +57,7 @@ class CommandCSDrop : public Command
FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci));
Channel *c = ci->c;
ci->destroy();
ci->Destroy();
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";
/* 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
* part of the code. This way we can enforce SECUREOPS even
* if it's off.
@@ -66,7 +66,7 @@ class CommandCSEnforce : public Command
{
UserContainer *uc = *it;
chan_set_correct_modes(uc->user, c, 0, false);
c->SetCorrectModes(uc->user, false, false);
}
if (hadsecureops)
@@ -95,9 +95,8 @@ class CommandCSEnforce : public Command
{
User *user = users[i];
Anope::string mask;
get_idealban(ci, user, mask);
Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
c->SetMode(NULL, CMODE_BAN, mask);
c->Kick(NULL, user, "%s", reason.c_str());
}
@@ -106,7 +105,6 @@ class CommandCSEnforce : public Command
void DoCModeR(CommandSource &source, Channel *c)
{
ChannelInfo *ci = c->ci;
Anope::string mask;
if (!ci)
return;
@@ -127,8 +125,8 @@ class CommandCSEnforce : public Command
{
User *user = users[i];
get_idealban(ci, user, mask);
Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
Anope::string mask = ci->GetIdealBan(user);
Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN);
if (!c->HasMode(CMODE_REGISTEREDONLY))
c->SetMode(NULL, CMODE_BAN, mask);
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] : "";
Channel *c = findchan(params[0]);
Channel *c = Channel::Find(params[0]);
if (!c)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
+16 -16
View File
@@ -15,7 +15,7 @@
struct EntryMsg : Serializable
{
serialize_obj<ChannelInfo> ci;
Serialize::Reference<ChannelInfo> ci;
Anope::string creator;
Anope::string message;
time_t when;
@@ -28,31 +28,31 @@ struct EntryMsg : Serializable
this->when = ct;
}
Serialize::Data serialize() const anope_override
Serialize::Data Serialize() const anope_override
{
Serialize::Data data;
data["ci"] << this->ci->name;
data["creator"] << this->creator;
data["message"] << this->message;
data["when"].setType(Serialize::DT_INT) << this->when;
data["when"].SetType(Serialize::DT_INT) << this->when;
return data;
}
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
};
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)
return NULL;
@@ -99,7 +99,7 @@ class CommandEntryMessage : public Command
source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str());
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)
{
EntryMsg *msg = (*messages)->at(i);
@@ -107,9 +107,9 @@ class CommandEntryMessage : public Command
ListFormatter::ListEntry entry;
entry["Number"] = stringify(i + 1);
entry["Creator"] = msg->creator;
entry["Created"] = do_strftime(msg->when);
entry["Created"] = Anope::strftime(msg->when);
entry["Message"] = msg->message;
list.addEntry(entry);
list.AddEntry(entry);
}
std::vector<Anope::string> replies;
@@ -159,7 +159,7 @@ class CommandEntryMessage : public Command
unsigned i = convertTo<unsigned>(message);
if (i > 0 && i <= (*messages)->size())
{
(*messages)->at(i - 1)->destroy();
(*messages)->at(i - 1)->Destroy();
(*messages)->erase((*messages)->begin() + i - 1);
if ((*messages)->empty())
ci->Shrink("cs_entrymsg");
@@ -182,7 +182,7 @@ class CommandEntryMessage : public Command
if (messages != NULL)
{
for (unsigned i = 0; i < (*messages)->size(); ++i)
(*messages)->at(i)->destroy();
(*messages)->at(i)->Destroy();
(*messages)->clear();
ci->Shrink("cs_entrymsg");
}
@@ -203,7 +203,7 @@ class CommandEntryMessage : public Command
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)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -258,11 +258,11 @@ class CommandEntryMessage : public Command
class CSEntryMessage : public Module
{
SerializeType entrymsg_type;
Serialize::Type entrymsg_type;
CommandEntryMessage commandentrymsg;
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");
+3 -3
View File
@@ -66,7 +66,7 @@ class CSStats : public Module
{
CommandCSStats commandcsstats;
CommandCSGStats commandcsgstats;
service_reference<SQLProvider> sql;
ServiceReference<SQLProvider> sql;
MySQLInterface sqlinterface;
Anope::string prefix;
public:
@@ -86,7 +86,7 @@ class CSStats : public Module
ConfigReader config;
prefix = config.ReadValue("chanstats", "prefix", "anope_", 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)
@@ -108,7 +108,7 @@ class CSStats : public Module
Anope::string display;
if (params.empty())
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;
else
{
+2 -2
View File
@@ -93,7 +93,7 @@ class CSTop : public Module
CommandCSGTop commandcsgtop;
CommandCSTop10 commandcstop10;
CommandCSGTop10 commandcsgtop10;
service_reference<SQLProvider> sql;
ServiceReference<SQLProvider> sql;
MySQLInterface sqlinterface;
Anope::string prefix;
@@ -115,7 +115,7 @@ class CSTop : public Module
ConfigReader config;
prefix = config.ReadValue("chanstats", "prefix", "anope_", 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)
+15 -15
View File
@@ -32,12 +32,12 @@ class FlagsChanAccess : public ChanAccess
return false;
}
Anope::string Serialize() const
Anope::string AccessSerialize() const
{
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)
this->flags.insert(data[i - 1]);
@@ -46,7 +46,7 @@ class FlagsChanAccess : public ChanAccess
static Anope::string DetermineFlags(const ChanAccess *access)
{
if (access->provider->name == "access/flags")
return access->Serialize();
return access->AccessSerialize();
std::set<char> buffer;
@@ -86,9 +86,9 @@ class CommandCSFlags : public Command
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)
mask = "*!*@" + targ->GetDisplayedHost();
else
@@ -191,7 +191,7 @@ class CommandCSFlags : public Command
return;
}
service_reference<AccessProvider> provider("AccessProvider", "access/flags");
ServiceReference<AccessProvider> provider("AccessProvider", "access/flags");
if (!provider)
return;
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));
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize();
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());
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->AccessSerialize().c_str());
return;
}
@@ -227,7 +227,7 @@ class CommandCSFlags : public Command
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;
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
@@ -257,11 +257,11 @@ class CommandCSFlags : public Command
entry["Mask"] = access->mask;
entry["Flags"] = FlagsChanAccess::DetermineFlags(access);
entry["Creator"] = access->creator;
entry["Created"] = do_strftime(access->created, source.nc, true);
list.addEntry(entry);
entry["Created"] = Anope::strftime(access->created, source.nc, true);
list.AddEntry(entry);
}
if (list.isEmpty())
if (list.IsEmpty())
source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
else
{
@@ -311,7 +311,7 @@ class CommandCSFlags : public Command
const Anope::string &chan = params[0];
const Anope::string &cmd = params[1];
ChannelInfo *ci = cs_findchan(chan);
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
@@ -329,7 +329,7 @@ class CommandCSFlags : public Command
if (!has_access)
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."));
else if (cmd.equals_ci("MODIFY"))
this->DoModify(source, ci, params);
@@ -374,7 +374,7 @@ class CommandCSFlags : public Command
Privilege *p = PrivilegeManager::FindPrivilege(it->second);
if (p == NULL)
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;
+1 -1
View File
@@ -26,7 +26,7 @@ class CommandCSGetKey : public Command
{
const Anope::string &chan = params[0];
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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())
buf += ", ";
buf += translate(nc, str);
buf += Language::Translate(nc, str);
}
}
@@ -39,7 +39,7 @@ class CommandCSInfo : public Command
const Anope::string &chan = params[0];
NickCore *nc = source.nc;
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -65,8 +65,8 @@ class CommandCSInfo : public Command
if (!ci->desc.empty())
info["Description"] = ci->desc;
info["Registered"] = do_strftime(ci->time_registered);
info["Last used"] = do_strftime(ci->last_used);
info["Registered"] = Anope::strftime(ci->time_registered);
info["Last used"] = Anope::strftime(ci->last_used);
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)))))
@@ -103,7 +103,7 @@ class CommandCSInfo : public Command
info["Mode lock"] = ml;
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))
{
+3 -3
View File
@@ -27,7 +27,7 @@ class CommandCSInvite : public Command
const Anope::string &chan = params[0];
User *u = source.GetUser();
Channel *c = findchan(chan);
Channel *c = Channel::Find(chan);
if (!c)
{
@@ -52,7 +52,7 @@ class CommandCSInvite : public Command
if (params.size() == 1)
u2 = u;
else
u2 = finduser(params[1]);
u2 = User::Find(params[1], true);
if (!u2)
{
@@ -71,7 +71,7 @@ class CommandCSInvite : public Command
{
bool override = !source.AccessFor(ci).HasPriv("INVITE");
ircdproto->SendInvite(ci->WhoSends(), c, u2);
IRCD->SendInvite(ci->WhoSends(), c, u2);
if (u2 != u)
{
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";
User *u = source.GetUser();
ChannelInfo *ci = cs_findchan(params[0]);
Channel *c = findchan(params[0]);
User *u2 = finduser(target);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
Channel *c = Channel::Find(params[0]);
User *u2 = User::Find(target, true);
if (!c)
{
+5 -4
View File
@@ -33,8 +33,9 @@ class CommandCSList : public Command
if (pattern[0] == '#')
{
Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */
n2 = myStrGetTokenRemainder(pattern, '-', 1);
Anope::string n1, n2;
sepstream(pattern.substr(1), '-').GetToken(n1, 0);
sepstream(pattern, '-').GetToken(n2, 1);
try
{
@@ -72,7 +73,7 @@ class CommandCSList : public Command
source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str());
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)
{
@@ -99,7 +100,7 @@ class CommandCSList : public Command
entry["Description"] = "[Suspended]";
else
entry["Description"] = ci->desc;
list.addEntry(entry);
list.AddEntry(entry);
}
++count;
}
+11 -11
View File
@@ -28,7 +28,7 @@ public:
{
const Anope::string &channel = params[0];
ChannelInfo *ci = cs_findchan(channel);
ChannelInfo *ci = ChannelInfo::Find(channel);
if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/set"))
@@ -40,7 +40,7 @@ public:
else
{
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)
{
@@ -52,7 +52,7 @@ public:
entry["Command"] = log->command_name;
entry["Method"] = log->method;
entry[""] = log->extra;
list.addEntry(entry);
list.AddEntry(entry);
}
source.Reply(_("Log list for %s:"), ci->name.c_str());
@@ -79,7 +79,7 @@ public:
Anope::string service = command.substr(0, sl),
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)
{
@@ -87,7 +87,7 @@ public:
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)
{
source.Reply(_("%s is not a valid command."), command.c_str());
@@ -117,7 +117,7 @@ public:
{
if (log->extra == extra)
{
log->destroy();
log->Destroy();
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;
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
{
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;
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)
{
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;
}
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());
else if (log->method.equals_ci("MEMO") && memoserv && l->ci->WhoSends() != NULL)
memoserv->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true);
IRCD->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str());
else if (log->method.equals_ci("MEMO") && MemoServService && l->ci->WhoSends() != NULL)
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)
{
if (!ci || !cm || cm->Type != MODE_STATUS)
if (!ci || !cm || cm->type != MODE_STATUS)
return false;
const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" };
@@ -30,7 +30,7 @@ class CommandCSMode : public Command
if (access.HasPriv(accesses[i]))
{
ChannelMode *cm2 = ModeManager::FindChannelModeByName(modes[i]);
if (cm2 == NULL || cm2->Type != MODE_STATUS)
if (cm2 == NULL || cm2->type != MODE_STATUS)
continue;
ChannelModeStatus *cms2 = anope_dynamic_static_cast<ChannelModeStatus *>(cm2);
if (cms2->Level > u_level)
@@ -82,15 +82,15 @@ class CommandCSMode : public Command
}
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)))
source.Reply(_("Missing parameter for mode %c."), cm->ModeChar);
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->mchar);
else
{
ci->SetMLock(cm, adding, mode_param, source.GetNick());
if (!mode_param.empty())
mode_param = " " + mode_param;
source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str());
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->ModeChar << mode_param;
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->mchar << mode_param;
}
}
}
@@ -132,19 +132,19 @@ class CommandCSMode : public Command
}
Anope::string mode_param;
if (!cm->Type == MODE_REGULAR && !sep.GetToken(mode_param))
source.Reply(_("Missing parameter for mode %c."), cm->ModeChar);
if (!cm->type == MODE_REGULAR && !sep.GetToken(mode_param))
source.Reply(_("Missing parameter for mode %c."), cm->mchar);
else
{
if (ci->RemoveMLock(cm, adding, mode_param))
{
if (!mode_param.empty())
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());
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param;
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->mchar << mode_param;
}
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
{
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)
{
@@ -169,11 +169,11 @@ class CommandCSMode : public Command
continue;
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["Creator"] = ml->setter;
entry["Created"] = do_strftime(ml->created, source.nc, false);
list.addEntry(entry);
entry["Created"] = Anope::strftime(ml->created, source.nc, false);
list.AddEntry(entry);
}
source.Reply(_("Mode locks for %s:"), ci->name.c_str());
@@ -218,7 +218,7 @@ class CommandCSMode : public Command
ChannelMode *cm = ModeManager::ChannelModes[j];
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)
ci->c->SetMode(NULL, cm);
@@ -234,7 +234,7 @@ class CommandCSMode : public Command
ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
if (!cm || (u && !cm->CanSet(u)))
continue;
switch (cm->Type)
switch (cm->type)
{
case MODE_REGULAR:
if (adding)
@@ -257,13 +257,13 @@ class CommandCSMode : public Command
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;
}
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)
{
@@ -288,7 +288,7 @@ class CommandCSMode : public Command
}
else
{
User *target = finduser(param);
User *target = User::Find(param, true);
if (target == NULL)
{
source.Reply(NICK_X_NOT_IN_USE, param.c_str());
@@ -316,7 +316,7 @@ class CommandCSMode : public Command
ci->c->SetMode(NULL, cm, param);
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;)
{
const Anope::string &mask = its.first->second;
@@ -343,7 +343,7 @@ class CommandCSMode : public Command
{
const Anope::string &subcommand = params[1];
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (!ci || !ci->c)
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)
{
User *u = source.GetUser();
User *u2 = finduser(nick);
Channel *c = findchan(chan);
User *u2 = User::Find(nick, true);
Channel *c = Channel::Find(chan);
if (!c)
{
+5 -5
View File
@@ -29,10 +29,10 @@ class CommandCSRegister : public Command
User *u = source.GetUser();
NickCore *nc = source.nc;
Channel *c = findchan(params[0]);
ChannelInfo *ci = cs_findchan(params[0]);
Channel *c = Channel::Find(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (readonly)
if (Anope::ReadOnly)
source.Reply(_("Sorry, channel registration is temporarily disabled."));
else if (nc->HasFlag(NI_UNCONFIRMED))
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."));
else if (chan[0] != '#')
source.Reply(CHAN_SYMBOL_REQUIRED);
else if (!ircdproto->IsChannelValid(chan))
else if (!IRCD->IsChannelValid(chan))
source.Reply(CHAN_X_INVALID, chan.c_str());
else if (ci)
source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str());
@@ -55,7 +55,7 @@ class CommandCSRegister : public Command
if (!chdesc.empty())
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);
ml->setter = source.GetNick();
+1 -1
View File
@@ -43,7 +43,7 @@ class CommandCSSASet : public Command
const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
service_reference<Command> command("Command", info.name);
ServiceReference<Command> command("Command", info.name);
if (command)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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;
@@ -48,12 +48,12 @@ struct SeenInfo : Serializable
data["nick2"] << nick2;
data["channel"] << channel;
data["message"] << message;
data["last"].setType(Serialize::DT_INT) << last;
data["last"].SetType(Serialize::DT_INT) << last;
return data;
}
static Serializable* unserialize(Serializable *obj, Serialize::Data &data)
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
{
SeenInfo *s;
if (obj)
@@ -95,8 +95,8 @@ static SeenInfo *FindInfo(const Anope::string &nick)
static bool ShouldHide(const Anope::string &channel, User *u)
{
Channel *targetchan = findchan(channel);
const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : cs_findchan(channel);
Channel *targetchan = Channel::Find(channel);
const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : ChannelInfo::Find(channel);
if (targetchan && targetchan->HasMode(CMODE_SECRET))
return true;
@@ -137,7 +137,7 @@ class CommandOSSeen : public Command
else if (params[0].equals_ci("CLEAR"))
{
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]);
return;
@@ -151,14 +151,14 @@ class CommandOSSeen : public Command
++it;
if (time < buf->second->last)
{
Log(LOG_DEBUG) << buf->first << " was last seen " << do_strftime(buf->second->last) << ", deleting entry";
buf->second->destroy();
Log(LOG_DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry";
buf->second->Destroy();
database.erase(buf);
counter++;
}
}
Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << do_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());
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, Anope::strftime(time, source.nc, true).c_str());
}
else
this->SendSyntax(source);
@@ -199,7 +199,7 @@ class CommandSeen : public Command
return;
}
if (findbot(target) != NULL)
if (BotInfo::Find(target, true) != NULL)
{
source.Reply(_("%s is a client on services."), target.c_str());
return;
@@ -218,15 +218,15 @@ class CommandSeen : public Command
return;
}
User *u2 = finduser(target);
User *u2 = User::Find(target, true);
Anope::string onlinestatus;
if (u2)
onlinestatus = ".";
else
onlinestatus = Anope::printf(_(" but %s mysteriously dematerialized."), target.c_str());
Anope::string timebuf = duration(Anope::CurTime - info->last, source.nc);
Anope::string timebuf2 = do_strftime(info->last, source.nc, true);
Anope::string timebuf = Anope::Duration(Anope::CurTime - info->last, source.nc);
Anope::string timebuf2 = Anope::strftime(info->last, source.nc, true);
if (info->type == NEW)
{
@@ -235,7 +235,7 @@ class CommandSeen : public Command
}
else if (info->type == NICK_TO)
{
u2 = finduser(info->nick2);
u2 = User::Find(info->nick2, true);
if (u2)
onlinestatus = Anope::printf( _(". %s is still online."), u2->nick.c_str());
else
@@ -309,8 +309,8 @@ class DataBasePurger : public CallBack
if ((Anope::CurTime - cur->second->last) > purgetime)
{
Log(LOG_DEBUG) << cur->first << " was last seen " << do_strftime(cur->second->last) << ", purging entry";
cur->second->destroy();
Log(LOG_DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entry";
cur->second->Destroy();
database.erase(cur);
}
}
@@ -320,12 +320,12 @@ class DataBasePurger : public CallBack
class CSSeen : public Module
{
SerializeType seeninfo_type;
Serialize::Type seeninfo_type;
CommandSeen commandseen;
CommandOSSeen commandosseen;
DataBasePurger purger;
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");
@@ -344,14 +344,14 @@ class CSSeen : public Module
void OnReload() anope_override
{
ConfigReader config;
purgetime = dotime(config.ReadValue("cs_seen", "purgetime", "30d", 0));
expiretimeout = dotime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0));
purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0));
expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0));
if (purger.GetSecs() != 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)
UpdateUser(u, NEW, u->nick, "", "", "");
+1 -1
View File
@@ -43,7 +43,7 @@ class CommandCSSet : public Command
const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
service_reference<Command> command("Command", info.name);
ServiceReference<Command> command("Command", info.name);
if (command)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (!ci)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -48,7 +48,7 @@ class CommandCSSetFounder : public Command
return;
}
const NickAlias *na = findnick(params[1]);
const NickAlias *na = NickAlias::Find(params[1]);
if (!na)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
+7 -7
View File
@@ -14,7 +14,7 @@
struct CSMiscData : ExtensibleItem, Serializable
{
serialize_obj<ChannelInfo> ci;
Serialize::Reference<ChannelInfo> ci;
Anope::string name;
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;
@@ -33,9 +33,9 @@ struct CSMiscData : ExtensibleItem, Serializable
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)
return NULL;
@@ -75,7 +75,7 @@ class CommandCSSetMisc : public Command
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)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -108,12 +108,12 @@ class CommandCSSetMisc : public Command
class CSSetMisc : public Module
{
SerializeType csmiscdata_type;
Serialize::Type csmiscdata_type;
CommandCSSetMisc commandcssetmisc;
public:
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");
+1 -1
View File
@@ -24,7 +24,7 @@ class CommandCSSetPeace : public Command
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)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -60,21 +60,19 @@ class CommandCSSetPersist : public Command
ci->bi->Join(c);
}
/* No botserv bot, no channel mode */
/* Give them ChanServ
* Yes, this works fine with no Config->s_BotServ
/* No botserv bot, no channel mode, give them ChanServ.
* Yes, this works fine with no Config->BotServ.
*/
if (!ci->bi && !cm)
{
BotInfo *bi = findbot(Config->ChanServ);
if (!bi)
if (!ChanServ)
{
source.Reply(_("ChanServ is required to enable persist on this network."));
return;
}
bi->Assign(NULL, ci);
if (!ci->c->FindUser(bi))
bi->Join(ci->c);
ChanServ->Assign(NULL, ci);
if (!ci->c->FindUser(ChanServ))
ChanServ->Join(ci->c);
}
/* Set the perm mode */
@@ -111,14 +109,13 @@ class CommandCSSetPersist : public Command
*/
if (!cm && Config->BotServ.empty() && ci->bi)
{
BotInfo *bi = findbot(Config->ChanServ);
if (!bi)
if (!ChanServ)
{
source.Reply(_("ChanServ is required to enable persist on this network."));
return;
}
/* 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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -55,7 +55,7 @@ class CommandCSSetSuccessor : public Command
if (params.size() > 1)
{
const NickAlias *na = findnick(params[1]);
const NickAlias *na = NickAlias::Find(params[1]);
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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];
ChannelInfo *ci = cs_findchan(channel);
ChannelInfo *ci = ChannelInfo::Find(channel);
if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/access/modify"))
@@ -38,20 +38,20 @@ public:
nick = params[1];
AccessGroup ag;
User *u = finduser(nick);
User *u = User::Find(nick, true);
NickAlias *na = NULL;
if (u != NULL)
ag = ci->AccessFor(u);
else
{
na = findnick(nick);
na = NickAlias::Find(nick);
if (na != NULL)
ag = ci->AccessFor(na->nc);
}
if (ag.SuperAdmin)
if (ag.super_admin)
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());
else if (ag.empty())
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];
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;
@@ -32,9 +32,9 @@ struct ChanSuspend : ExtensibleItem, Serializable
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)
return NULL;
@@ -77,7 +77,7 @@ class CommandCSSuspend : public Command
expiry.clear();
}
else
expiry_secs = dotime(expiry);
expiry_secs = Anope::DoTime(expiry);
if (Config->ForceForbidReason && reason.empty())
{
@@ -85,10 +85,10 @@ class CommandCSSuspend : public Command
return;
}
if (readonly)
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
ChannelInfo *ci = cs_findchan(chan);
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci == NULL)
{
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)
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)
@@ -125,7 +125,7 @@ class CommandCSSuspend : public Command
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());
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
{
if (readonly)
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -206,13 +206,13 @@ class CommandCSUnSuspend : public Command
class CSSuspend : public Module
{
SerializeType chansuspend_type;
Serialize::Type chansuspend_type;
CommandCSSuspend commandcssuspend;
CommandCSUnSuspend commandcsunsuspend;
public:
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");
@@ -247,7 +247,7 @@ class CSSuspend : public Module
ci->Shrink("suspend_by");
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -35,7 +35,7 @@ class CommandCSSync : public Command
Log(LOG_COMMAND, source, this, ci);
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());
}
+8 -9
View File
@@ -22,7 +22,7 @@ static Module *me;
class TempBan : public CallBack
{
private:
dynamic_reference<Channel> chan;
Reference<Channel> chan;
Anope::string mask;
public:
@@ -46,7 +46,7 @@ class CommandCSTBan : public Command
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 &time = params[2];
@@ -58,23 +58,22 @@ class CommandCSTBan : public Command
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
else if (!source.AccessFor(c->ci).HasPriv("BAN"))
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());
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());
else if (u2->IsProtected())
source.Reply(ACCESS_DENIED);
else
{
time_t t = dotime(time);
Anope::string mask;
get_idealban(c->ci, u2, mask);
time_t t = Anope::DoTime(time);
Anope::string mask = c->ci->GetIdealBan(u2);
c->SetMode(NULL, CMODE_BAN, 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;
+1 -1
View File
@@ -27,7 +27,7 @@ class CommandCSTopic : public Command
const Anope::string &topic = params.size() > 1 ? params[1] : "";
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
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
{
ChannelInfo *ci = cs_findchan(params[0]);
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL)
{
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
@@ -45,7 +45,7 @@ class CommandCSUnban : public Command
User *u2 = source.GetUser();
if (params.size() > 1)
u2 = finduser(params[1]);
u2 = User::Find(params[1], true);
if (!u2)
{
@@ -55,7 +55,7 @@ class CommandCSUnban : public Command
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())
source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str());
else

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