summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-05-28 12:07:29 -0400
committerAdam <Adam@anope.org>2014-05-28 12:07:54 -0400
commitf29e1cf383529a1a29f02b0669d973f5ee0b7a66 (patch)
tree3c33db276dc9328235bbd572641521ed44458176 /include/modules
parent1253c70e0682fa1490c99c3d2869049a0e3fa2e0 (diff)
Move most of the core pseudoclient logic to modules
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/botserv.h22
-rw-r--r--include/modules/bs_badwords.h4
-rw-r--r--include/modules/bs_info.h2
-rw-r--r--include/modules/bs_kick.h4
-rw-r--r--include/modules/chanserv.h595
-rw-r--r--include/modules/cs_access.h2
-rw-r--r--include/modules/cs_akick.h34
-rw-r--r--include/modules/cs_drop.h2
-rw-r--r--include/modules/cs_info.h2
-rw-r--r--include/modules/cs_mode.h4
-rw-r--r--include/modules/cs_set.h2
-rw-r--r--include/modules/dns.h42
-rw-r--r--include/modules/fantasy.h4
-rw-r--r--include/modules/hs_del.h2
-rw-r--r--include/modules/memoserv.h58
-rw-r--r--include/modules/nickserv.h288
-rw-r--r--include/modules/ns_cert.h16
-rw-r--r--include/modules/ns_drop.h2
-rw-r--r--include/modules/ns_group.h2
-rw-r--r--include/modules/ns_info.h2
-rw-r--r--include/modules/ns_set.h2
-rw-r--r--include/modules/os_ignore.h2
-rw-r--r--include/modules/os_news.h6
-rw-r--r--include/modules/os_session.h2
-rw-r--r--include/modules/redis.h2
-rw-r--r--include/modules/sasl.h20
-rw-r--r--include/modules/ssl.h2
-rw-r--r--include/modules/suspend.h8
-rw-r--r--include/modules/xmlrpc.h2
29 files changed, 1048 insertions, 87 deletions
diff --git a/include/modules/botserv.h b/include/modules/botserv.h
new file mode 100644
index 000000000..09183b53a
--- /dev/null
+++ b/include/modules/botserv.h
@@ -0,0 +1,22 @@
+/*
+ * (C) 2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ */
+
+#pragma once
+
+namespace BotServ
+{
+ class BotServService : public Service
+ {
+ public:
+ BotServService(Module *m) : Service(m, "BotServService", "BotServ")
+ {
+ }
+
+ };
+ static ServiceReference<BotServService> service("BotServService", "BotServ");
+}
diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h
index 390e502c0..ad75aa5bb 100644
--- a/include/modules/bs_badwords.h
+++ b/include/modules/bs_badwords.h
@@ -79,13 +79,13 @@ namespace Event
* @param ci The channel
* @param bw The badword
*/
- virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) anope_abstract;
+ virtual void OnBadWordAdd(ChanServ::Channel *ci, const BadWord *bw) anope_abstract;
/** Called before a badword is deleted from a channel
* @param ci The channel
* @param bw The badword
*/
- virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) anope_abstract;
+ virtual void OnBadWordDel(ChanServ::Channel *ci, const BadWord *bw) anope_abstract;
};
}
diff --git a/include/modules/bs_info.h b/include/modules/bs_info.h
index c9f360dfc..72180e312 100644
--- a/include/modules/bs_info.h
+++ b/include/modules/bs_info.h
@@ -13,7 +13,7 @@ namespace Event
{
/** Called when a user uses botserv/info on a bot or channel.
*/
- virtual void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) anope_abstract;
+ virtual void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) anope_abstract;
};
extern CoreExport EventHandlers<BotInfoEvent> OnBotInfo;
}
diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h
index a783b6017..fed90346c 100644
--- a/include/modules/bs_kick.h
+++ b/include/modules/bs_kick.h
@@ -42,7 +42,7 @@ struct KickerData
public:
virtual ~KickerData() { }
- virtual void Check(ChannelInfo *ci) = 0;
+ virtual void Check(ChanServ::Channel *ci) = 0;
};
namespace Event
@@ -54,7 +54,7 @@ namespace Event
* @param ci Channel the ban is placed on
* @param mask The mask being banned
*/
- virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) anope_abstract;
+ virtual void OnBotBan(User *u, ChanServ::Channel *ci, const Anope::string &mask) anope_abstract;
};
}
diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h
index 37a96e9e7..9170ea2d2 100644
--- a/include/modules/chanserv.h
+++ b/include/modules/chanserv.h
@@ -6,8 +6,89 @@
*
*/
+#pragma once
+
+#include "event.h"
+#include "channels.h"
+#include "modules/nickserv.h"
+#include "modules/memoserv.h"
+#include "bots.h"
+
namespace ChanServ
{
+ static struct
+ {
+ Anope::string name;
+ Anope::string desc;
+ } descriptions[] = {
+ {"ACCESS_CHANGE", _("Allowed to modify the access list")},
+ {"ACCESS_LIST", _("Allowed to view the access list")},
+ {"AKICK", _("Allowed to use the AKICK command")},
+ {"ASSIGN", _("Allowed to assign/unassign a bot")},
+ {"AUTOHALFOP", _("Automatic halfop upon join")},
+ {"AUTOOP", _("Automatic channel operator status upon join")},
+ {"AUTOOWNER", _("Automatic owner upon join")},
+ {"AUTOPROTECT", _("Automatic protect upon join")},
+ {"AUTOVOICE", _("Automatic voice on join")},
+ {"BADWORDS", _("Allowed to modify channel badwords list")},
+ {"BAN", _("Allowed to ban users")},
+ {"FANTASIA", _("Allowed to use fantasy commands")},
+ {"FOUNDER", _("Allowed to issue commands restricted to channel founders")},
+ {"GETKEY", _("Allowed to use GETKEY command")},
+ {"GREET", _("Greet message displayed on join")},
+ {"HALFOP", _("Allowed to (de)halfop users")},
+ {"HALFOPME", _("Allowed to (de)halfop him/herself")},
+ {"INFO", _("Allowed to get full INFO output")},
+ {"INVITE", _("Allowed to use the INVITE command")},
+ {"KICK", _("Allowed to use the KICK command")},
+ {"MEMO", _("Allowed to read channel memos")},
+ {"MODE", _("Allowed to use the MODE command")},
+ {"NOKICK", _("Prevents users being kicked by Services")},
+ {"OP", _("Allowed to (de)op users")},
+ {"OPME", _("Allowed to (de)op him/herself")},
+ {"OWNER", _("Allowed to (de)owner users")},
+ {"OWNERME", _("Allowed to (de)owner him/herself")},
+ {"PROTECT", _("Allowed to (de)protect users")},
+ {"PROTECTME", _("Allowed to (de)protect him/herself")},
+ {"SAY", _("Allowed to use SAY and ACT commands")},
+ {"SET", _("Allowed to set channel settings")},
+ {"SIGNKICK", _("No signed kick when SIGNKICK LEVEL is used")},
+ {"TOPIC", _("Allowed to change channel topics")},
+ {"UNBAN", _("Allowed to unban users")},
+ {"VOICE", _("Allowed to (de)voice users")},
+ {"VOICEME", _("Allowed to (de)voice him/herself")}
+ };
+
+ /* 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) : name(n), desc(d), rank(r)
+ {
+ if (this->desc.empty())
+ for (unsigned j = 0; j < sizeof(descriptions) / sizeof(*descriptions); ++j)
+ if (descriptions[j].name.equals_ci(name))
+ this->desc = descriptions[j].desc;
+ }
+
+ bool operator==(const Privilege &other) const
+ {
+ return this->name.equals_ci(other.name);
+ }
+ };
+
+ class Channel;
+ using registered_channel_map = Anope::hash_map<Channel *>;
+
+ class AccessProvider;
class ChanServService : public Service
{
public:
@@ -15,13 +96,38 @@ namespace ChanServ
{
}
+ virtual Channel *Create(const Anope::string &name) anope_abstract;
+ virtual Channel *Create(const Channel &) anope_abstract;
+ virtual Channel *Find(const Anope::string &name) anope_abstract;
+ virtual registered_channel_map& GetChannels() anope_abstract;
+
/* Have ChanServ hold the channel, that is, join and set +nsti and wait
* for a few minutes so no one can join or rejoin.
*/
- virtual void Hold(Channel *c) anope_abstract;
+ virtual void Hold(::Channel *c) anope_abstract;
+
+ virtual void AddPrivilege(Privilege p) anope_abstract;
+ virtual void RemovePrivilege(Privilege &p) anope_abstract;
+ virtual Privilege *FindPrivilege(const Anope::string &name) anope_abstract;
+ virtual std::vector<Privilege> &GetPrivileges() anope_abstract;
+ virtual void ClearPrivileges() anope_abstract;
+
+ virtual std::vector<AccessProvider *>& GetProviders() anope_abstract;
+
+ virtual void Destruct(ChanAccess *) anope_abstract;
+ virtual void Serialize(const ChanAccess *, Serialize::Data &data) anope_abstract;
+ //XXX
+ typedef std::multimap<const ChanAccess *, const ChanAccess *> Set;
+ typedef std::pair<Set, Set> Path;
+ virtual bool Matches(const ChanAccess *, const User *u, const NickServ::Account *acc, Path &p) anope_abstract;
};
static ServiceReference<ChanServService> service("ChanServService", "ChanServ");
+ inline Channel *Find(const Anope::string name)
+ {
+ return service ? service->Find(name) : nullptr;
+ }
+
namespace Event
{
struct CoreExport PreChanExpire : Events
@@ -30,7 +136,7 @@ namespace ChanServ
* @param ci The channel
* @param expire Set to true to allow the chan to expire
*/
- virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_abstract;
+ virtual void OnPreChanExpire(Channel *ci, bool &expire) anope_abstract;
};
static EventHandlersReference<PreChanExpire> OnPreChanExpire("OnPreChanExpire");
@@ -39,8 +145,491 @@ namespace ChanServ
/** Called before a channel expires
* @param ci The channel
*/
- virtual void OnChanExpire(ChannelInfo *ci) anope_abstract;
+ virtual void OnChanExpire(Channel *ci) anope_abstract;
};
static EventHandlersReference<ChanExpire> OnChanExpire("OnChanExpire");
}
+
+ /* It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Channel : public Serializable, public Extensible
+ {
+ public:
+ /* channels who reference this one */
+ Anope::map<int> references;
+ Serialize::Reference<NickServ::Account> founder; /* Channel founder */
+ Serialize::Reference<NickServ::Account> successor; /* Who gets the channel if the founder nick is dropped or expires */
+ Serialize::Checker<std::vector<ChanAccess *> > access; /* List of authorized users */
+ Serialize::Checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
+ Anope::map<int16_t> levels;
+
+ Anope::string name; /* Channel name */
+ 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 */
+
+ ::Channel::ModeList last_modes; /* The last modes set on this channel */
+
+ int16_t bantype;
+
+ MemoServ::MemoInfo *memos = nullptr;
+
+ ::Channel *c; /* Pointer to channel, if the channel exists */
+
+ /* For BotServ */
+ Serialize::Reference<BotInfo> bi; /* Bot used on this channel */
+
+ time_t banexpire; /* Time bans expire in */
+
+ protected:
+ Channel() : Serializable("ChannelInfo"), access("ChanAccess"), akick("AutoKick") { }
+
+ public:
+ /** Is the user the real founder?
+ * @param user The user
+ * @return true or false
+ */
+ virtual bool IsFounder(const User *user) anope_abstract;
+
+ /** Change the founder of the channek
+ * @params nc The new founder
+ */
+ virtual void SetFounder(NickServ::Account *nc) anope_abstract;
+
+ /** Get the founder of the channel
+ * @return The founder
+ */
+ virtual NickServ::Account *GetFounder() const anope_abstract;
+
+ virtual void SetSuccessor(NickServ::Account *nc) anope_abstract;
+ virtual NickServ::Account *GetSuccessor() const anope_abstract;
+
+ /** Find which bot should send mode/topic/etc changes for this channel
+ * @return The bot
+ */
+ virtual BotInfo *WhoSends() const anope_abstract;
+
+ /** Add an entry to the channel access list
+ * @param access The entry
+ */
+ virtual void AddAccess(ChanAccess *access) anope_abstract;
+
+ /** Get an entry from the channel access list by index
+ *
+ * @param index The index in the access list vector
+ * @return A ChanAccess struct corresponding to the index given, or NULL if outside the bounds
+ *
+ * Retrieves an entry from the access list that matches the given index.
+ */
+ virtual ChanAccess *GetAccess(unsigned index) const anope_abstract;
+
+ /** Retrieve the access for a user or group in the form of a vector of access entries
+ * (as multiple entries can affect a single user).
+ */
+ virtual AccessGroup AccessFor(const User *u) anope_abstract;
+ virtual AccessGroup AccessFor(const NickServ::Account *nc) anope_abstract;
+
+ /** Get the size of the accss vector for this channel
+ * @return The access vector size
+ */
+ virtual unsigned GetAccessCount() const anope_abstract;
+
+ /** Get the number of access entries for this channel,
+ * including those that are on other channels.
+ */
+ virtual unsigned GetDeepAccessCount() const anope_abstract;
+
+ /** Erase an entry from the channel access list
+ *
+ * @param index The index in the access list vector
+ *
+ * @return The erased entry
+ */
+ virtual ChanAccess *EraseAccess(unsigned index) anope_abstract;
+
+ /** Clear the entire channel access list
+ *
+ * Clears the entire access list by deleting every item and then clearing the vector.
+ */
+ virtual void ClearAccess() anope_abstract;
+
+ /** Add an akick entry to the channel by NickServ::Account
+ * @param user The user who added the akick
+ * @param akicknc The nickcore being akicked
+ * @param reason The reason for the akick
+ * @param t The time the akick was added, defaults to now
+ * @param lu The time the akick was last used, defaults to never
+ */
+ virtual AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;
+
+ /** Add an akick entry to the channel by reason
+ * @param user The user who added the akick
+ * @param mask The mask of the akick
+ * @param reason The reason for the akick
+ * @param t The time the akick was added, defaults to now
+ * @param lu The time the akick was last used, defaults to never
+ */
+ virtual AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;
+
+ /** Get an entry from the channel akick list
+ * @param index The index in the akick vector
+ * @return The akick structure, or NULL if not found
+ */
+ virtual AutoKick* GetAkick(unsigned index) const anope_abstract;
+
+ /** Get the size of the akick vector for this channel
+ * @return The akick vector size
+ */
+ virtual unsigned GetAkickCount() const anope_abstract;
+
+ /** Erase an entry from the channel akick list
+ * @param index The index of the akick
+ */
+ virtual void EraseAkick(unsigned index) anope_abstract;
+
+ /** Clear the whole akick list
+ */
+ virtual void ClearAkick() anope_abstract;
+
+ /** Get the level for a privilege
+ * @param priv The privilege name
+ * @return the level
+ * @throws CoreException if priv is not a valid privilege
+ */
+ virtual int16_t GetLevel(const Anope::string &priv) const anope_abstract;
+
+ /** Set the level for a privilege
+ * @param priv The privilege priv
+ * @param level The new level
+ */
+ virtual void SetLevel(const Anope::string &priv, int16_t level) anope_abstract;
+
+ /** Remove a privilege from the channel
+ * @param priv The privilege
+ */
+ virtual void RemoveLevel(const Anope::string &priv) anope_abstract;
+
+ /** Clear all privileges from the channel
+ */
+ virtual void ClearLevels() anope_abstract;
+
+ /** 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
+ */
+ virtual Anope::string GetIdealBan(User *u) const anope_abstract;
+
+ virtual void AddChannelReference(const Anope::string &what) anope_abstract;
+ virtual void RemoveChannelReference(const Anope::string &what) anope_abstract;
+ virtual void GetChannelReferences(std::deque<Anope::string> &chans) anope_abstract;
+ };
+
+ enum
+ {
+ ACCESS_INVALID = -10000,
+ ACCESS_FOUNDER = 10001
+ };
+
+ /* 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) : Service(o, "AccessProvider", n)
+ {
+ std::vector<AccessProvider *>& providers = service->GetProviders();
+ providers.push_back(this);
+ }
+
+ virtual ~AccessProvider()
+ {
+ std::vector<AccessProvider *>& providers = service->GetProviders();
+ std::vector<AccessProvider *>::iterator it = std::find(providers.begin(), providers.end(), this);
+ if (it != providers.end())
+ providers.erase(it);
+ }
+
+ /** Creates a new ChanAccess entry using this provider.
+ * @return The new entry
+ */
+ virtual ChanAccess *Create() anope_abstract;
+ };
+
+ /* Represents one entry of an access list on a channel. */
+ class CoreExport ChanAccess : public Serializable
+ {
+ public:
+ typedef std::multimap<const ChanAccess *, const ChanAccess *> Set;
+ /* shows the 'path' taken to determine if an access entry matches a user
+ * .first are access entries checked
+ * .second are access entries which match
+ */
+ typedef std::pair<Set, Set> Path;
+
+ /* The provider that created this access entry */
+ AccessProvider *provider;
+ /* Channel this access entry is on */
+ Serialize::Reference<Channel> ci;
+ /* account this access entry is for, if any */
+ Serialize::Reference<NickServ::Account> nc;
+ Anope::string mask;
+ Anope::string creator;
+ time_t last_seen;
+ time_t created;
+
+ ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p) { }
+
+ virtual ~ChanAccess()
+ {
+ service->Destruct(this);
+ }
+
+ void Serialize(Serialize::Data &data) const override
+ {
+ service->Serialize(this, data);
+ }
+
+ /** Check if this access entry matches the given user or account
+ * @param u The user
+ * @param nc The account
+ * @param p The path to the access object which matches will be put here
+ */
+ virtual bool Matches(const User *u, const NickServ::Account *acc, Path &p) const
+ {
+ return service->Matches(this, u, acc, p);
+ }
+
+ /** Check if this access entry has the given privilege.
+ * @param name The privilege name
+ */
+ virtual bool HasPriv(const Anope::string &name) const anope_abstract;
+
+ /** 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 anope_abstract;
+
+ /** Unserialize this access entry from the given data. This data
+ * will be fetched from AccessSerialize.
+ */
+ virtual void AccessUnserialize(const Anope::string &data) anope_abstract;
+
+ /* Comparison operators to other Access entries */
+ virtual bool operator>(const ChanAccess &other) const
+ {
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return this_p && !other_p;
+ }
+
+ return false;
+ }
+
+ virtual bool operator<(const ChanAccess &other) const
+ {
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return !this_p && other_p;
+ }
+
+ return false;
+ }
+
+ bool operator>=(const ChanAccess &other) const
+ {
+ return !(*this < other);
+ }
+
+ bool operator<=(const ChanAccess &other) const
+ {
+ return !(*this > other);
+ }
+ };
+
+ /* A group of access entries. This is used commonly, for example with ChanServ::Channel::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 ChanServ::Channel *ci;
+ /* Path from these entries to other entries that they depend on */
+ ChanAccess::Path path;
+ /* Account these entries affect, if any */
+ const NickServ::Account *nc;
+ /* super_admin always gets all privs. founder is a special case where ci->founder == nc */
+ bool super_admin, founder;
+
+ AccessGroup()
+ {
+ this->ci = NULL;
+ this->nc = NULL;
+ this->super_admin = this->founder = false;
+ }
+
+ private:
+ bool HasPriv(const ChanAccess *access, const Anope::string &name) const
+ {
+ EventReturn MOD_RESULT = ::Event::OnCheckPriv(&::Event::CheckPriv::OnCheckPriv, access, name);
+ if (MOD_RESULT == EVENT_ALLOW || access->HasPriv(name))
+ {
+ typedef std::multimap<const ChanAccess *, const ChanAccess *> P;
+ std::pair<P::const_iterator, P::const_iterator> it = this->path.second.equal_range(access);
+ if (it.first != it.second)
+ /* check all of the paths for this entry */
+ for (; it.first != it.second; ++it.first)
+ {
+ const ChanAccess *a = it.first->second;
+ /* if only one path fully matches then we are ok */
+ if (HasPriv(a, name))
+ return true;
+ }
+ else
+ /* entry is the end of a chain, all entries match, ok */
+ return true;
+ }
+
+ /* entry does not match or none of the chains fully match */
+ return false;
+ }
+
+ public:
+ /** 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
+ {
+ if (this->super_admin)
+ return true;
+ else if (!ci || ci->GetLevel(priv) == ACCESS_INVALID)
+ return false;
+
+ /* Privileges prefixed with auto are understood to be given
+ * automatically. Sometimes founders want to not automatically
+ * obtain privileges, so we will let them */
+ bool auto_mode = !priv.find("AUTO");
+
+ /* Only grant founder privilege if this isn't an auto mode or if they don't match any entries in this group */
+ if ((!auto_mode || this->empty()) && this->founder)
+ return true;
+
+ EventReturn MOD_RESULT;
+ MOD_RESULT = ::Event::OnGroupCheckPriv(&::Event::GroupCheckPriv::OnGroupCheckPriv, this, priv);
+ if (MOD_RESULT != EVENT_CONTINUE)
+ return MOD_RESULT == EVENT_ALLOW;
+
+ for (unsigned i = this->size(); i > 0; --i)
+ {
+ ChanAccess *access = this->at(i - 1);
+
+ if (HasPriv(access, priv))
+ return true;
+ }
+
+ return false;
+ }
+
+ /** 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
+ {
+ ChanAccess *highest = NULL;
+ for (unsigned i = 0; i < this->size(); ++i)
+ if (highest == NULL || *this->at(i) > *highest)
+ highest = this->at(i);
+ return highest;
+ }
+
+ /* Comparison operators to other AccessGroups */
+ bool operator>(const AccessGroup &other) const
+ {
+ if (other.super_admin)
+ return false;
+ else if (this->super_admin)
+ return true;
+ else if (other.founder)
+ return false;
+ else if (this->founder)
+ return true;
+
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return this_p && !other_p;
+ }
+
+ return false;
+ }
+
+ bool operator<(const AccessGroup &other) const
+ {
+ if (this->super_admin)
+ return false;
+ else if (other.super_admin)
+ return true;
+ else if (this->founder)
+ return false;
+ else if (other.founder)
+ return true;
+
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return !this_p && other_p;
+ }
+
+ return false;
+ }
+
+ bool operator>=(const AccessGroup &other) const
+ {
+ return !(*this < other);
+ }
+
+ bool operator<=(const AccessGroup &other) const
+ {
+ return !(*this > other);
+ }
+ };
}
diff --git a/include/modules/cs_access.h b/include/modules/cs_access.h
index 8c6778799..877a98f02 100644
--- a/include/modules/cs_access.h
+++ b/include/modules/cs_access.h
@@ -17,6 +17,6 @@ namespace Event
* @param priv The privilege changed
* @param what The new level
*/
- virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) anope_abstract;
+ virtual void OnLevelChange(CommandSource &source, ChanServ::Channel *ci, const Anope::string &priv, int16_t what) anope_abstract;
};
}
diff --git a/include/modules/cs_akick.h b/include/modules/cs_akick.h
index ab02985c1..08a72260f 100644
--- a/include/modules/cs_akick.h
+++ b/include/modules/cs_akick.h
@@ -7,6 +7,36 @@
*
*/
+ /* AutoKick data. */
+class CoreExport AutoKick : public Serializable
+{
+ public:
+ /* Channel this autokick is on */
+ Serialize::Reference<ChanServ::Channel> ci;
+
+ Anope::string mask;
+ Serialize::Reference<NickServ::Account> nc;
+
+ Anope::string reason;
+ Anope::string creator;
+ time_t addtime;
+ time_t last_used;
+
+ protected:
+ AutoKick() : Serializable("AutoKick") { }
+ public:
+ virtual ~AutoKick() { }
+};
+
+class AutoKickService : public Service
+{
+ public:
+ AutoKickService(Module *o) : Service(o, "AutoKickService", "AutoKickService") { }
+
+ virtual AutoKick* Create() anope_abstract;
+};
+static ServiceReference<AutoKickService> akick("AutoKickService", "AutoKickService");
+
namespace Event
{
struct CoreExport Akick : Events
@@ -16,13 +46,13 @@ namespace Event
* @param ci The channel
* @param ak The akick
*/
- virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) anope_abstract;
+ virtual void OnAkickAdd(CommandSource &source, ChanServ::Channel *ci, const AutoKick *ak) anope_abstract;
/** Called before removing an akick from a channel
* @param source The source of the command
* @param ci The channel
* @param ak The akick
*/
- virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) anope_abstract;
+ virtual void OnAkickDel(CommandSource &source, ChanServ::Channel *ci, const AutoKick *ak) anope_abstract;
};
}
diff --git a/include/modules/cs_drop.h b/include/modules/cs_drop.h
index e2a9ace8a..49247b3cb 100644
--- a/include/modules/cs_drop.h
+++ b/include/modules/cs_drop.h
@@ -15,6 +15,6 @@ namespace Event
* @param source The user dropping the channel
* @param ci The channel
*/
- virtual EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) anope_abstract;
+ virtual EventReturn OnChanDrop(CommandSource &source, ChanServ::Channel *ci) anope_abstract;
};
}
diff --git a/include/modules/cs_info.h b/include/modules/cs_info.h
index 7f0429387..7b19abd19 100644
--- a/include/modules/cs_info.h
+++ b/include/modules/cs_info.h
@@ -17,7 +17,7 @@ namespace Event
* @param info Data to show the user requesting information
* @param show_hidden true if we should show the user everything
*/
- virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_abstract;
+ virtual void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) anope_abstract;
};
}
diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h
index 4c1dc5d55..61ef93f95 100644
--- a/include/modules/cs_mode.h
+++ b/include/modules/cs_mode.h
@@ -97,14 +97,14 @@ namespace Event
* @param lock The mode lock
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
- virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_abstract;
+ virtual EventReturn OnMLock(ChanServ::Channel *ci, ModeLock *lock) anope_abstract;
/** Called when a mode is about to be unlocked
* @param ci The channel the mode is being unlocked from
* @param lock The mode lock
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
- virtual EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_abstract;
+ virtual EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) anope_abstract;
};
}
diff --git a/include/modules/cs_set.h b/include/modules/cs_set.h
index 3ddf2f41c..355459f7c 100644
--- a/include/modules/cs_set.h
+++ b/include/modules/cs_set.h
@@ -18,7 +18,7 @@ namespace Event
* @param setting The setting passed to the command. Probably ON/OFF.
* @return EVENT_ALLOW to bypass access checks, EVENT_STOP to halt immediately.
*/
- virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) anope_abstract;
+ virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChanServ::Channel *ci, const Anope::string &setting) anope_abstract;
};
static EventHandlersReference<SetChannelOption> OnSetChannelOption("OnSetChannelOption");
}
diff --git a/include/modules/dns.h b/include/modules/dns.h
index e340c3f2b..d0cecf080 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -9,7 +9,7 @@
* Based on the original code of Services by Andy Church.
*
*/
-
+
#ifndef DNS_H
#define DNS_H
@@ -53,7 +53,7 @@ namespace DNS
QUERYFLAGS_Z = 0x70,
QUERYFLAGS_RCODE = 0xF
};
-
+
enum Error
{
ERROR_NONE,
@@ -70,42 +70,42 @@ namespace DNS
ERROR_NO_RECORDS,
ERROR_INVALIDTYPE
};
-
+
struct Question
{
Anope::string name;
QueryType type;
unsigned short qclass;
-
+
Question() : type(QUERY_NONE), qclass(0) { }
Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { }
- inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
+ inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
struct hash
{
- size_t operator()(const Question &q) const
+ size_t operator()(const Question &q) const
{
return Anope::hash_ci()(q.name);
}
};
};
-
+
struct ResourceRecord : Question
{
unsigned int ttl;
Anope::string rdata;
time_t created;
-
+
ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { }
ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { }
};
-
+
struct Query
{
std::vector<Question> questions;
std::vector<ResourceRecord> answers, authorities, additional;
Error error;
-
+
Query() : error(ERROR_NONE) { }
Query(const Question &q) : error(ERROR_NONE) { questions.push_back(q); }
};
@@ -123,14 +123,14 @@ namespace DNS
virtual void Process(Request *req) = 0;
virtual void RemoveRequest(Request *req) = 0;
-
+
virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) = 0;
-
+
virtual void UpdateSerial() = 0;
virtual void Notify(const Anope::string &zone) = 0;
virtual uint32_t GetSerial() const = 0;
};
-
+
/** A DNS query.
*/
class Request : public Timer, public Question
@@ -146,22 +146,22 @@ namespace DNS
Request(Manager *mgr, Module *c, const Anope::string &addr, QueryType qt, bool cache = false) : Timer(0), Question(addr, qt), manager(mgr),
use_cache(cache), id(0), creator(c) { }
-
+
virtual ~Request()
{
manager->RemoveRequest(this);
}
-
+
/** 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, xalls OnError and lets the TimerManager
* delete this request.
*/
@@ -173,7 +173,7 @@ namespace DNS
this->OnError(&rr);
}
};
-
+
} // namespace DNS
namespace Event
@@ -189,7 +189,7 @@ namespace Event
static EventHandlersReference<DnsRequest> OnDnsRequest("OnDnsRequest");
}
-
+
#endif // DNS_H
-
-
+
+
diff --git a/include/modules/fantasy.h b/include/modules/fantasy.h
index a7944cef9..bb13b959d 100644
--- a/include/modules/fantasy.h
+++ b/include/modules/fantasy.h
@@ -18,7 +18,7 @@ namespace Event
* @param params The params
* @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
*/
- virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> &params) anope_abstract;
+ virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChanServ::Channel *ci, const std::vector<Anope::string> &params) anope_abstract;
};
struct CoreExport BotNoFantasyAccess : Events
@@ -30,6 +30,6 @@ namespace Event
* @param params The params
* @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
*/
- virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> &params) anope_abstract;
+ virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChanServ::Channel *ci, const std::vector<Anope::string> &params) anope_abstract;
};
}
diff --git a/include/modules/hs_del.h b/include/modules/hs_del.h
index d4a5c7666..fdec23b21 100644
--- a/include/modules/hs_del.h
+++ b/include/modules/hs_del.h
@@ -13,6 +13,6 @@ namespace Event
/** Called when a vhost is deleted
* @param na The nickalias of the vhost
*/
- virtual void OnDeleteVhost(NickAlias *na) anope_abstract;
+ virtual void OnDeleteVhost(NickServ::Nick *na) anope_abstract;
};
}
diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h
index 4e5d67de6..99f34b6e9 100644
--- a/include/modules/memoserv.h
+++ b/include/modules/memoserv.h
@@ -6,6 +6,10 @@
*
*/
+#pragma once
+
+#include "module.h"
+
namespace MemoServ
{
class MemoServService : public Service
@@ -18,26 +22,29 @@ namespace MemoServ
MEMO_TOO_FAST,
MEMO_TARGET_FULL
};
-
+
MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ")
{
}
-
+
/** Sends a memo.
* @param source The source of the memo, can be anythin.
* @param target The target of the memo, nick or channel.
* @param message Memo text
* @param force true to force the memo, restrictions/delays etc are not checked
*/
- virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0;
-
+ virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) anope_abstract;
+
/** Check for new memos and notify the user if there are any
* @param u The user
*/
- virtual void Check(User *u) = 0;
+ virtual void Check(User *u) anope_abstract;
+
+ virtual Memo *CreateMemo() anope_abstract;
+ virtual MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_registered, bool &is_chan, bool create) anope_abstract;
};
static ServiceReference<MemoServService> service("MemoServService", "MemoServ");
-
+
namespace Event
{
struct CoreExport MemoSend : Events
@@ -51,7 +58,7 @@ namespace MemoServ
virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) anope_abstract;
};
static EventHandlersReference<MemoSend> OnMemoSend("OnMemoSend");
-
+
struct CoreExport MemoDel : Events
{
/** Called when a memo is deleted
@@ -63,4 +70,41 @@ namespace MemoServ
};
static EventHandlersReference<MemoDel> OnMemoDel("OnMemoDel");
}
+
+ class Memo : public Serializable
+ {
+ public:
+ bool unread;
+ bool receipt;
+ protected:
+ Memo() : Serializable("Memo") { }
+ public:
+
+ Anope::string owner;
+ /* 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 = 0;
+ Serialize::Checker<std::vector<Memo *> > memos;
+ std::vector<Anope::string> ignores;
+
+ MemoInfo() : memos("Memo") { }
+ virtual ~MemoInfo() { }
+
+ virtual Memo *GetMemo(unsigned index) const anope_abstract;
+
+ virtual unsigned GetIndex(Memo *m) const anope_abstract;
+
+ virtual void Del(unsigned index) anope_abstract;
+
+ virtual bool HasIgnore(User *u) anope_abstract;
+ };
}
diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h
index 0ede4130e..a55786ffb 100644
--- a/include/modules/nickserv.h
+++ b/include/modules/nickserv.h
@@ -7,8 +7,20 @@
*
*/
+#pragma once
+
+#include "event.h"
+#include "service.h"
+
namespace NickServ
{
+ class Nick;
+ class Account;
+ class IdentifyRequestListener;
+
+ typedef Anope::hash_map<Nick *> nickalias_map;
+ typedef Anope::hash_map<Account *> nickcore_map;
+
class NickServService : public Service
{
public:
@@ -17,11 +29,33 @@ namespace NickServ
}
virtual void Validate(User *u) anope_abstract;
- virtual void Collide(User *u, NickAlias *na) anope_abstract;
- virtual void Release(NickAlias *na) anope_abstract;
+ virtual void Collide(User *u, Nick *na) anope_abstract;
+ virtual void Release(Nick *na) anope_abstract;
+
+ virtual IdentifyRequest *CreateIdentifyRequest(IdentifyRequestListener *l, Module *owner, const Anope::string &acc, const Anope::string &pass) anope_abstract;
+ virtual std::set<IdentifyRequest *>& GetIdentifyRequests() anope_abstract;
+
+ virtual nickalias_map& GetNickList() anope_abstract;
+ virtual nickcore_map& GetAccountList() anope_abstract;
+
+ virtual Nick *CreateNick(const Anope::string &nick, Account *acc) anope_abstract;
+ virtual Account *CreateAccount(const Anope::string &acc) anope_abstract;
+
+ virtual Nick *FindNick(const Anope::string &nick) anope_abstract;
+ virtual Account *FindAccount(const Anope::string &acc) anope_abstract;
};
static ServiceReference<NickServService> service("NickServService", "NickServ");
+ inline Nick *FindNick(const Anope::string &nick)
+ {
+ return service ? service->FindNick(nick) : nullptr;
+ }
+
+ inline Account *FindAccount(const Anope::string &account)
+ {
+ return service ? service->FindAccount(account) : nullptr;
+ }
+
namespace Event
{
struct CoreExport PreNickExpire : Events
@@ -30,7 +64,7 @@ namespace NickServ
* @param na The nick
* @param expire Set to true to allow the nick to expire
*/
- virtual void OnPreNickExpire(NickAlias *na, bool &expire) anope_abstract;
+ virtual void OnPreNickExpire(Nick *na, bool &expire) anope_abstract;
};
static EventHandlersReference<PreNickExpire> OnPreNickExpire("OnPreNickExpire");
@@ -39,7 +73,7 @@ namespace NickServ
/** Called when a nick drops
* @param na The nick
*/
- virtual void OnNickExpire(NickAlias *na) anope_abstract;
+ virtual void OnNickExpire(Nick *na) anope_abstract;
};
static EventHandlersReference<NickExpire> OnNickExpire("OnNickExpire");
@@ -49,7 +83,7 @@ namespace NickServ
* @param user The user registering the nick, of any
* @param The nick
*/
- virtual void OnNickRegister(User *user, NickAlias *na) anope_abstract;
+ virtual void OnNickRegister(User *user, Nick *na) anope_abstract;
};
static EventHandlersReference<NickRegister> OnNickRegister("OnNickRegister");
@@ -61,8 +95,250 @@ namespace NickServ
* @param na The nick they are on
* @return EVENT_STOP to force the user off of the nick
*/
- virtual EventReturn OnNickValidate(User *u, NickAlias *na) anope_abstract;
+ virtual EventReturn OnNickValidate(User *u, Nick *na) anope_abstract;
};
static EventHandlersReference<NickValidate> OnNickValidate("OnNickValidate");
}
+
+ /* A registered nickname.
+ * It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Nick : public Serializable, public Extensible
+ {
+ protected:
+ Anope::string vhost_ident, vhost_host, vhost_creator;
+ time_t vhost_created;
+
+ public:
+ 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<Account> nc;
+
+ protected:
+ Nick() : Serializable("NickAlias") { }
+
+ public:
+ virtual ~Nick() { }
+
+ /** Set a vhost for the user
+ * @param ident The ident
+ * @param host The host
+ * @param creator Who created the vhost
+ * @param time When the vhost was craated
+ */
+ virtual void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime) anope_abstract;
+
+ /** Remove a users vhost
+ **/
+ virtual void RemoveVhost() anope_abstract;
+
+ /** Check if the user has a vhost
+ * @return true or false
+ */
+ virtual bool HasVhost() const anope_abstract;
+
+ /** Retrieve the vhost ident
+ * @return the ident
+ */
+ virtual const Anope::string &GetVhostIdent() const anope_abstract;
+
+ /** Retrieve the vhost host
+ * @return the host
+ */
+ virtual const Anope::string &GetVhostHost() const anope_abstract;
+
+ /** Retrieve the vhost creator
+ * @return the creator
+ */
+ virtual const Anope::string &GetVhostCreator() const anope_abstract;
+
+ /** Retrieve when the vhost was created
+ * @return the time it was created
+ */
+ virtual time_t GetVhostCreated() const anope_abstract;
+ };
+
+ /* A registered account. Each account must have a Nick with the same nick as the
+ * account's display.
+ * It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Account : public Serializable, public Extensible
+ {
+ protected:
+ /* Channels which reference this core in some way (this is on their access list, akick list, is founder, successor, etc) */
+ Serialize::Checker<std::map<ChanServ::Channel *, int> > chanaccess;
+ public:
+ /* Name of the account. Find(display)->nc == this. */
+ Anope::string display;
+ /* User password in form of hashm:data */
+ Anope::string pass;
+ Anope::string email;
+ /* 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;
+ MemoServ::MemoInfo *memos = nullptr;
+ std::map<Anope::string, Anope::string> last_modes;
+
+ /* Nicknames registered that are grouped to this account.
+ * for n in aliases, n->nc == this.
+ */
+ Serialize::Checker<std::vector<Nick *> > aliases;
+
+ /* Set if this user is a services operattor. o->ot must exist. */
+ Oper *o;
+
+ /* Unsaved 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;
+
+ protected:
+ /** Constructor
+ * @param display The display nick
+ */
+ Account() : Serializable("NickCore"), chanaccess("ChannelInfo"), aliases("NickAlias") { }
+
+ public:
+ virtual ~Account() { }
+
+ /** Changes the display for this account
+ * @param na The new display, must be grouped to this account.
+ */
+ virtual void SetDisplay(const Nick *na) anope_abstract;
+
+ /** Checks whether this account is a services oper or not.
+ * @return True if this account is a services oper, false otherwise.
+ */
+ virtual bool IsServicesOper() const anope_abstract;
+
+ /** Add an entry to the nick's access list
+ *
+ * @param entry The nick!ident@host entry to add to the access list
+ *
+ * Adds a new entry into the access list.
+ */
+ virtual void AddAccess(const Anope::string &entry) anope_abstract;
+
+ /** Get an entry from the nick's access list by index
+ *
+ * @param entry Index in the access list vector to retrieve
+ * @return The access list entry of the given index if within bounds, an empty string if the vector is empty or the index is out of bounds
+ *
+ * Retrieves an entry from the access list corresponding to the given index.
+ */
+ virtual Anope::string GetAccess(unsigned entry) const anope_abstract;
+
+ /** Get the number of entries on the access list for this account.
+ */
+ virtual unsigned GetAccessCount() const anope_abstract;
+
+ /** Find an entry in the nick's access list
+ *
+ * @param entry The nick!ident@host entry to search for
+ * @return True if the entry is found in the access list, false otherwise
+ *
+ * Search for an entry within the access list.
+ */
+ virtual bool FindAccess(const Anope::string &entry) anope_abstract;
+
+ /** Erase an entry from the nick's access list
+ *
+ * @param entry The nick!ident@host entry to remove
+ *
+ * Removes the specified access list entry from the access list.
+ */
+ virtual void EraseAccess(const Anope::string &entry) anope_abstract;
+
+ /** Clears the entire nick's access list
+ *
+ * Deletes all the memory allocated in the access list vector and then clears the vector.
+ */
+ virtual void ClearAccess() anope_abstract;
+
+ /** Is the given user on this accounts access list?
+ *
+ * @param u The user
+ *
+ * @return true if the user is on the access list
+ */
+ virtual bool IsOnAccess(const User *u) const anope_abstract;
+
+ virtual void AddChannelReference(ChanServ::Channel *ci) anope_abstract;
+ virtual void RemoveChannelReference(ChanServ::Channel *ci) anope_abstract;
+ virtual void GetChannelReferences(std::deque<ChanServ::Channel *> &queue) anope_abstract;
+ };
+
+ /* A request to check if an account/password is valid. These can exist for
+ * extended periods due to the time some authentication modules take.
+ */
+ class CoreExport IdentifyRequest
+ {
+ protected:
+ /* Owner of this request, used to cleanup requests if a module is unloaded
+ * while a request us pending */
+ Module *owner;
+ IdentifyRequestListener *l;
+ Anope::string account;
+ Anope::string password;
+
+ std::set<Module *> holds;
+ bool dispatched = false;
+ bool success = false;
+
+ IdentifyRequest(IdentifyRequestListener *li, Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), l(li), account(acc), password(pass) { }
+ public:
+ virtual ~IdentifyRequest() { }
+
+ const Anope::string &GetAccount() const { return account; }
+ const Anope::string &GetPassword() const { return password; }
+ Module *GetOwner() const { return owner; }
+
+ /* 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
+ */
+ virtual void Hold(Module *m) anope_abstract;
+
+ /** Releases a held request
+ * @param m The module releaseing the hold
+ */
+ virtual void Release(Module *m) anope_abstract;
+
+ /** 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
+ */
+ virtual void Success(Module *m) anope_abstract;
+
+ /** Used to either finalize this request or marks
+ * it as dispatched and begins waiting for the module(s)
+ * that have holds to finish.
+ */
+ virtual void Dispatch() anope_abstract;
+ };
+
+ class IdentifyRequestListener
+ {
+ public:
+ virtual ~IdentifyRequestListener() { }
+ virtual void OnSuccess(IdentifyRequest *) anope_abstract;
+ virtual void OnFail(IdentifyRequest *) anope_abstract;
+ };
}
diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h
index b0614b2e6..f464d7fde 100644
--- a/include/modules/ns_cert.h
+++ b/include/modules/ns_cert.h
@@ -66,7 +66,7 @@ class CertService : public Service
public:
CertService(Module *c) : Service(c, "CertService", "certs") { }
- virtual NickCore* FindAccountFromCert(const Anope::string &cert) = 0;
+ virtual NickServ::Account* FindAccountFromCert(const Anope::string &cert) = 0;
};
namespace Event
@@ -77,18 +77,18 @@ namespace Event
* @param nc The nick
* @param entry The entry
*/
- virtual void OnNickAddCert(NickCore *nc, const Anope::string &entry) anope_abstract;
+ virtual void OnNickAddCert(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
- /** Called from NickCore::EraseCert()
- * @param nc pointer to the NickCore
+ /** Called from NickServ::Account::EraseCert()
+ * @param nc pointer to the NickServ::Account
* @param entry The fingerprint
*/
- virtual void OnNickEraseCert(NickCore *nc, const Anope::string &entry) anope_abstract;
+ virtual void OnNickEraseCert(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
- /** called from NickCore::ClearCert()
- * @param nc pointer to the NickCore
+ /** called from NickServ::Account::ClearCert()
+ * @param nc pointer to the NickServ::Account
*/
- virtual void OnNickClearCert(NickCore *nc) anope_abstract;
+ virtual void OnNickClearCert(NickServ::Account *nc) anope_abstract;
};
}
diff --git a/include/modules/ns_drop.h b/include/modules/ns_drop.h
index 2aef2b965..9217a924c 100644
--- a/include/modules/ns_drop.h
+++ b/include/modules/ns_drop.h
@@ -14,7 +14,7 @@ namespace Event
* @param source The source of the command
* @param na The nick
*/
- virtual void OnNickDrop(CommandSource &source, NickAlias *na) anope_abstract;
+ virtual void OnNickDrop(CommandSource &source, NickServ::Nick *na) anope_abstract;
};
extern CoreExport EventHandlers<NickDrop> OnNickDrop;
}
diff --git a/include/modules/ns_group.h b/include/modules/ns_group.h
index 8b3fa49f9..a254c4412 100644
--- a/include/modules/ns_group.h
+++ b/include/modules/ns_group.h
@@ -15,6 +15,6 @@ namespace Event
* @param u The user grouping
* @param target The target they're grouping to
*/
- virtual void OnNickGroup(User *u, NickAlias *target) anope_abstract;
+ virtual void OnNickGroup(User *u, NickServ::Nick *target) anope_abstract;
};
}
diff --git a/include/modules/ns_info.h b/include/modules/ns_info.h
index 8fae2b536..dd593ce59 100644
--- a/include/modules/ns_info.h
+++ b/include/modules/ns_info.h
@@ -17,6 +17,6 @@ namespace Event
* @param info Data to show the user requesting information
* @param show_hidden true if we should show the user everything
*/
- virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_abstract;
+ virtual void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) anope_abstract;
};
}
diff --git a/include/modules/ns_set.h b/include/modules/ns_set.h
index a45fa0b5e..b958b4cf5 100644
--- a/include/modules/ns_set.h
+++ b/include/modules/ns_set.h
@@ -18,7 +18,7 @@ namespace Event
* @param setting The setting passed to the command. Probably ON/OFF.
* @return EVENT_STOP to halt immediately
*/
- virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickCore *nc, const Anope::string &setting) anope_abstract;
+ virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickServ::Account *nc, const Anope::string &setting) anope_abstract;
};
static EventHandlersReference<SetNickOption> OnSetNickOption("OnSetNickOption");
}
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
index 2511d47b2..598122663 100644
--- a/include/modules/os_ignore.h
+++ b/include/modules/os_ignore.h
@@ -26,7 +26,7 @@ class IgnoreService : public Service
{
protected:
IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { }
-
+
public:
virtual void AddIgnore(IgnoreData *) = 0;
diff --git a/include/modules/os_news.h b/include/modules/os_news.h
index 458a5a82b..b076f62af 100644
--- a/include/modules/os_news.h
+++ b/include/modules/os_news.h
@@ -31,11 +31,11 @@ class NewsService : public Service
NewsService(Module *m) : Service(m, "NewsService", "news") { }
virtual NewsItem *CreateNewsItem() = 0;
-
+
virtual void AddNewsItem(NewsItem *n) = 0;
-
+
virtual void DelNewsItem(NewsItem *n) = 0;
-
+
virtual std::vector<NewsItem *> &GetNewsList(NewsType t) = 0;
};
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index 91548a5c2..1c1966e06 100644
--- a/include/modules/os_session.h
+++ b/include/modules/os_session.h
@@ -40,7 +40,7 @@ class SessionService : public Service
virtual Exception *FindException(User *u) = 0;
- virtual Exception *FindException(const Anope::string &host) = 0;
+ virtual Exception *FindException(const Anope::string &host) = 0;
virtual ExceptionVector &GetExceptions() = 0;
diff --git a/include/modules/redis.h b/include/modules/redis.h
index 941691a72..ae444e782 100644
--- a/include/modules/redis.h
+++ b/include/modules/redis.h
@@ -24,7 +24,7 @@ namespace Redis
Reply() { Clear(); }
~Reply() { Clear(); }
-
+
void Clear()
{
type = NOT_PARSED;
diff --git a/include/modules/sasl.h b/include/modules/sasl.h
index dbe6441e9..28bdb1ca6 100644
--- a/include/modules/sasl.h
+++ b/include/modules/sasl.h
@@ -33,7 +33,7 @@ namespace SASL
virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0;
- virtual void Succeed(Session *, NickCore *) = 0;
+ virtual void Succeed(Session *, NickServ::Account *) = 0;
virtual void Fail(Session *) = 0;
virtual void SendMechs(Session *) = 0;
virtual void DeleteSessions(Mechanism *, bool = false) = 0;
@@ -73,32 +73,32 @@ namespace SASL
}
};
- class IdentifyRequest : public ::IdentifyRequest
+ class IdentifyRequestListener : public NickServ::IdentifyRequestListener
{
Anope::string uid;
public:
- IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass) : ::IdentifyRequest(m, acc, pass), uid(id) { }
+ IdentifyRequestListener(const Anope::string &id) : uid(id) { }
- void OnSuccess() override
+ void OnSuccess(NickServ::IdentifyRequest *req) override
{
if (!sasl)
return;
- NickAlias *na = NickAlias::Find(GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (!na || na->nc->HasExt("NS_SUSPENDED"))
- return OnFail();
+ return OnFail(req);
Session *s = sasl->GetSession(uid);
if (s)
{
- Log(Config->GetClient("NickServ")) << "A user identified to account " << this->GetAccount() << " using SASL";
+ Log(Config->GetClient("NickServ")) << "A user identified to account " << req->GetAccount() << " using SASL";
sasl->Succeed(s, na->nc);
delete s;
}
}
- void OnFail() override
+ void OnFail(NickServ::IdentifyRequest *req) override
{
if (!sasl)
return;
@@ -111,13 +111,13 @@ namespace SASL
}
Anope::string accountstatus;
- NickAlias *na = NickAlias::Find(GetAccount());
+ NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (!na)
accountstatus = "nonexistent ";
else if (na->nc->HasExt("NS_SUSPENDED"))
accountstatus = "suspended ";
- Log(Config->GetClient("NickServ")) << "A user failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL";
+ Log(Config->GetClient("NickServ")) << "A user failed to identify for " << accountstatus << "account " << req->GetAccount() << " using SASL";
}
};
}
diff --git a/include/modules/ssl.h b/include/modules/ssl.h
index 6eb97582c..fab3c35cc 100644
--- a/include/modules/ssl.h
+++ b/include/modules/ssl.h
@@ -3,7 +3,7 @@ class SSLService : public Service
{
public:
SSLService(Module *o, const Anope::string &n) : Service(o, "SSLService", n) { }
-
+
virtual void Init(Socket *s) = 0;
};
diff --git a/include/modules/suspend.h b/include/modules/suspend.h
index bd4eacd3b..3f5a8ded3 100644
--- a/include/modules/suspend.h
+++ b/include/modules/suspend.h
@@ -22,14 +22,14 @@ namespace Event
/** Called when a channel is suspended
* @param ci The channel
*/
- virtual void OnChanSuspend(ChannelInfo *ci) anope_abstract;
+ virtual void OnChanSuspend(ChanServ::Channel *ci) anope_abstract;
};
struct CoreExport ChanUnsuspend : Events
{
/** Called when a channel is unsuspended
* @param ci The channel
*/
- virtual void OnChanUnsuspend(ChannelInfo *ci) anope_abstract;
+ virtual void OnChanUnsuspend(ChanServ::Channel *ci) anope_abstract;
};
extern CoreExport EventHandlers<ChanUnsuspend> OnChanUnsuspend;
@@ -38,7 +38,7 @@ namespace Event
/** Called when a nick is suspended
* @param na The nick alias
*/
- virtual void OnNickSuspend(NickAlias *na) anope_abstract;
+ virtual void OnNickSuspend(NickServ::Nick *na) anope_abstract;
};
struct CoreExport NickUnsuspended : Events
@@ -46,7 +46,7 @@ namespace Event
/** Called when a nick is unsuspneded
* @param na The nick alias
*/
- virtual void OnNickUnsuspended(NickAlias *na) anope_abstract;
+ virtual void OnNickUnsuspended(NickServ::Nick *na) anope_abstract;
};
}
diff --git a/include/modules/xmlrpc.h b/include/modules/xmlrpc.h
index d5a5ea4a7..55962db24 100644
--- a/include/modules/xmlrpc.h
+++ b/include/modules/xmlrpc.h
@@ -9,7 +9,7 @@ class XMLRPCRequest
Anope::string id;
std::deque<Anope::string> data;
HTTPReply& r;
-
+
XMLRPCRequest(HTTPReply &_r) : r(_r) { }
inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }