From df0cd3ef3e9a5cd1230aebdb45569f54512373ad Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 8 Mar 2025 12:22:07 +0000 Subject: Move some headers around. --- include/modules/botserv/badwords.h | 72 ++++++++++++ include/modules/botserv/kick.h | 46 ++++++++ include/modules/bs_badwords.h | 72 ------------ include/modules/bs_kick.h | 46 -------- include/modules/chanserv/entrymsg.h | 37 ++++++ include/modules/chanserv/log.h | 45 ++++++++ include/modules/chanserv/mode.h | 91 +++++++++++++++ include/modules/chanserv/service.h | 23 ++++ include/modules/cs_entrymsg.h | 37 ------ include/modules/cs_log.h | 45 -------- include/modules/cs_mode.h | 91 --------------- include/modules/global/service.h | 75 ++++++++++++ include/modules/hostserv/request.h | 23 ++++ include/modules/hs_request.h | 23 ---- include/modules/memoserv/service.h | 39 +++++++ include/modules/nickserv/cert.h | 83 ++++++++++++++ include/modules/nickserv/sasl.h | 188 +++++++++++++++++++++++++++++++ include/modules/nickserv/service.h | 23 ++++ include/modules/ns_cert.h | 83 -------------- include/modules/operserv/forbid.h | 53 +++++++++ include/modules/operserv/ignore.h | 46 ++++++++ include/modules/operserv/news.h | 51 +++++++++ include/modules/operserv/oper.h | 46 ++++++++ include/modules/operserv/session.h | 93 +++++++++++++++ include/modules/os_forbid.h | 53 --------- include/modules/os_ignore.h | 46 -------- include/modules/os_news.h | 51 --------- include/modules/os_oper.h | 46 -------- include/modules/os_session.h | 93 --------------- include/modules/pseudoclients/chanserv.h | 23 ---- include/modules/pseudoclients/global.h | 75 ------------ include/modules/pseudoclients/memoserv.h | 39 ------- include/modules/pseudoclients/nickserv.h | 23 ---- include/modules/sasl.h | 188 ------------------------------- 34 files changed, 1034 insertions(+), 1034 deletions(-) create mode 100644 include/modules/botserv/badwords.h create mode 100644 include/modules/botserv/kick.h delete mode 100644 include/modules/bs_badwords.h delete mode 100644 include/modules/bs_kick.h create mode 100644 include/modules/chanserv/entrymsg.h create mode 100644 include/modules/chanserv/log.h create mode 100644 include/modules/chanserv/mode.h create mode 100644 include/modules/chanserv/service.h delete mode 100644 include/modules/cs_entrymsg.h delete mode 100644 include/modules/cs_log.h delete mode 100644 include/modules/cs_mode.h create mode 100644 include/modules/global/service.h create mode 100644 include/modules/hostserv/request.h delete mode 100644 include/modules/hs_request.h create mode 100644 include/modules/memoserv/service.h create mode 100644 include/modules/nickserv/cert.h create mode 100644 include/modules/nickserv/sasl.h create mode 100644 include/modules/nickserv/service.h delete mode 100644 include/modules/ns_cert.h create mode 100644 include/modules/operserv/forbid.h create mode 100644 include/modules/operserv/ignore.h create mode 100644 include/modules/operserv/news.h create mode 100644 include/modules/operserv/oper.h create mode 100644 include/modules/operserv/session.h delete mode 100644 include/modules/os_forbid.h delete mode 100644 include/modules/os_ignore.h delete mode 100644 include/modules/os_news.h delete mode 100644 include/modules/os_oper.h delete mode 100644 include/modules/os_session.h delete mode 100644 include/modules/pseudoclients/chanserv.h delete mode 100644 include/modules/pseudoclients/global.h delete mode 100644 include/modules/pseudoclients/memoserv.h delete mode 100644 include/modules/pseudoclients/nickserv.h delete mode 100644 include/modules/sasl.h (limited to 'include/modules') diff --git a/include/modules/botserv/badwords.h b/include/modules/botserv/badwords.h new file mode 100644 index 000000000..ae78df8b1 --- /dev/null +++ b/include/modules/botserv/badwords.h @@ -0,0 +1,72 @@ +/* BotServ core functions + * + * (C) 2003-2025 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. + */ + +#pragma once + +/** Flags for badwords + */ +enum BadWordType +{ + /* Always kicks if the word is said */ + BW_ANY, + /* User must way the entire word */ + BW_SINGLE, + /* The word has to start with the badword */ + BW_START, + /* The word has to end with the badword */ + BW_END +}; + +/* Structure used to contain bad words. */ +struct BadWord +{ + Anope::string chan; + Anope::string word; + BadWordType type; + + virtual ~BadWord() = default; +protected: + BadWord() = default; +}; + +struct BadWords +{ + virtual ~BadWords() = default; + + /** Add a badword to the badword list + * @param word The badword + * @param type The type (SINGLE START END) + * @return The badword + */ + virtual BadWord *AddBadWord(const Anope::string &word, BadWordType type) = 0; + + /** Get a badword structure by index + * @param index The index + * @return The badword + */ + virtual BadWord *GetBadWord(unsigned index) const = 0; + + /** Get how many badwords are on this channel + * @return The number of badwords in the vector + */ + virtual unsigned GetBadWordCount() const = 0; + + /** Remove a badword + * @param index The index of the badword + */ + virtual void EraseBadWord(unsigned index) = 0; + + /** Clear all badwords from the channel + */ + virtual void ClearBadWords() = 0; + + virtual void Check() = 0; +}; diff --git a/include/modules/botserv/kick.h b/include/modules/botserv/kick.h new file mode 100644 index 000000000..8ad44aab5 --- /dev/null +++ b/include/modules/botserv/kick.h @@ -0,0 +1,46 @@ +/* BotServ core functions + * + * (C) 2003-2025 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. + */ + +#pragma once + +/* 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 +}; + +struct KickerData +{ + bool amsgs, badwords, bolds, caps, colors, flood, italics, repeat, reverses, underlines; + 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 */ + + bool dontkickops, dontkickvoices; + +protected: + KickerData() = default; + +public: + virtual ~KickerData() = default; + virtual void Check(ChannelInfo *ci) = 0; +}; diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h deleted file mode 100644 index ae78df8b1..000000000 --- a/include/modules/bs_badwords.h +++ /dev/null @@ -1,72 +0,0 @@ -/* BotServ core functions - * - * (C) 2003-2025 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. - */ - -#pragma once - -/** Flags for badwords - */ -enum BadWordType -{ - /* Always kicks if the word is said */ - BW_ANY, - /* User must way the entire word */ - BW_SINGLE, - /* The word has to start with the badword */ - BW_START, - /* The word has to end with the badword */ - BW_END -}; - -/* Structure used to contain bad words. */ -struct BadWord -{ - Anope::string chan; - Anope::string word; - BadWordType type; - - virtual ~BadWord() = default; -protected: - BadWord() = default; -}; - -struct BadWords -{ - virtual ~BadWords() = default; - - /** Add a badword to the badword list - * @param word The badword - * @param type The type (SINGLE START END) - * @return The badword - */ - virtual BadWord *AddBadWord(const Anope::string &word, BadWordType type) = 0; - - /** Get a badword structure by index - * @param index The index - * @return The badword - */ - virtual BadWord *GetBadWord(unsigned index) const = 0; - - /** Get how many badwords are on this channel - * @return The number of badwords in the vector - */ - virtual unsigned GetBadWordCount() const = 0; - - /** Remove a badword - * @param index The index of the badword - */ - virtual void EraseBadWord(unsigned index) = 0; - - /** Clear all badwords from the channel - */ - virtual void ClearBadWords() = 0; - - virtual void Check() = 0; -}; diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h deleted file mode 100644 index 8ad44aab5..000000000 --- a/include/modules/bs_kick.h +++ /dev/null @@ -1,46 +0,0 @@ -/* BotServ core functions - * - * (C) 2003-2025 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. - */ - -#pragma once - -/* 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 -}; - -struct KickerData -{ - bool amsgs, badwords, bolds, caps, colors, flood, italics, repeat, reverses, underlines; - 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 */ - - bool dontkickops, dontkickvoices; - -protected: - KickerData() = default; - -public: - virtual ~KickerData() = default; - virtual void Check(ChannelInfo *ci) = 0; -}; diff --git a/include/modules/chanserv/entrymsg.h b/include/modules/chanserv/entrymsg.h new file mode 100644 index 000000000..2672f8ac0 --- /dev/null +++ b/include/modules/chanserv/entrymsg.h @@ -0,0 +1,37 @@ +/* + * + * (C) 2003-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +struct EntryMsg +{ + Anope::string chan; + Anope::string creator; + Anope::string message; + time_t when; + + virtual ~EntryMsg() = default; +protected: + EntryMsg() = default; +}; + +struct EntryMessageList + : Serialize::Checker > +{ +protected: + EntryMessageList() : Serialize::Checker >("EntryMsg") { } + +public: + virtual ~EntryMessageList() + { + for (unsigned i = (*this)->size(); i > 0; --i) + delete (*this)->at(i - 1); + } + + virtual EntryMsg *Create() = 0; +}; diff --git a/include/modules/chanserv/log.h b/include/modules/chanserv/log.h new file mode 100644 index 000000000..f9549126b --- /dev/null +++ b/include/modules/chanserv/log.h @@ -0,0 +1,45 @@ +/* ChanServ core functions + * + * (C) 2003-2025 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. + */ + +#pragma once + +struct LogSetting +{ + Anope::string chan; + /* Our service name of the command */ + Anope::string service_name; + /* The name of the client the command is on */ + Anope::string command_service; + /* Name of the command to the user, can have spaces */ + Anope::string command_name; + Anope::string method, extra; + Anope::string creator; + time_t created; + + virtual ~LogSetting() = default; +protected: + LogSetting() = default; +}; + +struct LogSettings + : Serialize::Checker > +{ + typedef std::vector::iterator iterator; + +protected: + LogSettings() : Serialize::Checker >("LogSetting") + { + } + +public: + virtual ~LogSettings() = default; + virtual LogSetting *Create() = 0; +}; diff --git a/include/modules/chanserv/mode.h b/include/modules/chanserv/mode.h new file mode 100644 index 000000000..f3668c004 --- /dev/null +++ b/include/modules/chanserv/mode.h @@ -0,0 +1,91 @@ +/* ChanServ core functions + * + * (C) 2003-2025 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. + */ + +#pragma once + +struct ModeLock +{ + Anope::string ci; + bool set; + Anope::string name; + Anope::string param; + Anope::string setter; + time_t created; + + virtual ~ModeLock() = default; +protected: + ModeLock() = default; +}; + +struct ModeLocks +{ + typedef std::vector ModeList; + + virtual ~ModeLocks() = default; + + /** Check if a mode is mlocked + * @param mode The mode + * @param An optional param + * @param status True to check mlock on, false for mlock off + * @return true on success, false on fail + */ + virtual bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const = 0; + + /** Set a mlock + * @param mode The mode + * @param status True for mlock on, false for mlock off + * @param param An optional param arg for + mlocked modes + * @param setter Who is setting the mlock + * @param created When the mlock was created + * @return true on success, false on failure (module blocking) + */ + virtual bool SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "", Anope::string setter = "", time_t created = Anope::CurTime) = 0; + + /** Remove a mlock + * @param mode The mode + * @param status True for mlock on, false for mlock off + * @param param The param of the mode, required if it is a list or status mode + * @return true on success, false on failure + */ + virtual bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "") = 0; + + virtual void RemoveMLock(ModeLock *mlock) = 0; + + /** Clear all mlocks on the channel + */ + virtual void ClearMLock() = 0; + + /** Get all of the mlocks for this channel + * @return The mlocks + */ + virtual const ModeList &GetMLock() const = 0; + + /** Get a list of mode locks on a channel + * @param name The mode name to get a list of + * @return a list of mlocks for the given mode + */ + virtual std::list GetModeLockList(const Anope::string &name) = 0; + + /** Get details for a specific mlock + * @param mname The mode name + * @param An optional param to match with + * @return The MLock, if any + */ + virtual const ModeLock *GetMLock(const Anope::string &mname, const Anope::string ¶m = "") = 0; + + /** Get the current mode locks as a string + * @param complete True to show mlock parameters as well + * @return A string of mode locks, eg: +nrt + */ + virtual Anope::string GetMLockAsString(bool complete) const = 0; + + virtual void Check() = 0; +}; diff --git a/include/modules/chanserv/service.h b/include/modules/chanserv/service.h new file mode 100644 index 000000000..5bef94340 --- /dev/null +++ b/include/modules/chanserv/service.h @@ -0,0 +1,23 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +class ChanServService + : public Service +{ +public: + ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") + { + } + + /* 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) = 0; +}; diff --git a/include/modules/cs_entrymsg.h b/include/modules/cs_entrymsg.h deleted file mode 100644 index 2672f8ac0..000000000 --- a/include/modules/cs_entrymsg.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * (C) 2003-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -struct EntryMsg -{ - Anope::string chan; - Anope::string creator; - Anope::string message; - time_t when; - - virtual ~EntryMsg() = default; -protected: - EntryMsg() = default; -}; - -struct EntryMessageList - : Serialize::Checker > -{ -protected: - EntryMessageList() : Serialize::Checker >("EntryMsg") { } - -public: - virtual ~EntryMessageList() - { - for (unsigned i = (*this)->size(); i > 0; --i) - delete (*this)->at(i - 1); - } - - virtual EntryMsg *Create() = 0; -}; diff --git a/include/modules/cs_log.h b/include/modules/cs_log.h deleted file mode 100644 index f9549126b..000000000 --- a/include/modules/cs_log.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2025 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. - */ - -#pragma once - -struct LogSetting -{ - Anope::string chan; - /* Our service name of the command */ - Anope::string service_name; - /* The name of the client the command is on */ - Anope::string command_service; - /* Name of the command to the user, can have spaces */ - Anope::string command_name; - Anope::string method, extra; - Anope::string creator; - time_t created; - - virtual ~LogSetting() = default; -protected: - LogSetting() = default; -}; - -struct LogSettings - : Serialize::Checker > -{ - typedef std::vector::iterator iterator; - -protected: - LogSettings() : Serialize::Checker >("LogSetting") - { - } - -public: - virtual ~LogSettings() = default; - virtual LogSetting *Create() = 0; -}; diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h deleted file mode 100644 index f3668c004..000000000 --- a/include/modules/cs_mode.h +++ /dev/null @@ -1,91 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2025 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. - */ - -#pragma once - -struct ModeLock -{ - Anope::string ci; - bool set; - Anope::string name; - Anope::string param; - Anope::string setter; - time_t created; - - virtual ~ModeLock() = default; -protected: - ModeLock() = default; -}; - -struct ModeLocks -{ - typedef std::vector ModeList; - - virtual ~ModeLocks() = default; - - /** Check if a mode is mlocked - * @param mode The mode - * @param An optional param - * @param status True to check mlock on, false for mlock off - * @return true on success, false on fail - */ - virtual bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const = 0; - - /** Set a mlock - * @param mode The mode - * @param status True for mlock on, false for mlock off - * @param param An optional param arg for + mlocked modes - * @param setter Who is setting the mlock - * @param created When the mlock was created - * @return true on success, false on failure (module blocking) - */ - virtual bool SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "", Anope::string setter = "", time_t created = Anope::CurTime) = 0; - - /** Remove a mlock - * @param mode The mode - * @param status True for mlock on, false for mlock off - * @param param The param of the mode, required if it is a list or status mode - * @return true on success, false on failure - */ - virtual bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "") = 0; - - virtual void RemoveMLock(ModeLock *mlock) = 0; - - /** Clear all mlocks on the channel - */ - virtual void ClearMLock() = 0; - - /** Get all of the mlocks for this channel - * @return The mlocks - */ - virtual const ModeList &GetMLock() const = 0; - - /** Get a list of mode locks on a channel - * @param name The mode name to get a list of - * @return a list of mlocks for the given mode - */ - virtual std::list GetModeLockList(const Anope::string &name) = 0; - - /** Get details for a specific mlock - * @param mname The mode name - * @param An optional param to match with - * @return The MLock, if any - */ - virtual const ModeLock *GetMLock(const Anope::string &mname, const Anope::string ¶m = "") = 0; - - /** Get the current mode locks as a string - * @param complete True to show mlock parameters as well - * @return A string of mode locks, eg: +nrt - */ - virtual Anope::string GetMLockAsString(bool complete) const = 0; - - virtual void Check() = 0; -}; diff --git a/include/modules/global/service.h b/include/modules/global/service.h new file mode 100644 index 000000000..01149d48e --- /dev/null +++ b/include/modules/global/service.h @@ -0,0 +1,75 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +#define GLOBAL_NO_MESSAGE _("You do not have any messages queued and did not specify a message to send.") +#define GLOBAL_QUEUE_CONFLICT _("You can not send a single message while you have messages queued.") + +class GlobalService + : public Service +{ +public: + GlobalService(Module *m) + : Service(m, "GlobalService", "Global") + { + } + + /** Retrieves the bot which sends global messages unless otherwise specified. */ + virtual Reference GetDefaultSender() const = 0; + + /** Clears any queued messages for the specified account. + * @param nc The account to clear queued messages for. + */ + virtual void ClearQueue(NickCore *nc) = 0; + + /** Retrieves the size of the messages queue for the specified user. + * @param nc The account to count queued messages for. + */ + inline size_t CountQueue(NickCore* nc) const + { + auto *q = GetQueue(nc); + return q ? q->size() : 0; + } + + /** Retrieves the messages queue for the specified user. + * @param nc The account to retrieve queued messages for. + */ + virtual const std::vector *GetQueue(NickCore* nc) const = 0; + + /** Queues a message to be sent later. + * @param nc The account to queue the message for. + * @param message The message to queue. + * @return The new number of messages in the queue. + */ + virtual size_t Queue(NickCore *nc, const Anope::string &message) = 0; + + /** Sends a single message to all users on the network. + * @param message The message to send. + * @param source If non-nullptr then the source of the message. + * @param sender If non-nullptr then the bot to send the message from. + * @param server If non-nullptr then the server to send messages to. + * @return If the message was sent then true; otherwise, false. + */ + virtual bool SendSingle(const Anope::string &message, CommandSource *source = nullptr, BotInfo *sender = nullptr, Server *server = nullptr) = 0; + + /** Sends a message queue to all users on the network. + * @param source The source of the message. + * @param sender If non-nullptr then the bot to send the message from. + * @param server If non-nullptr then the server to send messages to. + * @return If the message queue was sent then true; otherwise, false. + */ + virtual bool SendQueue(CommandSource &source, BotInfo *sender = nullptr, Server *server = nullptr) = 0; + + /** Unqueues a message from the message queue. + * @param nc The account to unqueue the message from. + * @param idx The index of the item to remove. + * @return Whether the message was removed from the queue. + */ + virtual bool Unqueue(NickCore *nc, size_t idx) = 0; +}; diff --git a/include/modules/hostserv/request.h b/include/modules/hostserv/request.h new file mode 100644 index 000000000..a1805a298 --- /dev/null +++ b/include/modules/hostserv/request.h @@ -0,0 +1,23 @@ +/* + * + * (C) 2003-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +class HostRequest +{ +protected: + HostRequest() = default; + +public: + Anope::string nick; + Anope::string ident; + Anope::string host; + time_t time = 0; + + virtual ~HostRequest() = default; +}; diff --git a/include/modules/hs_request.h b/include/modules/hs_request.h deleted file mode 100644 index a1805a298..000000000 --- a/include/modules/hs_request.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * (C) 2003-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -class HostRequest -{ -protected: - HostRequest() = default; - -public: - Anope::string nick; - Anope::string ident; - Anope::string host; - time_t time = 0; - - virtual ~HostRequest() = default; -}; diff --git a/include/modules/memoserv/service.h b/include/modules/memoserv/service.h new file mode 100644 index 000000000..c1ff4af7d --- /dev/null +++ b/include/modules/memoserv/service.h @@ -0,0 +1,39 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +class MemoServService + : public Service +{ +public: + enum MemoResult + { + MEMO_SUCCESS, + MEMO_INVALID_TARGET, + 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 anything. + * @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; + + /** Check for new memos and notify the user if there are any + * @param u The user + */ + virtual void Check(User *u) = 0; +}; diff --git a/include/modules/nickserv/cert.h b/include/modules/nickserv/cert.h new file mode 100644 index 000000000..9462d66a0 --- /dev/null +++ b/include/modules/nickserv/cert.h @@ -0,0 +1,83 @@ +/* NickServ core functions + * + * (C) 2003-2025 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. + */ + +#pragma once + +struct NSCertList +{ +protected: + NSCertList() = default; +public: + virtual ~NSCertList() = default; + + /** Add an entry to the nick's certificate list + * + * @param entry The fingerprint to add to the cert list + * + * Adds a new entry into the cert list. + */ + virtual void AddCert(const Anope::string &entry) = 0; + + /** Get an entry from the nick's cert list by index + * + * @param entry Index in the certificate list vector to retrieve + * @return The fingerprint 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 certificate list corresponding to the given index. + */ + virtual Anope::string GetCert(unsigned entry) const = 0; + + virtual unsigned GetCertCount() const = 0; + + /** Find an entry in the nick's cert list + * + * @param entry The fingerprint to search for + * @return True if the fingerprint is found in the cert list, false otherwise + * + * Search for an fingerprint within the cert list. + */ + virtual bool FindCert(const Anope::string &entry) const = 0; + + /** Erase a fingerprint from the nick's certificate list + * + * @param entry The fingerprint to remove + * + * Removes the specified fingerprint from the cert list. + */ + virtual void EraseCert(const Anope::string &entry) = 0; + + /** Replaces a fingerprint in the nick's certificate list + * + * @param oldentry The old fingerprint to remove + * @param newentry The new fingerprint to add + * + * Replaces the specified fingerprint in the cert list. + */ + virtual void ReplaceCert(const Anope::string &oldentry, const Anope::string &newentry) = 0; + + /** Clears the entire nick's cert list + * + * Deletes all the memory allocated in the certificate list vector and then clears the vector. + */ + virtual void ClearCert() = 0; + + virtual void Check() = 0; +}; + +class CertService + : public Service +{ +public: + CertService(Module *c) : Service(c, "CertService", "certs") { } + + virtual NickCore *FindAccountFromCert(const Anope::string &cert) = 0; + virtual void ReplaceCert(const Anope::string &oldcert, const Anope::string &newcert) = 0; +}; diff --git a/include/modules/nickserv/sasl.h b/include/modules/nickserv/sasl.h new file mode 100644 index 000000000..f23a5d32a --- /dev/null +++ b/include/modules/nickserv/sasl.h @@ -0,0 +1,188 @@ +/* + * + * (C) 2014-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +namespace SASL +{ + struct Message final + { + Anope::string source; + Anope::string target; + Anope::string type; + std::vector data; + }; + + class Mechanism; + struct Session; + + class Service + : public ::Service + { + public: + Service(Module *o) : ::Service(o, "SASL::Service", "sasl") { } + + virtual void ProcessMessage(const Message &) = 0; + + virtual Session *GetSession(const Anope::string &uid) = 0; + + virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0; + + virtual void Succeed(Session *, NickCore *) = 0; + virtual void Fail(Session *) = 0; + virtual void DeleteSessions(Mechanism *, bool = false) = 0; + virtual void RemoveSession(Session *) = 0; + }; + + static ServiceReference service("SASL::Service", "sasl"); + + struct Session + { + time_t created; + Anope::string uid; + Anope::string hostname, ip; + Reference mech; + + Session(Mechanism *m, const Anope::string &u) : created(Anope::CurTime), uid(u), mech(m) { } + + inline Anope::string GetUserInfo() + { + auto *u = User::Find(uid); + if (u) + return u->GetMask(); + if (!hostname.empty() && !ip.empty()) + return Anope::printf("%s (%s)", hostname.c_str(), ip.c_str()); + return "A user"; + }; + + virtual ~Session() + { + if (service) + service->RemoveSession(this); + } + }; + + /* PLAIN, EXTERNAL, etc */ + class Mechanism + : public ::Service + { + public: + Mechanism(Module *o, const Anope::string &sname) : Service(o, "SASL::Mechanism", sname) { } + + virtual Session *CreateSession(const Anope::string &uid) { return new Session(this, uid); } + + virtual bool ProcessMessage(Session *session, const Message &) = 0; + + virtual ~Mechanism() + { + if (service) + service->DeleteSessions(this, true); + } + }; + + class IdentifyRequest + : public ::IdentifyRequest + { + Anope::string uid; + Anope::string hostname; + + inline Anope::string GetUserInfo() + { + auto *u = User::Find(uid); + if (u) + return u->GetMask(); + if (!hostname.empty() && !GetAddress().empty()) + return Anope::printf("%s (%s)", hostname.c_str(), GetAddress().c_str()); + return "A user"; + }; + + public: + IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass, const Anope::string &h, const Anope::string &i) + : ::IdentifyRequest(m, acc, pass, i) + , uid(id) + , hostname(h) + { + } + + void OnSuccess() override + { + if (!service) + return; + + NickAlias *na = NickAlias::Find(GetAccount()); + if (!na || na->nc->HasExt("NS_SUSPENDED") || na->nc->HasExt("UNCONFIRMED")) + return OnFail(); + + unsigned int maxlogins = Config->GetModule("ns_identify").Get("maxlogins"); + if (maxlogins && na->nc->users.size() >= maxlogins) + return OnFail(); + + Session *s = service->GetSession(uid); + if (s) + { + Log(this->GetOwner(), "sasl", Config->GetClient("NickServ")) << GetUserInfo() << " identified to account " << this->GetAccount() << " using SASL"; + service->Succeed(s, na->nc); + delete s; + } + } + + void OnFail() override + { + if (!service) + return; + + Session *s = service->GetSession(uid); + if (s) + { + service->Fail(s); + delete s; + } + + Anope::string accountstatus; + NickAlias *na = NickAlias::Find(GetAccount()); + if (!na) + accountstatus = "nonexistent "; + else if (na->nc->HasExt("NS_SUSPENDED")) + accountstatus = "suspended "; + else if (na->nc->HasExt("UNCONFIRMED")) + accountstatus = "unconfirmed "; + + Log(this->GetOwner(), "sasl", Config->GetClient("NickServ")) << GetUserInfo() << " failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL"; + } + }; + + /** Sends IRCd messages used by the SASL module. */ + class ProtocolInterface + : public ::Service + { + protected: + ProtocolInterface(Module *o) + : ::Service(o, "SASL::ProtocolInterface", "sasl") + { + } + + public: + /** Sends the list of SASL mechanisms to the IRCd + * @param mechs The list of SASL mechanisms. + */ + virtual void SendSASLMechanisms(std::vector &mechs) { }; + + /** Sends a SASL message to the IRCd. + * @param message The SASL message to send. + */ + virtual void SendSASLMessage(const SASL::Message &message) = 0; + + /** Sends a login or logout for \p uid to \p na. + * @param uid The uid of the user to log in. + * @param na The nick alias to log the user in as or logout if nullptr. + */ + virtual void SendSVSLogin(const Anope::string &uid, NickAlias *na) = 0; + }; + + static ServiceReference protocol_interface("SASL::ProtocolInterface", "sasl"); +} diff --git a/include/modules/nickserv/service.h b/include/modules/nickserv/service.h new file mode 100644 index 000000000..2c659501e --- /dev/null +++ b/include/modules/nickserv/service.h @@ -0,0 +1,23 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +class NickServService + : public Service +{ +public: + NickServService(Module *m) : Service(m, "NickServService", "NickServ") + { + } + + virtual void Validate(User *u) = 0; + virtual void Collide(User *u, NickAlias *na) = 0; + virtual void Release(NickAlias *na) = 0; + virtual bool IsGuestNick(const Anope::string &nick) const = 0; +}; diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h deleted file mode 100644 index 9462d66a0..000000000 --- a/include/modules/ns_cert.h +++ /dev/null @@ -1,83 +0,0 @@ -/* NickServ core functions - * - * (C) 2003-2025 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. - */ - -#pragma once - -struct NSCertList -{ -protected: - NSCertList() = default; -public: - virtual ~NSCertList() = default; - - /** Add an entry to the nick's certificate list - * - * @param entry The fingerprint to add to the cert list - * - * Adds a new entry into the cert list. - */ - virtual void AddCert(const Anope::string &entry) = 0; - - /** Get an entry from the nick's cert list by index - * - * @param entry Index in the certificate list vector to retrieve - * @return The fingerprint 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 certificate list corresponding to the given index. - */ - virtual Anope::string GetCert(unsigned entry) const = 0; - - virtual unsigned GetCertCount() const = 0; - - /** Find an entry in the nick's cert list - * - * @param entry The fingerprint to search for - * @return True if the fingerprint is found in the cert list, false otherwise - * - * Search for an fingerprint within the cert list. - */ - virtual bool FindCert(const Anope::string &entry) const = 0; - - /** Erase a fingerprint from the nick's certificate list - * - * @param entry The fingerprint to remove - * - * Removes the specified fingerprint from the cert list. - */ - virtual void EraseCert(const Anope::string &entry) = 0; - - /** Replaces a fingerprint in the nick's certificate list - * - * @param oldentry The old fingerprint to remove - * @param newentry The new fingerprint to add - * - * Replaces the specified fingerprint in the cert list. - */ - virtual void ReplaceCert(const Anope::string &oldentry, const Anope::string &newentry) = 0; - - /** Clears the entire nick's cert list - * - * Deletes all the memory allocated in the certificate list vector and then clears the vector. - */ - virtual void ClearCert() = 0; - - virtual void Check() = 0; -}; - -class CertService - : public Service -{ -public: - CertService(Module *c) : Service(c, "CertService", "certs") { } - - virtual NickCore *FindAccountFromCert(const Anope::string &cert) = 0; - virtual void ReplaceCert(const Anope::string &oldcert, const Anope::string &newcert) = 0; -}; diff --git a/include/modules/operserv/forbid.h b/include/modules/operserv/forbid.h new file mode 100644 index 000000000..5c2f9d05c --- /dev/null +++ b/include/modules/operserv/forbid.h @@ -0,0 +1,53 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +enum ForbidType +{ + FT_NICK = 1, + FT_CHAN, + FT_EMAIL, + FT_REGISTER, + FT_SIZE +}; + +struct ForbidData +{ + Anope::string mask; + Anope::string creator; + Anope::string reason; + time_t created = 0; + time_t expires = 0; + ForbidType type; + + virtual ~ForbidData() = default; +protected: + ForbidData() = default; +}; + +class ForbidService + : public Service +{ +public: + ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { } + + virtual void AddForbid(ForbidData *d) = 0; + + virtual void RemoveForbid(ForbidData *d) = 0; + + virtual ForbidData *CreateForbid() = 0; + + virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0; + + virtual ForbidData *FindForbidExact(const Anope::string &mask, ForbidType type) = 0; + + virtual std::vector GetForbids() = 0; +}; + +static ServiceReference forbid_service("ForbidService", "forbid"); diff --git a/include/modules/operserv/ignore.h b/include/modules/operserv/ignore.h new file mode 100644 index 000000000..8a60a044f --- /dev/null +++ b/include/modules/operserv/ignore.h @@ -0,0 +1,46 @@ +/* OperServ ignore interface + * + * (C) 2003-2025 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. + */ + +#pragma once + +struct IgnoreData +{ + Anope::string mask; + Anope::string creator; + Anope::string reason; + time_t time = 0; /* When do we stop ignoring them? */ + + virtual ~IgnoreData() = default; +protected: + IgnoreData() = default; +}; + +class IgnoreService + : public Service +{ +protected: + IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { } + +public: + virtual void AddIgnore(IgnoreData *) = 0; + + virtual void DelIgnore(IgnoreData *) = 0; + + virtual void ClearIgnores() = 0; + + virtual IgnoreData *Create() = 0; + + virtual IgnoreData *Find(const Anope::string &mask) = 0; + + virtual std::vector &GetIgnores() = 0; +}; + +static ServiceReference ignore_service("IgnoreService", "ignore"); diff --git a/include/modules/operserv/news.h b/include/modules/operserv/news.h new file mode 100644 index 000000000..815c71db6 --- /dev/null +++ b/include/modules/operserv/news.h @@ -0,0 +1,51 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +enum NewsType +{ + NEWS_LOGON, + NEWS_RANDOM, + NEWS_OPER +}; + +struct NewsMessages final +{ + NewsType type; + Anope::string name; + const char *msgs[10]; +}; + +struct NewsItem + : Serializable +{ + NewsType type; + Anope::string text; + Anope::string who; + time_t time; + + NewsItem() : Serializable("NewsItem") { } +}; + +class NewsService + : public Service +{ +public: + 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 &GetNewsList(NewsType t) = 0; +}; + +static ServiceReference news_service("NewsService", "news"); diff --git a/include/modules/operserv/oper.h b/include/modules/operserv/oper.h new file mode 100644 index 000000000..154b6af08 --- /dev/null +++ b/include/modules/operserv/oper.h @@ -0,0 +1,46 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +struct MyOper final + : Oper + , Serializable +{ + MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } + + void Serialize(Serialize::Data &data) const override + { + data.Store("name", this->name); + data.Store("type", this->ot->GetName()); + } + + static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) + { + Anope::string stype, sname; + + data["type"] >> stype; + data["name"] >> sname; + + OperType *ot = OperType::Find(stype); + if (ot == NULL) + return NULL; + NickCore *nc = NickCore::Find(sname); + if (nc == NULL) + return NULL; + + MyOper *myo; + if (obj) + myo = anope_dynamic_static_cast(obj); + else + myo = new MyOper(nc->display, ot); + nc->o = myo; + Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName(); + return myo; + } +}; diff --git a/include/modules/operserv/session.h b/include/modules/operserv/session.h new file mode 100644 index 000000000..0f25f669e --- /dev/null +++ b/include/modules/operserv/session.h @@ -0,0 +1,93 @@ +/* + * + * (C) 2011-2025 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +struct Session final +{ + cidr addr; /* A cidr (sockaddrs + len) representing this session */ + unsigned count = 1; /* Number of clients with this host */ + unsigned hits = 0; /* Number of subsequent kills for a host */ + + Session(const sockaddrs &ip, int len) : addr(ip, len) { } +}; + +struct Exception final + : Serializable +{ + Anope::string mask; /* Hosts to which this exception applies */ + unsigned limit; /* Session limit for exception */ + Anope::string who; /* Nick of person who added the exception */ + Anope::string reason; /* Reason for exception's addition */ + time_t time; /* When this exception was added */ + time_t expires; /* Time when it expires. 0 == no expiry */ + + Exception() : Serializable("Exception") { } + void Serialize(Serialize::Data &data) const override; + static Serializable *Unserialize(Serializable *obj, Serialize::Data &data); +}; + +class SessionService + : public Service +{ +public: + typedef std::unordered_map SessionMap; + typedef std::vector ExceptionVector; + + SessionService(Module *m) : Service(m, "SessionService", "session") { } + + virtual Exception *CreateException() = 0; + + virtual void AddException(Exception *e) = 0; + + virtual void DelException(Exception *e) = 0; + + virtual Exception *FindException(User *u) = 0; + + virtual Exception *FindException(const Anope::string &host) = 0; + + virtual ExceptionVector &GetExceptions() = 0; + + virtual Session *FindSession(const Anope::string &ip) = 0; + + virtual SessionMap &GetSessions() = 0; +}; + +static ServiceReference session_service("SessionService", "session"); + +void Exception::Serialize(Serialize::Data &data) const +{ + data.Store("mask", this->mask); + data.Store("limit", this->limit); + data.Store("who", this->who); + data.Store("reason", this->reason); + data.Store("time", this->time); + data.Store("expires", this->expires); +} + +Serializable *Exception::Unserialize(Serializable *obj, Serialize::Data &data) +{ + if (!session_service) + return NULL; + + Exception *ex; + if (obj) + ex = anope_dynamic_static_cast(obj); + else + ex = new Exception; + data["mask"] >> ex->mask; + data["limit"] >> ex->limit; + data["who"] >> ex->who; + data["reason"] >> ex->reason; + data["time"] >> ex->time; + data["expires"] >> ex->expires; + + if (!obj) + session_service->AddException(ex); + return ex; +} diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h deleted file mode 100644 index 5c2f9d05c..000000000 --- a/include/modules/os_forbid.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -enum ForbidType -{ - FT_NICK = 1, - FT_CHAN, - FT_EMAIL, - FT_REGISTER, - FT_SIZE -}; - -struct ForbidData -{ - Anope::string mask; - Anope::string creator; - Anope::string reason; - time_t created = 0; - time_t expires = 0; - ForbidType type; - - virtual ~ForbidData() = default; -protected: - ForbidData() = default; -}; - -class ForbidService - : public Service -{ -public: - ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { } - - virtual void AddForbid(ForbidData *d) = 0; - - virtual void RemoveForbid(ForbidData *d) = 0; - - virtual ForbidData *CreateForbid() = 0; - - virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0; - - virtual ForbidData *FindForbidExact(const Anope::string &mask, ForbidType type) = 0; - - virtual std::vector GetForbids() = 0; -}; - -static ServiceReference forbid_service("ForbidService", "forbid"); diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h deleted file mode 100644 index 8a60a044f..000000000 --- a/include/modules/os_ignore.h +++ /dev/null @@ -1,46 +0,0 @@ -/* OperServ ignore interface - * - * (C) 2003-2025 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. - */ - -#pragma once - -struct IgnoreData -{ - Anope::string mask; - Anope::string creator; - Anope::string reason; - time_t time = 0; /* When do we stop ignoring them? */ - - virtual ~IgnoreData() = default; -protected: - IgnoreData() = default; -}; - -class IgnoreService - : public Service -{ -protected: - IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { } - -public: - virtual void AddIgnore(IgnoreData *) = 0; - - virtual void DelIgnore(IgnoreData *) = 0; - - virtual void ClearIgnores() = 0; - - virtual IgnoreData *Create() = 0; - - virtual IgnoreData *Find(const Anope::string &mask) = 0; - - virtual std::vector &GetIgnores() = 0; -}; - -static ServiceReference ignore_service("IgnoreService", "ignore"); diff --git a/include/modules/os_news.h b/include/modules/os_news.h deleted file mode 100644 index 815c71db6..000000000 --- a/include/modules/os_news.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -enum NewsType -{ - NEWS_LOGON, - NEWS_RANDOM, - NEWS_OPER -}; - -struct NewsMessages final -{ - NewsType type; - Anope::string name; - const char *msgs[10]; -}; - -struct NewsItem - : Serializable -{ - NewsType type; - Anope::string text; - Anope::string who; - time_t time; - - NewsItem() : Serializable("NewsItem") { } -}; - -class NewsService - : public Service -{ -public: - 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 &GetNewsList(NewsType t) = 0; -}; - -static ServiceReference news_service("NewsService", "news"); diff --git a/include/modules/os_oper.h b/include/modules/os_oper.h deleted file mode 100644 index 154b6af08..000000000 --- a/include/modules/os_oper.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -struct MyOper final - : Oper - , Serializable -{ - MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } - - void Serialize(Serialize::Data &data) const override - { - data.Store("name", this->name); - data.Store("type", this->ot->GetName()); - } - - static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) - { - Anope::string stype, sname; - - data["type"] >> stype; - data["name"] >> sname; - - OperType *ot = OperType::Find(stype); - if (ot == NULL) - return NULL; - NickCore *nc = NickCore::Find(sname); - if (nc == NULL) - return NULL; - - MyOper *myo; - if (obj) - myo = anope_dynamic_static_cast(obj); - else - myo = new MyOper(nc->display, ot); - nc->o = myo; - Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName(); - return myo; - } -}; diff --git a/include/modules/os_session.h b/include/modules/os_session.h deleted file mode 100644 index 0f25f669e..000000000 --- a/include/modules/os_session.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -struct Session final -{ - cidr addr; /* A cidr (sockaddrs + len) representing this session */ - unsigned count = 1; /* Number of clients with this host */ - unsigned hits = 0; /* Number of subsequent kills for a host */ - - Session(const sockaddrs &ip, int len) : addr(ip, len) { } -}; - -struct Exception final - : Serializable -{ - Anope::string mask; /* Hosts to which this exception applies */ - unsigned limit; /* Session limit for exception */ - Anope::string who; /* Nick of person who added the exception */ - Anope::string reason; /* Reason for exception's addition */ - time_t time; /* When this exception was added */ - time_t expires; /* Time when it expires. 0 == no expiry */ - - Exception() : Serializable("Exception") { } - void Serialize(Serialize::Data &data) const override; - static Serializable *Unserialize(Serializable *obj, Serialize::Data &data); -}; - -class SessionService - : public Service -{ -public: - typedef std::unordered_map SessionMap; - typedef std::vector ExceptionVector; - - SessionService(Module *m) : Service(m, "SessionService", "session") { } - - virtual Exception *CreateException() = 0; - - virtual void AddException(Exception *e) = 0; - - virtual void DelException(Exception *e) = 0; - - virtual Exception *FindException(User *u) = 0; - - virtual Exception *FindException(const Anope::string &host) = 0; - - virtual ExceptionVector &GetExceptions() = 0; - - virtual Session *FindSession(const Anope::string &ip) = 0; - - virtual SessionMap &GetSessions() = 0; -}; - -static ServiceReference session_service("SessionService", "session"); - -void Exception::Serialize(Serialize::Data &data) const -{ - data.Store("mask", this->mask); - data.Store("limit", this->limit); - data.Store("who", this->who); - data.Store("reason", this->reason); - data.Store("time", this->time); - data.Store("expires", this->expires); -} - -Serializable *Exception::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!session_service) - return NULL; - - Exception *ex; - if (obj) - ex = anope_dynamic_static_cast(obj); - else - ex = new Exception; - data["mask"] >> ex->mask; - data["limit"] >> ex->limit; - data["who"] >> ex->who; - data["reason"] >> ex->reason; - data["time"] >> ex->time; - data["expires"] >> ex->expires; - - if (!obj) - session_service->AddException(ex); - return ex; -} diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h deleted file mode 100644 index 5bef94340..000000000 --- a/include/modules/pseudoclients/chanserv.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -class ChanServService - : public Service -{ -public: - ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") - { - } - - /* 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) = 0; -}; diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h deleted file mode 100644 index 01149d48e..000000000 --- a/include/modules/pseudoclients/global.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -#define GLOBAL_NO_MESSAGE _("You do not have any messages queued and did not specify a message to send.") -#define GLOBAL_QUEUE_CONFLICT _("You can not send a single message while you have messages queued.") - -class GlobalService - : public Service -{ -public: - GlobalService(Module *m) - : Service(m, "GlobalService", "Global") - { - } - - /** Retrieves the bot which sends global messages unless otherwise specified. */ - virtual Reference GetDefaultSender() const = 0; - - /** Clears any queued messages for the specified account. - * @param nc The account to clear queued messages for. - */ - virtual void ClearQueue(NickCore *nc) = 0; - - /** Retrieves the size of the messages queue for the specified user. - * @param nc The account to count queued messages for. - */ - inline size_t CountQueue(NickCore* nc) const - { - auto *q = GetQueue(nc); - return q ? q->size() : 0; - } - - /** Retrieves the messages queue for the specified user. - * @param nc The account to retrieve queued messages for. - */ - virtual const std::vector *GetQueue(NickCore* nc) const = 0; - - /** Queues a message to be sent later. - * @param nc The account to queue the message for. - * @param message The message to queue. - * @return The new number of messages in the queue. - */ - virtual size_t Queue(NickCore *nc, const Anope::string &message) = 0; - - /** Sends a single message to all users on the network. - * @param message The message to send. - * @param source If non-nullptr then the source of the message. - * @param sender If non-nullptr then the bot to send the message from. - * @param server If non-nullptr then the server to send messages to. - * @return If the message was sent then true; otherwise, false. - */ - virtual bool SendSingle(const Anope::string &message, CommandSource *source = nullptr, BotInfo *sender = nullptr, Server *server = nullptr) = 0; - - /** Sends a message queue to all users on the network. - * @param source The source of the message. - * @param sender If non-nullptr then the bot to send the message from. - * @param server If non-nullptr then the server to send messages to. - * @return If the message queue was sent then true; otherwise, false. - */ - virtual bool SendQueue(CommandSource &source, BotInfo *sender = nullptr, Server *server = nullptr) = 0; - - /** Unqueues a message from the message queue. - * @param nc The account to unqueue the message from. - * @param idx The index of the item to remove. - * @return Whether the message was removed from the queue. - */ - virtual bool Unqueue(NickCore *nc, size_t idx) = 0; -}; diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h deleted file mode 100644 index c1ff4af7d..000000000 --- a/include/modules/pseudoclients/memoserv.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -class MemoServService - : public Service -{ -public: - enum MemoResult - { - MEMO_SUCCESS, - MEMO_INVALID_TARGET, - 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 anything. - * @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; - - /** Check for new memos and notify the user if there are any - * @param u The user - */ - virtual void Check(User *u) = 0; -}; diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h deleted file mode 100644 index 2c659501e..000000000 --- a/include/modules/pseudoclients/nickserv.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * (C) 2011-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -class NickServService - : public Service -{ -public: - NickServService(Module *m) : Service(m, "NickServService", "NickServ") - { - } - - virtual void Validate(User *u) = 0; - virtual void Collide(User *u, NickAlias *na) = 0; - virtual void Release(NickAlias *na) = 0; - virtual bool IsGuestNick(const Anope::string &nick) const = 0; -}; diff --git a/include/modules/sasl.h b/include/modules/sasl.h deleted file mode 100644 index f23a5d32a..000000000 --- a/include/modules/sasl.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * (C) 2014-2025 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#pragma once - -namespace SASL -{ - struct Message final - { - Anope::string source; - Anope::string target; - Anope::string type; - std::vector data; - }; - - class Mechanism; - struct Session; - - class Service - : public ::Service - { - public: - Service(Module *o) : ::Service(o, "SASL::Service", "sasl") { } - - virtual void ProcessMessage(const Message &) = 0; - - virtual Session *GetSession(const Anope::string &uid) = 0; - - virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0; - - virtual void Succeed(Session *, NickCore *) = 0; - virtual void Fail(Session *) = 0; - virtual void DeleteSessions(Mechanism *, bool = false) = 0; - virtual void RemoveSession(Session *) = 0; - }; - - static ServiceReference service("SASL::Service", "sasl"); - - struct Session - { - time_t created; - Anope::string uid; - Anope::string hostname, ip; - Reference mech; - - Session(Mechanism *m, const Anope::string &u) : created(Anope::CurTime), uid(u), mech(m) { } - - inline Anope::string GetUserInfo() - { - auto *u = User::Find(uid); - if (u) - return u->GetMask(); - if (!hostname.empty() && !ip.empty()) - return Anope::printf("%s (%s)", hostname.c_str(), ip.c_str()); - return "A user"; - }; - - virtual ~Session() - { - if (service) - service->RemoveSession(this); - } - }; - - /* PLAIN, EXTERNAL, etc */ - class Mechanism - : public ::Service - { - public: - Mechanism(Module *o, const Anope::string &sname) : Service(o, "SASL::Mechanism", sname) { } - - virtual Session *CreateSession(const Anope::string &uid) { return new Session(this, uid); } - - virtual bool ProcessMessage(Session *session, const Message &) = 0; - - virtual ~Mechanism() - { - if (service) - service->DeleteSessions(this, true); - } - }; - - class IdentifyRequest - : public ::IdentifyRequest - { - Anope::string uid; - Anope::string hostname; - - inline Anope::string GetUserInfo() - { - auto *u = User::Find(uid); - if (u) - return u->GetMask(); - if (!hostname.empty() && !GetAddress().empty()) - return Anope::printf("%s (%s)", hostname.c_str(), GetAddress().c_str()); - return "A user"; - }; - - public: - IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass, const Anope::string &h, const Anope::string &i) - : ::IdentifyRequest(m, acc, pass, i) - , uid(id) - , hostname(h) - { - } - - void OnSuccess() override - { - if (!service) - return; - - NickAlias *na = NickAlias::Find(GetAccount()); - if (!na || na->nc->HasExt("NS_SUSPENDED") || na->nc->HasExt("UNCONFIRMED")) - return OnFail(); - - unsigned int maxlogins = Config->GetModule("ns_identify").Get("maxlogins"); - if (maxlogins && na->nc->users.size() >= maxlogins) - return OnFail(); - - Session *s = service->GetSession(uid); - if (s) - { - Log(this->GetOwner(), "sasl", Config->GetClient("NickServ")) << GetUserInfo() << " identified to account " << this->GetAccount() << " using SASL"; - service->Succeed(s, na->nc); - delete s; - } - } - - void OnFail() override - { - if (!service) - return; - - Session *s = service->GetSession(uid); - if (s) - { - service->Fail(s); - delete s; - } - - Anope::string accountstatus; - NickAlias *na = NickAlias::Find(GetAccount()); - if (!na) - accountstatus = "nonexistent "; - else if (na->nc->HasExt("NS_SUSPENDED")) - accountstatus = "suspended "; - else if (na->nc->HasExt("UNCONFIRMED")) - accountstatus = "unconfirmed "; - - Log(this->GetOwner(), "sasl", Config->GetClient("NickServ")) << GetUserInfo() << " failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL"; - } - }; - - /** Sends IRCd messages used by the SASL module. */ - class ProtocolInterface - : public ::Service - { - protected: - ProtocolInterface(Module *o) - : ::Service(o, "SASL::ProtocolInterface", "sasl") - { - } - - public: - /** Sends the list of SASL mechanisms to the IRCd - * @param mechs The list of SASL mechanisms. - */ - virtual void SendSASLMechanisms(std::vector &mechs) { }; - - /** Sends a SASL message to the IRCd. - * @param message The SASL message to send. - */ - virtual void SendSASLMessage(const SASL::Message &message) = 0; - - /** Sends a login or logout for \p uid to \p na. - * @param uid The uid of the user to log in. - * @param na The nick alias to log the user in as or logout if nullptr. - */ - virtual void SendSVSLogin(const Anope::string &uid, NickAlias *na) = 0; - }; - - static ServiceReference protocol_interface("SASL::ProtocolInterface", "sasl"); -} -- cgit