1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 12:23:14 +02:00

Rework the module headers to use namespaces and static services.

This commit is contained in:
Sadie Powell
2025-11-24 16:47:00 +00:00
parent 62ca6c96eb
commit be965f2618
65 changed files with 1054 additions and 864 deletions
+3 -4
View File
@@ -15,8 +15,9 @@
#pragma once
class AccessGroup;
namespace ChanServ { class AutoKick; }
class BotInfo;
namespace BotServ { class BadWord; }
namespace ChanServ { class AutoKick; class ModeLock; }
class CallBack;
class ChanAccess;
class Channel;
@@ -41,6 +42,7 @@ class MessageSource;
class Module;
class NickAlias;
class NickCore;
namespace OperServ { struct Exception; }
class OperType;
class ReferenceBase;
class Regex;
@@ -51,9 +53,6 @@ class Thread;
class User;
class XLine;
class XLineManager;
struct BadWord;
struct Exception;
struct MemoInfo;
struct ModeLock;
struct Oper;
namespace SASL { struct Message; }
-5
View File
@@ -48,8 +48,3 @@
#include "uplink.h"
#include "users.h"
#include "xline.h"
#include "modules/chanserv/service.h"
#include "modules/global/service.h"
#include "modules/memoserv/service.h"
#include "modules/nickserv/service.h"
+6 -6
View File
@@ -418,13 +418,13 @@ public:
* @param ci The channel
* @param bw The badword
*/
virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
virtual void OnBadWordAdd(ChannelInfo *ci, const BotServ::BadWord *bw) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
/** 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) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
virtual void OnBadWordDel(ChannelInfo *ci, const BotServ::BadWord *bw) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
/** Called when a bot is created or destroyed
*/
@@ -533,13 +533,13 @@ public:
* @param ex The exception
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnExceptionAdd(Exception *ex) ATTR_NOT_NULL(2) { throw NotImplementedException(); }
virtual EventReturn OnExceptionAdd(OperServ::Exception *ex) ATTR_NOT_NULL(2) { throw NotImplementedException(); }
/** Called before an exception is deleted
* @param source The source deleting it
* @param ex The exception
*/
virtual void OnExceptionDel(CommandSource &source, Exception *ex) ATTR_NOT_NULL(3) { throw NotImplementedException(); }
virtual void OnExceptionDel(CommandSource &source, OperServ::Exception *ex) ATTR_NOT_NULL(3) { throw NotImplementedException(); }
/** Called before a XLine is added
* @param source The source of the XLine
@@ -919,14 +919,14 @@ public:
* @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) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
virtual EventReturn OnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
/** 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) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
virtual EventReturn OnUnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) ATTR_NOT_NULL(2, 3) { throw NotImplementedException(); }
/** Called after a module is loaded
* @param u The user loading the module, can be NULL
+31 -21
View File
@@ -14,33 +14,43 @@
#pragma once
/** Flags for badwords
*/
enum BadWordType
#define BOTSERV_BAD_WORDS_EXT "badwords"
#define BOTSERV_BAD_WORDS_TYPE "BadWord"
namespace BotServ
{
/* 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
};
class BadWord;
struct BadWords;
/** 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
class BotServ::BadWord
{
Anope::string chan;
Anope::string word;
BadWordType type;
virtual ~BadWord() = default;
protected:
BadWord() = default;
public:
Anope::string chan;
Anope::string word;
BotServ::BadWordType type;
virtual ~BadWord() = default;
};
struct BadWords
struct BotServ::BadWords
{
virtual ~BadWords() = default;
@@ -49,13 +59,13 @@ struct BadWords
* @param type The type (SINGLE START END)
* @return The badword
*/
virtual BadWord *AddBadWord(const Anope::string &word, BadWordType type) = 0;
virtual BotServ::BadWord *AddBadWord(const Anope::string &word, BotServ::BadWordType type) = 0;
/** Get a badword structure by index
* @param index The index
* @return The badword
*/
virtual BadWord *GetBadWord(unsigned index) const = 0;
virtual BotServ::BadWord *GetBadWord(unsigned index) const = 0;
/** Get how many badwords are on this channel
* @return The number of badwords in the vector
+29 -21
View File
@@ -14,36 +14,44 @@
#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
};
#define BOTSERV_KICKER_DATA_EXT "kickerdata"
struct KickerData
namespace BotServ
{
class KickerData;
/* 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
};
}
class BotServ::KickerData
{
protected:
KickerData() = default;
public:
bool amsgs, badwords, bolds, caps, colors, flood, italics, repeat, reverses, underlines;
int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
int16_t ttb[BotServ::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;
};
+5 -5
View File
@@ -14,15 +14,15 @@
#pragma once
#define AUTOKICK_TYPE "AutoKick"
#define AUTOKICK_SERVICE "ChanServ::AutoKickService"
#define CHANSERV_AUTO_KICK_TYPE "AutoKick"
#define CHANSERV_AUTO_KICK_SERVICE "ChanServ::AutoKickService"
namespace ChanServ
{
class AutoKick;
class AutoKickService;
ServiceReference<AutoKickService> akick_service(AUTOKICK_SERVICE, AUTOKICK_TYPE);
ServiceReference<AutoKickService> akick_service(CHANSERV_AUTO_KICK_SERVICE, CHANSERV_AUTO_KICK_SERVICE);
}
class ChanServ::AutoKickService
@@ -30,7 +30,7 @@ class ChanServ::AutoKickService
{
public:
AutoKickService(Module *m)
: Service(m, AUTOKICK_SERVICE, AUTOKICK_TYPE)
: Service(m, CHANSERV_AUTO_KICK_SERVICE, CHANSERV_AUTO_KICK_SERVICE)
{
}
@@ -90,7 +90,7 @@ public:
time_t last_used;
AutoKick()
: Serializable(AUTOKICK_TYPE)
: Serializable(CHANSERV_AUTO_KICK_TYPE)
{
}
+25 -11
View File
@@ -14,30 +14,44 @@
#pragma once
struct EntryMsg
#define CHANSERV_ENTRY_MESSAGE_EXT "entrymsg"
#define CHANSERV_ENTRY_MESSAGE_TYPE "EntryMsg"
namespace ChanServ
{
class EntryMessage;
class EntryMessageList;
}
class ChanServ::EntryMessage
{
protected:
EntryMessage() = default;
public:
Anope::string chan;
Anope::string creator;
Anope::string message;
time_t when;
time_t when = 0;
virtual ~EntryMsg() = default;
protected:
EntryMsg() = default;
virtual ~EntryMessage() = default;
};
struct EntryMessageList
: Serialize::Checker<std::vector<EntryMsg *> >
class ChanServ::EntryMessageList
: public Serialize::Checker<std::vector<ChanServ::EntryMessage *>>
{
protected:
EntryMessageList() : Serialize::Checker<std::vector<EntryMsg *> >("EntryMsg") { }
EntryMessageList()
: Serialize::Checker<std::vector<ChanServ::EntryMessage *>>(CHANSERV_ENTRY_MESSAGE_TYPE)
{
}
public:
virtual ~EntryMessageList()
{
for (unsigned i = (*this)->size(); i > 0; --i)
delete (*this)->at(i - 1);
while (!(*this)->empty())
delete (*this)->back();
}
virtual EntryMsg *Create() = 0;
virtual ChanServ::EntryMessage *Create() = 0;
};
+19 -9
View File
@@ -14,8 +14,21 @@
#pragma once
struct LogSetting
#define CHANSERV_LOG_SETTING_EXT "logsettings"
#define CHANSERV_LOG_SETTING_TYPE "LogSetting"
namespace ChanServ
{
class LogSetting;
class LogSettings;
}
class ChanServ::LogSetting
{
protected:
LogSetting() = default;
public:
Anope::string chan;
/* Our service name of the command */
Anope::string service_name;
@@ -28,21 +41,18 @@ struct LogSetting
time_t created;
virtual ~LogSetting() = default;
protected:
LogSetting() = default;
};
struct LogSettings
: Serialize::Checker<std::vector<LogSetting *> >
class ChanServ::LogSettings
: public Serialize::Checker<std::vector<ChanServ::LogSetting *>>
{
typedef std::vector<LogSetting *>::iterator iterator;
protected:
LogSettings() : Serialize::Checker<std::vector<LogSetting *> >("LogSetting")
LogSettings()
: Serialize::Checker<std::vector<ChanServ::LogSetting *>>(CHANSERV_LOG_SETTING_TYPE)
{
}
public:
virtual ~LogSettings() = default;
virtual LogSetting *Create() = 0;
virtual ChanServ::LogSetting *Create() = 0;
};
+21 -6
View File
@@ -14,8 +14,23 @@
#pragma once
struct ModeLock
#define CHANSERV_MODE_LOCK_EXT "modelocks"
#define CHANSERV_MODE_LOCK_TYPE "ModeLock"
namespace ChanServ
{
class ModeLock;
class ModeLocks;
using ModeLockList = std::vector<ModeLock *>;
}
class ChanServ::ModeLock
{
protected:
ModeLock() = default;
public:
Anope::string ci;
bool set;
Anope::string name;
@@ -24,14 +39,14 @@ struct ModeLock
time_t created;
virtual ~ModeLock() = default;
protected:
ModeLock() = default;
};
struct ModeLocks
class ChanServ::ModeLocks
{
typedef std::vector<ModeLock *> ModeList;
protected:
ModeLocks() = default;
public:
virtual ~ModeLocks() = default;
/** Check if a mode is mlocked
@@ -69,7 +84,7 @@ struct ModeLocks
/** Get all of the mlocks for this channel
* @return The mlocks
*/
virtual const ModeList &GetMLock() const = 0;
virtual const ChanServ::ModeLockList &GetMLock() const = 0;
/** Get a list of mode locks on a channel
* @param name The mode name to get a list of
+13 -3
View File
@@ -14,11 +14,21 @@
#pragma once
class ChanServService
: public Service
#define CHANSERV_SERVICE "ChanServ::Service"
namespace ChanServ
{
class Service;
ServiceReference<Service> service(CHANSERV_SERVICE, CHANSERV_SERVICE);
}
class ChanServ::Service
: public ::Service
{
public:
ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ")
Service(Module *m)
: ::Service(m, CHANSERV_SERVICE, CHANSERV_SERVICE)
{
}
+13 -4
View File
@@ -17,12 +17,21 @@
#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
#define GLOBAL_SERVICE "Global::Service"
namespace Global
{
class Service;
ServiceReference<Global::Service> service(GLOBAL_SERVICE, GLOBAL_SERVICE);
}
class Global::Service
: public ::Service
{
public:
GlobalService(Module *m)
: Service(m, "GlobalService", "Global")
Service(Module *m)
: ::Service(m, GLOBAL_SERVICE, GLOBAL_SERVICE)
{
}
+8 -1
View File
@@ -14,7 +14,14 @@
#pragma once
class HostRequest
#define HOSTSERV_HOST_REQUEST_EXT "hostrequest"
namespace HostServ
{
class HostRequest;
}
class HostServ::HostRequest
{
protected:
HostRequest() = default;
+16 -5
View File
@@ -14,10 +14,13 @@
#pragma once
class MemoServService
: public Service
#define MEMOSERV_SERVICE "MemoServ::Service"
namespace MemoServ
{
public:
class Service;
/** Possible results when sending a memo. */
enum MemoResult
{
MEMO_SUCCESS,
@@ -26,7 +29,15 @@ public:
MEMO_TARGET_FULL
};
MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ")
ServiceReference<Service> service(MEMOSERV_SERVICE, MEMOSERV_SERVICE);
}
class MemoServ::Service
: public ::Service
{
public:
Service(Module *m)
: ::Service(m, MEMOSERV_SERVICE, MEMOSERV_SERVICE)
{
}
@@ -36,7 +47,7 @@ public:
* @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 MemoServ::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
+21 -6
View File
@@ -14,12 +14,24 @@
#pragma once
struct NSCertList
#define NICKSERV_CERT_EXT "certificates"
#define NICKSERV_CERT_SERVICE "NickServ::CertService"
namespace NickServ
{
class CertList;
class CertService;
ServiceReference<CertService> cert_service(NICKSERV_CERT_SERVICE, NICKSERV_CERT_SERVICE);
}
class NickServ::CertList
{
protected:
NSCertList() = default;
CertList() = default;
public:
virtual ~NSCertList() = default;
virtual ~CertList() = default;
/** Add an entry to the nick's certificate list
*
@@ -75,11 +87,14 @@ public:
virtual void Check() = 0;
};
class CertService
: public Service
class NickServ::CertService
: public ::Service
{
public:
CertService(Module *c) : Service(c, "CertService", "certs") { }
CertService(Module *m)
: ::Service(m, NICKSERV_CERT_SERVICE, NICKSERV_CERT_SERVICE)
{
}
virtual NickCore *FindAccountFromCert(const Anope::string &cert) = 0;
virtual void ReplaceCert(const Anope::string &oldcert, const Anope::string &newcert) = 0;
+14 -3
View File
@@ -14,11 +14,22 @@
#pragma once
class NickServService
: public Service
#define NICKSERV_SERVICE "NickServ::Service"
namespace NickServ
{
class Service;
ServiceReference<Service> service(NICKSERV_SERVICE, NICKSERV_SERVICE);
}
class NickServ::Service
: public ::Service
{
public:
NickServService(Module *m) : Service(m, "NickServService", "NickServ")
Service(Module *m)
: ::Service(m, NICKSERV_SERVICE, NICKSERV_SERVICE)
{
}
+37 -23
View File
@@ -14,48 +14,62 @@
#pragma once
enum ForbidType
{
FT_NICK = 1,
FT_CHAN,
FT_EMAIL,
FT_REGISTER,
FT_PASSWORD,
FT_SIZE
};
#define OPERSERV_FORBID_DATA_TYPE "ForbidData"
#define OPERSERV_FORBID_SERVICE "OperServ::ForbidService"
struct ForbidData
namespace OperServ
{
class ForbidData;
class ForbidService;
enum ForbidType
{
FT_NICK = 1,
FT_CHAN,
FT_EMAIL,
FT_REGISTER,
FT_PASSWORD,
FT_SIZE
};
ServiceReference<ForbidService> forbid_service(OPERSERV_FORBID_SERVICE, OPERSERV_FORBID_SERVICE);
}
class OperServ::ForbidData
{
protected:
ForbidData() = default;
public:
Anope::string mask;
Anope::string creator;
Anope::string reason;
time_t created = 0;
time_t expires = 0;
bool immutable = false;
ForbidType type;
OperServ::ForbidType type;
virtual ~ForbidData() = default;
protected:
ForbidData() = default;
};
class ForbidService
class OperServ::ForbidService
: public Service
{
public:
ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { }
ForbidService(Module *m)
: Service(m, OPERSERV_FORBID_SERVICE, OPERSERV_FORBID_SERVICE)
{
}
virtual void AddForbid(ForbidData *d) = 0;
virtual void AddForbid(OperServ::ForbidData *d) = 0;
virtual void RemoveForbid(ForbidData *d) = 0;
virtual void RemoveForbid(OperServ::ForbidData *d) = 0;
virtual ForbidData *CreateForbid() = 0;
virtual OperServ::ForbidData *CreateForbid() = 0;
virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0;
virtual OperServ::ForbidData *FindForbid(const Anope::string &mask, OperServ::ForbidType type) = 0;
virtual ForbidData *FindForbidExact(const Anope::string &mask, ForbidType type) = 0;
virtual OperServ::ForbidData *FindForbidExact(const Anope::string &mask, OperServ::ForbidType type) = 0;
virtual std::vector<ForbidData *> GetForbids() = 0;
virtual std::vector<OperServ::ForbidData *> GetForbids() = 0;
};
static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
+26 -12
View File
@@ -14,36 +14,50 @@
#pragma once
struct IgnoreData
#define OPERSERV_IGNORE_DATA_TYPE "IgnoreData"
#define OPERSERV_IGNORE_SERVICE "OperServ::IgnoreService"
namespace OperServ
{
class IgnoreData;
class IgnoreService;
ServiceReference<IgnoreService> ignore_service(OPERSERV_IGNORE_SERVICE, OPERSERV_IGNORE_SERVICE);
}
class OperServ::IgnoreData
{
protected:
IgnoreData() = default;
public:
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
class OperServ::IgnoreService
: public Service
{
protected:
IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { }
IgnoreService(Module *c)
: Service(c, OPERSERV_IGNORE_SERVICE, OPERSERV_IGNORE_SERVICE)
{
}
public:
virtual void AddIgnore(IgnoreData *) = 0;
virtual void AddIgnore(OperServ::IgnoreData *) = 0;
virtual void DelIgnore(IgnoreData *) = 0;
virtual void DelIgnore(OperServ::IgnoreData *) = 0;
virtual void ClearIgnores() = 0;
virtual IgnoreData *Create() = 0;
virtual OperServ::IgnoreData *Create() = 0;
virtual IgnoreData *Find(const Anope::string &mask) = 0;
virtual OperServ::IgnoreData *Find(const Anope::string &mask) = 0;
virtual std::vector<IgnoreData *> &GetIgnores() = 0;
virtual std::vector<OperServ::IgnoreData *> &GetIgnores() = 0;
};
static ServiceReference<IgnoreService> ignore_service("IgnoreService", "ignore");
+32 -17
View File
@@ -14,37 +14,52 @@
#pragma once
enum NewsType
{
NEWS_LOGON,
NEWS_RANDOM,
NEWS_OPER
};
#define OPERSERV_NEWS_ITEM_TYPE "NewsItem"
#define OPERSERV_NEWS_SERVICE "OperServ::NewsService"
struct NewsItem
namespace OperServ
{
struct NewsItem;
class NewsService;
enum NewsType
{
NEWS_LOGON,
NEWS_RANDOM,
NEWS_OPER,
};
ServiceReference<NewsService> news_service(OPERSERV_NEWS_SERVICE, OPERSERV_NEWS_SERVICE);
}
struct OperServ::NewsItem
: Serializable
{
NewsType type;
OperServ::NewsType type;
Anope::string text;
Anope::string who;
time_t time;
NewsItem() : Serializable("NewsItem") { }
NewsItem()
: Serializable(OPERSERV_NEWS_ITEM_TYPE)
{
}
};
class NewsService
class OperServ::NewsService
: public Service
{
public:
NewsService(Module *m) : Service(m, "NewsService", "news") { }
NewsService(Module *m)
: Service(m, OPERSERV_NEWS_SERVICE, OPERSERV_NEWS_SERVICE)
{
}
virtual NewsItem *CreateNewsItem() = 0;
virtual OperServ::NewsItem *CreateNewsItem() = 0;
virtual void AddNewsItem(NewsItem *n) = 0;
virtual void AddNewsItem(OperServ::NewsItem *n) = 0;
virtual void DelNewsItem(NewsItem *n) = 0;
virtual void DelNewsItem(OperServ::NewsItem *n) = 0;
virtual std::vector<NewsItem *> &GetNewsList(NewsType t) = 0;
virtual std::vector<OperServ::NewsItem *> &GetNewsList(OperServ::NewsType t) = 0;
};
static ServiceReference<NewsService> news_service("NewsService", "news");
+14 -3
View File
@@ -14,9 +14,20 @@
#pragma once
struct MyOper final
: Oper
#define OPERSERV_OPER_TYPE "Oper"
namespace OperServ
{
struct Oper;
}
struct OperServ::Oper final
: ::Oper
, Serializable
{
MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { }
Oper(const Anope::string &n, OperType *o)
: ::Oper(n, o)
, Serializable(OPERSERV_OPER_TYPE)
{
}
};
+38 -19
View File
@@ -14,16 +14,34 @@
#pragma once
struct Session final
#define OPERSERV_SESSION_EXCEPTION_TYPE "Exception"
#define OPERSERV_SESSION_SERVICE "OperServ::SessionService"
namespace OperServ
{
struct Exception;
struct Session;
class SessionService;
using ExceptionVector = std::vector<Exception *>;
using SessionMap = std::unordered_map<cidr, Session *, cidr::hash>;
ServiceReference<SessionService> session_service(OPERSERV_SESSION_SERVICE, OPERSERV_SESSION_SERVICE);
}
struct OperServ::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) { }
Session(const sockaddrs &ip, int len)
: addr(ip, len)
{
}
};
struct Exception final
struct OperServ::Exception final
: Serializable
{
Anope::string mask; /* Hosts to which this exception applies */
@@ -33,33 +51,34 @@ struct Exception final
time_t time; /* When this exception was added */
time_t expires; /* Time when it expires. 0 == no expiry */
Exception() : Serializable("Exception") { }
Exception()
: Serializable(OPERSERV_SESSION_EXCEPTION_TYPE)
{
}
};
class SessionService
class OperServ::SessionService
: public Service
{
public:
typedef std::unordered_map<cidr, Session *, cidr::hash> SessionMap;
typedef std::vector<Exception *> ExceptionVector;
SessionService(Module *m)
: Service(m, OPERSERV_SESSION_SERVICE, OPERSERV_SESSION_SERVICE)
{
}
SessionService(Module *m) : Service(m, "SessionService", "session") { }
virtual OperServ::Exception *CreateException() = 0;
virtual Exception *CreateException() = 0;
virtual void AddException(OperServ::Exception *e) = 0;
virtual void AddException(Exception *e) = 0;
virtual void DelException(OperServ::Exception *e) = 0;
virtual void DelException(Exception *e) = 0;
virtual OperServ::Exception *FindException(User *u) = 0;
virtual Exception *FindException(User *u) = 0;
virtual OperServ::Exception *FindException(const Anope::string &host) = 0;
virtual Exception *FindException(const Anope::string &host) = 0;
virtual OperServ::ExceptionVector &GetExceptions() = 0;
virtual ExceptionVector &GetExceptions() = 0;
virtual OperServ::Session *FindSession(const Anope::string &ip) = 0;
virtual Session *FindSession(const Anope::string &ip) = 0;
virtual SessionMap &GetSessions() = 0;
virtual OperServ::SessionMap &GetSessions() = 0;
};
static ServiceReference<SessionService> session_service("SessionService", "session");
+43 -36
View File
@@ -17,42 +17,45 @@
namespace
{
Anope::string TypeToString(BadWordType bw)
Anope::string TypeToString(BotServ::BadWordType bw)
{
switch (bw)
{
case BW_ANY:
case BotServ::BW_ANY:
return "ANY";
case BW_SINGLE:
case BotServ::BW_SINGLE:
return "SINGLE";
case BW_START:
case BotServ::BW_START:
return "START";
case BW_END:
case BotServ::BW_END:
return "END";
}
return ""; // Should never happen.
}
BadWordType StringToType(const Anope::string &bw)
BotServ::BadWordType StringToType(const Anope::string &bw)
{
if (bw.equals_ci("ANY") || bw.equals_ci("0"))
return BW_ANY;
return BotServ::BW_ANY;
if (bw.equals_ci("SINGLE") || bw.equals_ci("1"))
return BW_SINGLE;
return BotServ::BW_SINGLE;
if (bw.equals_ci("START") || bw.equals_ci("2"))
return BW_START;
return BotServ::BW_START;
if (bw.equals_ci("END") || bw.equals_ci("3"))
return BW_END;
return BotServ::BW_END;
return BW_ANY; // Should never happen.
return BotServ::BW_ANY; // Should never happen.
}
}
struct BadWordImpl final
: BadWord
: BotServ::BadWord
, Serializable
{
BadWordImpl() : Serializable("BadWord") { }
BadWordImpl()
: Serializable(BOTSERV_BAD_WORDS_TYPE)
{
}
~BadWordImpl() override;
};
@@ -60,7 +63,7 @@ struct BadWordTypeImpl final
: Serialize::Type
{
BadWordTypeImpl()
: Serialize::Type("BadWord")
: Serialize::Type(BOTSERV_BAD_WORDS_TYPE)
{
}
@@ -76,17 +79,21 @@ struct BadWordTypeImpl final
};
struct BadWordsImpl final
: BadWords
: BotServ::BadWords
{
Serialize::Reference<ChannelInfo> ci;
typedef std::vector<BadWordImpl *> list;
Serialize::Checker<list> badwords;
BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { }
BadWordsImpl(Extensible *obj)
: ci(anope_dynamic_static_cast<ChannelInfo *>(obj))
, badwords(BOTSERV_BAD_WORDS_TYPE)
{
}
~BadWordsImpl() override;
BadWord *AddBadWord(const Anope::string &word, BadWordType type) override
BotServ::BadWord *AddBadWord(const Anope::string &word, BotServ::BadWordType type) override
{
auto *bw = new BadWordImpl();
bw->chan = ci->name;
@@ -100,7 +107,7 @@ struct BadWordsImpl final
return bw;
}
BadWord *GetBadWord(unsigned index) const override
BotServ::BadWord *GetBadWord(unsigned index) const override
{
if (this->badwords->empty() || index >= this->badwords->size())
return NULL;
@@ -134,7 +141,7 @@ struct BadWordsImpl final
void Check() override
{
if (this->badwords->empty())
ci->Shrink<BadWords>("badwords");
ci->Shrink<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
}
};
@@ -142,7 +149,7 @@ BadWordsImpl::~BadWordsImpl()
{
for (list::iterator it = badwords->begin(); it != badwords->end();)
{
BadWord *bw = *it;
auto *bw = *it;
++it;
delete bw;
}
@@ -153,7 +160,7 @@ BadWordImpl::~BadWordImpl()
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci)
{
BadWordsImpl *badwords = ci->GetExt<BadWordsImpl>("badwords");
BadWordsImpl *badwords = ci->GetExt<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
if (badwords)
{
BadWordsImpl::list::iterator it = std::find(badwords->badwords->begin(), badwords->badwords->end(), this);
@@ -186,7 +193,7 @@ Serializable *BadWordTypeImpl::Unserialize(Serializable *obj, Serialize::Data &d
bw->word = sword;
bw->type = StringToType(n);
BadWordsImpl *bws = ci->Require<BadWordsImpl>("badwords");
BadWordsImpl *bws = ci->Require<BadWordsImpl>(BOTSERV_BAD_WORDS_EXT);
if (!obj)
bws->badwords->push_back(bw);
@@ -198,7 +205,7 @@ class BadwordsDelCallback final
{
CommandSource &source;
ChannelInfo *ci;
BadWords *bw;
BotServ::BadWords *bw;
Command *c;
unsigned deleted = 0;
Anope::string lastdeleted;
@@ -208,7 +215,7 @@ public:
{
if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration"))
this->override = true;
bw = ci->Require<BadWords>("badwords");
bw = ci->Require<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
}
~BadwordsDelCallback() override
@@ -254,7 +261,7 @@ private:
list.AddColumn(_("Number")).AddColumn(_("Word")).AddColumn(_("Type"));
list.SetFlexible(_("{number}: \002{word}\002 -- type: {type}"));
BadWords *bw = ci->GetExt<BadWords>("badwords");
auto *bw = ci->GetExt<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (!bw || !bw->GetBadWordCount())
{
source.Reply(_("%s bad words list is empty."), ci->name.c_str());
@@ -266,9 +273,9 @@ private:
: public NumberList
{
ListFormatter &list;
BadWords *bw;
BotServ::BadWords *bw;
public:
BadwordsListCallback(ListFormatter &_list, BadWords *_bw, const Anope::string &numlist) : NumberList(numlist, false), list(_list), bw(_bw)
BadwordsListCallback(ListFormatter &_list, BotServ::BadWords *_bw, const Anope::string &numlist) : NumberList(numlist, false), list(_list), bw(_bw)
{
}
@@ -277,7 +284,7 @@ private:
if (!Number || Number > bw->GetBadWordCount())
return;
const BadWord *b = bw->GetBadWord(Number - 1);
const auto *b = bw->GetBadWord(Number - 1);
ListFormatter::ListEntry entry;
entry["Number"] = Anope::ToString(Number);
entry["Word"] = b->word;
@@ -292,7 +299,7 @@ private:
{
for (unsigned i = 0, end = bw->GetBadWordCount(); i < end; ++i)
{
const BadWord *b = bw->GetBadWord(i);
const auto *b = bw->GetBadWord(i);
if (!word.empty() && !Anope::Match(b->word, word))
continue;
@@ -318,9 +325,9 @@ private:
void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
{
size_t pos = word.rfind(' ');
BadWordType bwtype = BW_ANY;
auto bwtype = BotServ::BW_ANY;
Anope::string realword = word;
BadWords *badwords = ci->Require<BadWords>("badwords");
auto *badwords = ci->Require<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (pos != Anope::string::npos)
{
@@ -341,7 +348,7 @@ private:
for (unsigned i = 0, end = badwords->GetBadWordCount(); i < end; ++i)
{
const BadWord *bw = badwords->GetBadWord(i);
const auto *bw = badwords->GetBadWord(i);
if ((casesensitive && realword.equals_cs(bw->word)) || (!casesensitive && realword.equals_ci(bw->word)))
{
@@ -359,7 +366,7 @@ private:
void DoDelete(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
{
BadWords *badwords = ci->GetExt<BadWords>("badwords");
auto *badwords = ci->GetExt<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (!badwords || !badwords->GetBadWordCount())
{
@@ -376,7 +383,7 @@ private:
else
{
unsigned i, end;
const BadWord *badword;
const BotServ::BadWord *badword;
for (i = 0, end = badwords->GetBadWordCount(); i < end; ++i)
{
@@ -408,7 +415,7 @@ private:
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR";
BadWords *badwords = ci->GetExt<BadWords>("badwords");
auto *badwords = ci->GetExt<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (badwords)
badwords->ClearBadWords();
source.Reply(_("Bad words list is now empty."));
@@ -519,7 +526,7 @@ public:
BSBadwords(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, commandbsbadwords(this)
, badwords(this, "badwords")
, badwords(this, BOTSERV_BAD_WORDS_EXT)
{
}
};
+85 -85
View File
@@ -19,7 +19,7 @@
static Module *me;
struct KickerDataImpl final
: KickerData
: BotServ::KickerData
{
KickerDataImpl(Extensible *obj)
{
@@ -38,7 +38,7 @@ struct KickerDataImpl final
if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines || dontkickops || dontkickvoices)
return;
ci->Shrink<KickerData>("kickerdata");
ci->Shrink<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
}
struct ExtensibleItem final
@@ -52,7 +52,7 @@ struct KickerDataImpl final
return;
const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(e);
KickerData *kd = this->Get(ci);
auto *kd = this->Get(ci);
if (kd == NULL)
return;
@@ -86,7 +86,7 @@ struct KickerDataImpl final
return;
ChannelInfo *ci = anope_dynamic_static_cast<ChannelInfo *>(e);
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
data["kickerdata:amsgs"] >> kd->amsgs;
data["kickerdata:badwords"] >> kd->badwords;
@@ -110,7 +110,7 @@ struct KickerDataImpl final
Anope::string ttb, tok;
data["ttb"] >> ttb;
spacesepstream sep(ttb);
for (int i = 0; sep.GetToken(tok) && i < TTB_SIZE; ++i)
for (int i = 0; sep.GetToken(tok) && i < BotServ::TTB_SIZE; ++i)
{
if (auto n = Anope::TryConvert<int16_t>(tok))
kd->ttb[i] = n.value();
@@ -208,7 +208,7 @@ protected:
return false;
}
void Process(CommandSource &source, ChannelInfo *ci, const Anope::string &param, const Anope::string &ttb, size_t ttb_idx, const Anope::string &optname, KickerData *kd, bool &val)
void Process(CommandSource &source, ChannelInfo *ci, const Anope::string &param, const Anope::string &ttb, size_t ttb_idx, const Anope::string &optname, BotServ::KickerData *kd, bool &val)
{
if (param.equals_ci("ON"))
{
@@ -265,8 +265,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_AMSGS, "AMSG", kd, kd->amsgs);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_AMSGS, "AMSG", kd, kd->amsgs);
kd->Check(ci);
}
}
@@ -305,8 +305,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_BADWORDS, "badwords", kd, kd->badwords);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_BADWORDS, BOTSERV_BAD_WORDS_EXT, kd, kd->badwords);
kd->Check(ci);
}
@@ -349,8 +349,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_BOLDS, "bolds", kd, kd->bolds);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_BOLDS, "bolds", kd, kd->bolds);
kd->Check(ci);
}
}
@@ -387,7 +387,7 @@ public:
if (!CheckArguments(source, params, ci))
return;
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (params[1].equals_ci("ON"))
{
@@ -397,16 +397,16 @@ public:
if (!ttb.empty())
{
kd->ttb[TTB_CAPS] = Anope::Convert<int16_t>(ttb, -1);
if (kd->ttb[TTB_CAPS] < 0)
kd->ttb[BotServ::TTB_CAPS] = Anope::Convert<int16_t>(ttb, -1);
if (kd->ttb[BotServ::TTB_CAPS] < 0)
{
kd->ttb[TTB_CAPS] = 0;
kd->ttb[BotServ::TTB_CAPS] = 0;
source.Reply(_("\002%s\002 cannot be taken as times to ban."), ttb.c_str());
return;
}
}
else
kd->ttb[TTB_CAPS] = 0;
kd->ttb[BotServ::TTB_CAPS] = 0;
kd->capsmin = Anope::Convert(min, 0);
if (kd->capsmin < 1)
@@ -417,7 +417,7 @@ public:
kd->capspercent = 25;
kd->caps = true;
if (kd->ttb[TTB_CAPS])
if (kd->ttb[BotServ::TTB_CAPS])
{
source.Reply(_(
"Bot will now kick for \002caps\002 (they must constitute at least "
@@ -426,7 +426,7 @@ public:
),
kd->capsmin,
kd->capspercent,
kd->ttb[TTB_CAPS]);
kd->ttb[BotServ::TTB_CAPS]);
}
else
source.Reply(_(
@@ -482,8 +482,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_COLORS, "colors", kd, kd->colors);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_COLORS, "colors", kd, kd->colors);
kd->Check(ci);
}
}
@@ -520,7 +520,7 @@ public:
if (!CheckArguments(source, params, ci))
return;
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (params[1].equals_ci("ON"))
{
@@ -530,16 +530,16 @@ public:
if (!ttb.empty())
{
kd->ttb[TTB_FLOOD] = Anope::Convert<int16_t>(ttb, -1);
if (kd->ttb[TTB_FLOOD] < 0)
kd->ttb[BotServ::TTB_FLOOD] = Anope::Convert<int16_t>(ttb, -1);
if (kd->ttb[BotServ::TTB_FLOOD] < 0)
{
kd->ttb[TTB_FLOOD] = 0;
kd->ttb[BotServ::TTB_FLOOD] = 0;
source.Reply(_("\002%s\002 cannot be taken as times to ban."), ttb.c_str());
return;
}
}
else
kd->ttb[TTB_FLOOD] = 0;
kd->ttb[BotServ::TTB_FLOOD] = 0;
kd->floodlines = Anope::Convert(lines, -1);
if (kd->floodlines < 2)
@@ -553,7 +553,7 @@ public:
kd->floodsecs = Config->GetModule(me).Get<time_t>("keepdata");
kd->flood = true;
if (kd->ttb[TTB_FLOOD])
if (kd->ttb[BotServ::TTB_FLOOD])
{
source.Reply(_(
"Bot will now kick for \002flood\002 (%d lines in %d seconds "
@@ -561,7 +561,7 @@ public:
),
kd->floodlines,
kd->floodsecs,
kd->ttb[TTB_FLOOD]);
kd->ttb[BotServ::TTB_FLOOD]);
}
else
source.Reply(_("Bot will now kick for \002flood\002 (%d lines in %d seconds)."), kd->floodlines, kd->floodsecs);
@@ -609,8 +609,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_ITALICS, "italics", kd, kd->italics);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_ITALICS, "italics", kd, kd->italics);
kd->Check(ci);
}
}
@@ -647,7 +647,7 @@ public:
if (!CheckArguments(source, params, ci))
return;
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (params[1].equals_ci("ON"))
{
@@ -656,23 +656,23 @@ public:
if (!ttb.empty())
{
kd->ttb[TTB_REPEAT] = Anope::Convert(ttb, -1);
if (kd->ttb[TTB_REPEAT] < 0)
kd->ttb[BotServ::TTB_REPEAT] = Anope::Convert(ttb, -1);
if (kd->ttb[BotServ::TTB_REPEAT] < 0)
{
kd->ttb[TTB_REPEAT] = 0;
kd->ttb[BotServ::TTB_REPEAT] = 0;
source.Reply(_("\002%s\002 cannot be taken as times to ban."), ttb.c_str());
return;
}
}
else
kd->ttb[TTB_REPEAT] = 0;
kd->ttb[BotServ::TTB_REPEAT] = 0;
kd->repeattimes = Anope::Convert<int16_t>(times, -1);
if (kd->repeattimes < 1)
kd->repeattimes = 3;
kd->repeat = true;
if (kd->ttb[TTB_REPEAT])
if (kd->ttb[BotServ::TTB_REPEAT])
{
if (kd->repeattimes != 1)
{
@@ -682,7 +682,7 @@ public:
"kicks for the same user."
),
kd->repeattimes,
kd->ttb[TTB_REPEAT]);
kd->ttb[BotServ::TTB_REPEAT]);
}
else
source.Reply(_(
@@ -691,7 +691,7 @@ public:
"kicks for the same user."
),
kd->repeattimes,
kd->ttb[TTB_REPEAT]);
kd->ttb[BotServ::TTB_REPEAT]);
}
else
{
@@ -757,8 +757,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_REVERSES, "reverses", kd, kd->reverses);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_REVERSES, "reverses", kd, kd->reverses);
kd->Check(ci);
}
}
@@ -794,8 +794,8 @@ public:
ChannelInfo *ci;
if (CheckArguments(source, params, ci))
{
KickerData *kd = ci->Require<KickerData>("kickerdata");
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", TTB_UNDERLINES, "underlines", kd, kd->underlines);
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
Process(source, ci, params[1], params.size() > 2 ? params[2] : "", BotServ::TTB_UNDERLINES, "underlines", kd, kd->underlines);
kd->Check(ci);
}
}
@@ -848,7 +848,7 @@ public:
return;
}
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (params[1].equals_ci("ON"))
{
bool override = !access.HasPriv("SET");
@@ -916,7 +916,7 @@ public:
return;
}
KickerData *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (params[1].equals_ci("ON"))
{
bool override = !access.HasPriv("SET");
@@ -958,7 +958,7 @@ struct BanData final
{
Anope::string mask;
time_t last_use;
int16_t ttb[TTB_SIZE];
int16_t ttb[BotServ::TTB_SIZE];
Data()
{
@@ -1089,7 +1089,7 @@ class BSKick final
return ud;
}
void check_ban(ChannelInfo *ci, User *u, KickerData *kd, int ttbtype)
void check_ban(ChannelInfo *ci, User *u, BotServ::KickerData *kd, int ttbtype)
{
/* Don't ban ulines or protected users */
if (u->IsProtected())
@@ -1129,7 +1129,7 @@ public:
BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
bandata(this, "bandata"),
userdata(this, "userdata"),
kickerdata(this, "kickerdata"),
kickerdata(this, BOTSERV_KICKER_DATA_EXT),
commandbskick(this),
commandbskickamsg(this), commandbskickbadwords(this), commandbskickbolds(this), commandbskickcaps(this),
@@ -1151,12 +1151,12 @@ public:
Anope::string enabled = Language::Translate(source.nc, _("Enabled"));
Anope::string disabled = Language::Translate(source.nc, _("Disabled"));
KickerData *kd = kickerdata.Get(ci);
auto *kd = kickerdata.Get(ci);
if (kd && kd->badwords)
{
if (kd->ttb[TTB_BADWORDS])
info[_("Bad words kicker")] = Anope::Format("%s (%d kick(s) to ban)", enabled.c_str(), kd->ttb[TTB_BADWORDS]);
if (kd->ttb[BotServ::TTB_BADWORDS])
info[_("Bad words kicker")] = Anope::Format("%s (%d kick(s) to ban)", enabled.c_str(), kd->ttb[BotServ::TTB_BADWORDS]);
else
info[_("Bad words kicker")] = enabled;
}
@@ -1165,8 +1165,8 @@ public:
if (kd && kd->bolds)
{
if (kd->ttb[TTB_BOLDS])
info[_("Bolds kicker")] = Anope::Format("%s (%d kick(s) to ban)", enabled.c_str(), kd->ttb[TTB_BOLDS]);
if (kd->ttb[BotServ::TTB_BOLDS])
info[_("Bolds kicker")] = Anope::Format("%s (%d kick(s) to ban)", enabled.c_str(), kd->ttb[BotServ::TTB_BOLDS]);
else
info[_("Bolds kicker")] = enabled;
}
@@ -1175,8 +1175,8 @@ public:
if (kd && kd->caps)
{
if (kd->ttb[TTB_CAPS])
info[_("Caps kicker")] = Anope::Format(_("%s (%d kick(s) to ban; minimum %d/%d%%)"), enabled.c_str(), kd->ttb[TTB_CAPS], kd->capsmin, kd->capspercent);
if (kd->ttb[BotServ::TTB_CAPS])
info[_("Caps kicker")] = Anope::Format(_("%s (%d kick(s) to ban; minimum %d/%d%%)"), enabled.c_str(), kd->ttb[BotServ::TTB_CAPS], kd->capsmin, kd->capspercent);
else
info[_("Caps kicker")] = Anope::Format(_("%s (minimum %d/%d%%)"), enabled.c_str(), kd->capsmin, kd->capspercent);
}
@@ -1185,8 +1185,8 @@ public:
if (kd && kd->colors)
{
if (kd->ttb[TTB_COLORS])
info[_("Colors kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[TTB_COLORS]);
if (kd->ttb[BotServ::TTB_COLORS])
info[_("Colors kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[BotServ::TTB_COLORS]);
else
info[_("Colors kicker")] = enabled;
}
@@ -1195,8 +1195,8 @@ public:
if (kd && kd->flood)
{
if (kd->ttb[TTB_FLOOD])
info[_("Flood kicker")] = Anope::Format(_("%s (%d kick(s) to ban; %d lines in %ds)"), enabled.c_str(), kd->ttb[TTB_FLOOD], kd->floodlines, kd->floodsecs);
if (kd->ttb[BotServ::TTB_FLOOD])
info[_("Flood kicker")] = Anope::Format(_("%s (%d kick(s) to ban; %d lines in %ds)"), enabled.c_str(), kd->ttb[BotServ::TTB_FLOOD], kd->floodlines, kd->floodsecs);
else
info[_("Flood kicker")] = Anope::Format(_("%s (%d lines in %ds)"), enabled.c_str(), kd->floodlines, kd->floodsecs);
}
@@ -1205,8 +1205,8 @@ public:
if (kd && kd->repeat)
{
if (kd->ttb[TTB_REPEAT])
info[_("Repeat kicker")] = Anope::Format(_("%s (%d kick(s) to ban; %d times)"), enabled.c_str(), kd->ttb[TTB_REPEAT], kd->repeattimes);
if (kd->ttb[BotServ::TTB_REPEAT])
info[_("Repeat kicker")] = Anope::Format(_("%s (%d kick(s) to ban; %d times)"), enabled.c_str(), kd->ttb[BotServ::TTB_REPEAT], kd->repeattimes);
else
info[_("Repeat kicker")] = Anope::Format(_("%s (%d times)"), enabled.c_str(), kd->repeattimes);
}
@@ -1215,8 +1215,8 @@ public:
if (kd && kd->reverses)
{
if (kd->ttb[TTB_REVERSES])
info[_("Reverses kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[TTB_REVERSES]);
if (kd->ttb[BotServ::TTB_REVERSES])
info[_("Reverses kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[BotServ::TTB_REVERSES]);
else
info[_("Reverses kicker")] = enabled;
}
@@ -1225,8 +1225,8 @@ public:
if (kd && kd->underlines)
{
if (kd->ttb[TTB_UNDERLINES])
info[_("Underlines kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[TTB_UNDERLINES]);
if (kd->ttb[BotServ::TTB_UNDERLINES])
info[_("Underlines kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[BotServ::TTB_UNDERLINES]);
else
info[_("Underlines kicker")] = enabled;
}
@@ -1235,8 +1235,8 @@ public:
if (kd && kd->italics)
{
if (kd->ttb[TTB_ITALICS])
info[_("Italics kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[TTB_ITALICS]);
if (kd->ttb[BotServ::TTB_ITALICS])
info[_("Italics kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[BotServ::TTB_ITALICS]);
else
info[_("Italics kicker")] = enabled;
}
@@ -1245,8 +1245,8 @@ public:
if (kd && kd->amsgs)
{
if (kd->ttb[TTB_AMSGS])
info[_("AMSG kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[TTB_AMSGS]);
if (kd->ttb[BotServ::TTB_AMSGS])
info[_("AMSG kicker")] = Anope::Format(_("%s (%d kick(s) to ban)"), enabled.c_str(), kd->ttb[BotServ::TTB_AMSGS]);
else
info[_("AMSG kicker")] = enabled;
}
@@ -1272,7 +1272,7 @@ public:
ChannelInfo *ci = c->ci;
if (ci == NULL)
return;
KickerData *kd = kickerdata.Get(ci);
auto *kd = kickerdata.Get(ci);
if (kd == NULL)
return;
@@ -1298,7 +1298,7 @@ public:
/* Bolds kicker */
if (kd->bolds && realbuf.find(2) != Anope::string::npos)
{
check_ban(ci, u, kd, TTB_BOLDS);
check_ban(ci, u, kd, BotServ::TTB_BOLDS);
bot_kick(ci, u, _("Don't use bolds on this channel!"));
return;
}
@@ -1306,7 +1306,7 @@ public:
/* Color kicker */
if (kd->colors && realbuf.find(3) != Anope::string::npos)
{
check_ban(ci, u, kd, TTB_COLORS);
check_ban(ci, u, kd, BotServ::TTB_COLORS);
bot_kick(ci, u, _("Don't use colors on this channel!"));
return;
}
@@ -1314,7 +1314,7 @@ public:
/* Reverses kicker */
if (kd->reverses && realbuf.find(22) != Anope::string::npos)
{
check_ban(ci, u, kd, TTB_REVERSES);
check_ban(ci, u, kd, BotServ::TTB_REVERSES);
bot_kick(ci, u, _("Don't use reverses on this channel!"));
return;
}
@@ -1322,7 +1322,7 @@ public:
/* Italics kicker */
if (kd->italics && realbuf.find(29) != Anope::string::npos)
{
check_ban(ci, u, kd, TTB_ITALICS);
check_ban(ci, u, kd, BotServ::TTB_ITALICS);
bot_kick(ci, u, _("Don't use italics on this channel!"));
return;
}
@@ -1330,7 +1330,7 @@ public:
/* Underlines kicker */
if (kd->underlines && realbuf.find(31) != Anope::string::npos)
{
check_ban(ci, u, kd, TTB_UNDERLINES);
check_ban(ci, u, kd, BotServ::TTB_UNDERLINES);
bot_kick(ci, u, _("Don't use underlines on this channel!"));
return;
}
@@ -1355,7 +1355,7 @@ public:
if ((i || l) && i >= kd->capsmin && i * 100 / (i + l) >= kd->capspercent)
{
check_ban(ci, u, kd, TTB_CAPS);
check_ban(ci, u, kd, BotServ::TTB_CAPS);
bot_kick(ci, u, _("Turn caps lock OFF!"));
return;
}
@@ -1365,7 +1365,7 @@ public:
if (kd->badwords)
{
bool mustkick = false;
BadWords *badwords = ci->GetExt<BadWords>("badwords");
auto *badwords = ci->GetExt<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
/* Normalize the buffer */
Anope::string nbuf = Anope::RemoveFormatting(realbuf);
@@ -1375,7 +1375,7 @@ public:
if (badwords && !nbuf.empty())
for (unsigned i = 0; i < badwords->GetBadWordCount(); ++i)
{
const BadWord *bw = badwords->GetBadWord(i);
const auto *bw = badwords->GetBadWord(i);
if (bw->word.empty())
continue; // Shouldn't happen
@@ -1383,9 +1383,9 @@ public:
if (bw->word.length() > nbuf.length())
continue; // This can't ever match
if (bw->type == BW_ANY && ((casesensitive && nbuf.find(bw->word) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(bw->word) != Anope::string::npos)))
if (bw->type == BotServ::BW_ANY && ((casesensitive && nbuf.find(bw->word) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(bw->word) != Anope::string::npos)))
mustkick = true;
else if (bw->type == BW_SINGLE)
else if (bw->type == BotServ::BW_SINGLE)
{
size_t len = bw->word.length();
@@ -1406,7 +1406,7 @@ public:
}
}
}
else if (bw->type == BW_START)
else if (bw->type == BotServ::BW_START)
{
size_t len = bw->word.length();
@@ -1420,7 +1420,7 @@ public:
mustkick = true;
}
}
else if (bw->type == BW_END)
else if (bw->type == BotServ::BW_END)
{
size_t len = bw->word.length();
@@ -1437,7 +1437,7 @@ public:
if (mustkick)
{
check_ban(ci, u, kd, TTB_BADWORDS);
check_ban(ci, u, kd, BotServ::TTB_BADWORDS);
if (Config->GetModule(me).Get<bool>("gentlebadwordreason"))
bot_kick(ci, u, _("Watch your language!"));
else
@@ -1464,7 +1464,7 @@ public:
++ud->lines;
if (ud->lines >= kd->floodlines)
{
check_ban(ci, u, kd, TTB_FLOOD);
check_ban(ci, u, kd, BotServ::TTB_FLOOD);
bot_kick(ci, u, _("Stop flooding!"));
return;
}
@@ -1480,7 +1480,7 @@ public:
if (ud->times >= kd->repeattimes)
{
check_ban(ci, u, kd, TTB_REPEAT);
check_ban(ci, u, kd, BotServ::TTB_REPEAT);
bot_kick(ci, u, _("Stop repeating yourself!"));
return;
}
@@ -1495,7 +1495,7 @@ public:
if (chan->ci && kd->amsgs && !chan->ci->AccessFor(u).HasPriv("NOKICK"))
{
check_ban(chan->ci, u, kd, TTB_AMSGS);
check_ban(chan->ci, u, kd, BotServ::TTB_AMSGS);
bot_kick(chan->ci, u, _("Don't use AMSGs!"));
}
}
+7 -3
View File
@@ -14,6 +14,7 @@
#include "module.h"
#include "modules/chanserv/mode.h"
#include "modules/chanserv/service.h"
inline static Anope::string BotModes()
{
@@ -24,7 +25,7 @@ inline static Anope::string BotModes()
class ChanServCore final
: public Module
, public ChanServService
, public ChanServ::Service
{
Reference<BotInfo> ChanServ;
std::vector<Anope::string> defaults;
@@ -33,8 +34,11 @@ class ChanServCore final
bool always_lower = false;
public:
ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
ChanServService(this), inhabit(this, "inhabit"), persist("PERSIST")
ChanServCore(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, PSEUDOCLIENT | VENDOR)
, ChanServ::Service(this)
, inhabit(this, "inhabit")
, persist("PERSIST")
{
}
+1 -1
View File
@@ -123,7 +123,7 @@ struct AutoKickType final
: public Serialize::Type
{
AutoKickType()
: Serialize::Type(AUTOKICK_TYPE)
: Serialize::Type(CHANSERV_AUTO_KICK_TYPE)
{
}
+3 -3
View File
@@ -82,8 +82,8 @@ class CommandCSClone final
static void CopyBadwords(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci)
{
BadWords *target_badwords = target_ci->Require<BadWords>("badwords"),
*badwords = ci->Require<BadWords>("badwords");
auto *target_badwords = target_ci->Require<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
auto *badwords = ci->Require<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (!target_badwords || !badwords)
{
@@ -95,7 +95,7 @@ class CommandCSClone final
for (unsigned i = 0; i < badwords->GetBadWordCount(); ++i)
{
const BadWord *bw = badwords->GetBadWord(i);
const auto *bw = badwords->GetBadWord(i);
target_badwords->AddBadWord(bw->word, bw->type);
}
+19 -17
View File
@@ -16,14 +16,16 @@
#include "modules/chanserv/entrymsg.h"
struct EntryMsgImpl final
: EntryMsg
: ChanServ::EntryMessage
, Serializable
{
EntryMsgImpl() : Serializable("EntryMsg")
EntryMsgImpl()
: Serializable(CHANSERV_ENTRY_MESSAGE_TYPE)
{
}
EntryMsgImpl(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) : Serializable("EntryMsg")
EntryMsgImpl(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime)
: Serializable(CHANSERV_ENTRY_MESSAGE_TYPE)
{
this->chan = c->name;
this->creator = cname;
@@ -38,7 +40,7 @@ struct EntryMsgTypeImpl final
: Serialize::Type
{
EntryMsgTypeImpl()
: Serialize::Type("EntryMsg")
: Serialize::Type(CHANSERV_ENTRY_MESSAGE_TYPE)
{
}
@@ -55,11 +57,11 @@ struct EntryMsgTypeImpl final
};
struct EntryMessageListImpl final
: EntryMessageList
: ChanServ::EntryMessageList
{
EntryMessageListImpl(Extensible *) { }
EntryMsg *Create() override
ChanServ::EntryMessage *Create() override
{
return new EntryMsgImpl();
}
@@ -71,11 +73,11 @@ EntryMsgImpl::~EntryMsgImpl()
if (!ci)
return;
EntryMessageList *messages = ci->GetExt<EntryMessageList>("entrymsg");
auto *messages = ci->GetExt<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if (!messages)
return;
std::vector<EntryMsg *>::iterator it = std::find((*messages)->begin(), (*messages)->end(), this);
auto it = std::find((*messages)->begin(), (*messages)->end(), this);
if (it != (*messages)->end())
(*messages)->erase(it);
}
@@ -104,7 +106,7 @@ Serializable *EntryMsgTypeImpl::Unserialize(Serializable *obj, Serialize::Data &
return msg;
}
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
auto *messages = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
data["when"] >> swhen;
@@ -119,7 +121,7 @@ class CommandEntryMessage final
private:
static void DoList(CommandSource &source, ChannelInfo *ci)
{
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
auto *messages = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if ((*messages)->empty())
{
@@ -135,7 +137,7 @@ private:
for (unsigned i = 0; i < (*messages)->size(); ++i)
{
EntryMsg *msg = (*messages)->at(i);
auto *msg = (*messages)->at(i);
ListFormatter::ListEntry entry;
entry["Number"] = Anope::ToString(i + 1);
@@ -151,7 +153,7 @@ private:
void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message)
{
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
auto *messages = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if ((*messages)->size() >= Config->GetModule(this->owner).Get<unsigned>("maxentries"))
source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str());
@@ -165,7 +167,7 @@ private:
void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message)
{
EntryMessageList *messages = ci->Require<EntryMessageList>("entrymsg");
auto *messages = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if (!message.is_pos_number_only())
source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str());
@@ -178,7 +180,7 @@ private:
{
delete (*messages)->at(i - 1);
if ((*messages)->empty())
ci->Shrink<EntryMessageList>("entrymsg");
ci->Shrink<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message";
source.Reply(_("Entry message \002%i\002 for \002%s\002 deleted."), i, ci->name.c_str());
}
@@ -191,7 +193,7 @@ private:
void DoClear(CommandSource &source, ChannelInfo *ci)
{
ci->Shrink<EntryMessageList>("entrymsg");
ci->Shrink<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages";
source.Reply(_("Entry messages for \002%s\002 have been cleared."), ci->name.c_str());
@@ -287,7 +289,7 @@ public:
CSEntryMessage(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, commandentrymsg(this)
, eml(this, "entrymsg")
, eml(this, CHANSERV_ENTRY_MESSAGE_EXT)
{
}
@@ -295,7 +297,7 @@ public:
{
if (u && c && c->ci && u->server->IsSynced())
{
EntryMessageList *messages = c->ci->GetExt<EntryMessageList>("entrymsg");
auto *messages = c->ci->GetExt<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if (!messages)
return;
+2 -2
View File
@@ -99,8 +99,8 @@ public:
if (ci->c && ci->c->HasMode("SECRET"))
continue;
ModeLocks *ml = ci->GetExt<ModeLocks>("modelocks");
const ModeLock *secret = ml ? ml->GetMLock("SECRET") : NULL;
auto *ml = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
const auto *secret = ml ? ml->GetMLock("SECRET") : nullptr;
if (secret && secret->set)
continue;
}
+21 -21
View File
@@ -14,12 +14,14 @@
#include "module.h"
#include "modules/chanserv/log.h"
#include "modules/memoserv/service.h"
struct LogSettingImpl final
: LogSetting
: ChanServ::LogSetting
, Serializable
{
LogSettingImpl() : Serializable("LogSetting")
LogSettingImpl()
: Serializable(CHANSERV_LOG_SETTING_TYPE)
{
}
@@ -28,10 +30,10 @@ struct LogSettingImpl final
ChannelInfo *ci = ChannelInfo::Find(chan);
if (ci)
{
LogSettings *ls = ci->GetExt<LogSettings>("logsettings");
auto *ls = ci->GetExt<ChanServ::LogSettings>(CHANSERV_LOG_SETTING_EXT);
if (ls)
{
LogSettings::iterator it = std::find((*ls)->begin(), (*ls)->end(), this);
auto it = std::find((*ls)->begin(), (*ls)->end(), this);
if (it != (*ls)->end())
(*ls)->erase(it);
}
@@ -43,7 +45,7 @@ struct LogSettingTypeImpl final
: Serialize::Type
{
LogSettingTypeImpl()
: Serialize::Type("LogSetting")
: Serialize::Type(CHANSERV_LOG_SETTING_TYPE)
{
}
@@ -74,7 +76,7 @@ struct LogSettingTypeImpl final
ls = anope_dynamic_static_cast<LogSettingImpl *>(obj);
else
{
LogSettings *lsettings = ci->Require<LogSettings>("logsettings");
auto *lsettings = ci->Require<ChanServ::LogSettings>(CHANSERV_LOG_SETTING_EXT);
ls = new LogSettingImpl();
(*lsettings)->push_back(ls);
}
@@ -93,21 +95,21 @@ struct LogSettingTypeImpl final
};
struct LogSettingsImpl final
: LogSettings
: ChanServ::LogSettings
{
LogSettingsImpl(Extensible *) { }
~LogSettingsImpl() override
{
for (iterator it = (*this)->begin(); it != (*this)->end();)
for (auto it = (*this)->begin(); it != (*this)->end();)
{
LogSetting *ls = *it;
auto *ls = *it;
++it;
delete ls;
}
}
LogSetting *Create() override
ChanServ::LogSetting *Create() override
{
return new LogSettingImpl();
}
@@ -135,7 +137,7 @@ public:
source.Reply(ACCESS_DENIED);
else if (params.size() == 1)
{
LogSettings *ls = ci->Require<LogSettings>("logsettings");
auto *ls = ci->Require<ChanServ::LogSettings>(CHANSERV_LOG_SETTING_EXT);
if (!ls || (*ls)->empty())
source.Reply(_("There currently are no logging configurations for %s."), ci->name.c_str());
else
@@ -146,7 +148,7 @@ public:
for (unsigned i = 0; i < (*ls)->size(); ++i)
{
const LogSetting *log = (*ls)->at(i);
const auto *log = (*ls)->at(i);
ListFormatter::ListEntry entry;
entry["Number"] = Anope::ToString(i + 1);
@@ -168,7 +170,7 @@ public:
return;
}
LogSettings *ls = ci->Require<LogSettings>("logsettings");
auto *ls = ci->Require<ChanServ::LogSettings>(CHANSERV_LOG_SETTING_EXT);
const Anope::string &command = params[1];
const Anope::string &method = params[2];
const Anope::string &extra = params.size() > 3 ? params[3] : "";
@@ -224,7 +226,7 @@ public:
for (unsigned i = (*ls)->size(); i > 0; --i)
{
LogSetting *log = (*ls)->at(i - 1);
auto *log = (*ls)->at(i - 1);
if (log->service_name == service_name && log->method.equals_ci(method) && command_name.equals_ci(log->command_name))
{
@@ -300,7 +302,6 @@ public:
class CSLog final
: public Module
{
ServiceReference<MemoServService> MSService;
CommandCSLog commandcslog;
ExtensibleItem<LogSettingsImpl> logsettings;
LogSettingTypeImpl logsetting_type;
@@ -315,9 +316,8 @@ class CSLog final
public:
CSLog(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, MSService("MemoServService", "MemoServ")
, commandcslog(this)
, logsettings(this, "logsettings")
, logsettings(this, CHANSERV_LOG_SETTING_EXT)
{
}
@@ -345,7 +345,7 @@ public:
if (defaults.empty())
return;
LogSettings *ls = logsettings.Require(ci);
auto *ls = logsettings.Require(ci);
for (auto &d : defaults)
{
auto *log = new LogSettingImpl();
@@ -376,7 +376,7 @@ public:
if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced())
return;
LogSettings *ls = logsettings.Get(l->ci);
auto *ls = logsettings.Get(l->ci);
if (ls)
{
for (auto *log : *(*ls))
@@ -398,8 +398,8 @@ public:
Anope::string buffer = l->u->nick + " used " + l->source->command.upper() + " " + l->buf.str();
if (log->method.equals_ci("MEMO") && MSService && l->ci->WhoSends() != NULL)
MSService->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true);
if (log->method.equals_ci("MEMO") && MemoServ::service && l->ci->WhoSends() != NULL)
MemoServ::service->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true);
else if (l->source->c)
/* Sending a channel message or notice in response to a fantasy command */;
else if (log->method.equals_ci("MESSAGE") && l->ci->c)
+29 -26
View File
@@ -69,10 +69,11 @@ public:
};
struct ModeLockImpl final
: ModeLock
: ChanServ::ModeLock
, Serializable
{
ModeLockImpl() : Serializable("ModeLock")
ModeLockImpl()
: Serializable(CHANSERV_MODE_LOCK_TYPE)
{
}
@@ -81,7 +82,7 @@ struct ModeLockImpl final
ChannelInfo *chan = ChannelInfo::Find(ci);
if (chan)
{
ModeLocks *ml = chan->GetExt<ModeLocks>("modelocks");
auto *ml = chan->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (ml)
ml->RemoveMLock(this);
}
@@ -92,7 +93,7 @@ struct ModeLockTypeImpl final
: Serialize::Type
{
ModeLockTypeImpl()
: Serialize::Type("ModeLock")
: Serialize::Type(CHANSERV_MODE_LOCK_TYPE)
{
}
void Serialize(Serializable *obj, Serialize::Data &data) const override;
@@ -100,18 +101,20 @@ struct ModeLockTypeImpl final
};
struct ModeLocksImpl final
: ModeLocks
: ChanServ::ModeLocks
{
Serialize::Reference<ChannelInfo> ci;
Serialize::Checker<ModeList> mlocks;
Serialize::Checker<ChanServ::ModeLockList> mlocks;
ModeLocksImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), mlocks("ModeLock")
ModeLocksImpl(Extensible *obj)
: ci(anope_dynamic_static_cast<ChannelInfo *>(obj))
, mlocks(CHANSERV_MODE_LOCK_TYPE)
{
}
~ModeLocksImpl() override
{
ModeList modelist;
ChanServ::ModeLockList modelist;
mlocks->swap(modelist);
for (auto *ml : modelist)
{
@@ -193,38 +196,38 @@ struct ModeLocksImpl final
return false;
}
void RemoveMLock(ModeLock *mlock) override
void RemoveMLock(ChanServ::ModeLock *mlock) override
{
ModeList::iterator it = std::find(this->mlocks->begin(), this->mlocks->end(), mlock);
auto it = std::find(this->mlocks->begin(), this->mlocks->end(), mlock);
if (it != this->mlocks->end())
this->mlocks->erase(it);
}
void ClearMLock() override
{
ModeList ml;
ChanServ::ModeLockList ml;
this->mlocks->swap(ml);
for (const auto *lock : ml)
delete lock;
}
const ModeList &GetMLock() const override
const ChanServ::ModeLockList &GetMLock() const override
{
return this->mlocks;
}
std::list<ModeLock *> GetModeLockList(const Anope::string &name) override
std::list<ChanServ::ModeLock *> GetModeLockList(const Anope::string &name) override
{
std::list<ModeLock *> mlist;
std::list<ChanServ::ModeLock *> mlist;
for (auto *m : *this->mlocks)
{
if (m->name == name)
if (m->name == name)
mlist.push_back(m);
}
return mlist;
}
const ModeLock *GetMLock(const Anope::string &mname, const Anope::string &param = "") override
const ChanServ::ModeLock *GetMLock(const Anope::string &mname, const Anope::string &param = "") override
{
for (auto *m : *this->mlocks)
{
@@ -250,7 +253,7 @@ struct ModeLocksImpl final
void Check() override
{
if (this->mlocks->empty())
ci->Shrink<ModeLocks>("modelocks");
ci->Shrink<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
}
};
@@ -291,7 +294,7 @@ Serializable *ModeLockTypeImpl::Unserialize(Serializable *obj, Serialize::Data &
data["param"] >> ml->param;
if (!obj)
ci->Require<ModeLocksImpl>("modelocks")->mlocks->push_back(ml);
ci->Require<ModeLocksImpl>(CHANSERV_MODE_LOCK_EXT)->mlocks->push_back(ml);
return ml;
}
@@ -330,7 +333,7 @@ class CommandCSMode final
const Anope::string &param = params.size() > 3 ? params[3] : "";
bool override = !source.AccessFor(ci).HasPriv("MODE");
ModeLocks *modelocks = ci->Require<ModeLocks>("modelocks");
auto *modelocks = ci->Require<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (Anope::ReadOnly && !subcommand.equals_ci("LIST"))
{
@@ -343,7 +346,7 @@ class CommandCSMode final
/* If setting, remove the existing locks */
if (subcommand.equals_ci("SET"))
{
const ModeLocks::ModeList mlocks = modelocks->GetMLock();
const auto mlocks = modelocks->GetMLock();
for (auto *ml : mlocks)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
@@ -363,7 +366,7 @@ class CommandCSMode final
}
else if (subcommand.equals_ci("LIST"))
{
const ModeLocks::ModeList mlocks = modelocks->GetMLock();
const auto mlocks = modelocks->GetMLock();
if (mlocks.empty())
{
source.Reply(_("Channel %s has no mode locks."), ci->name.c_str());
@@ -401,7 +404,7 @@ class CommandCSMode final
this->OnSyntaxError(source, subcommand);
}
void DoLockChange(CommandSource &source, ChannelInfo *ci, ModeLocks *modelocks, const Anope::string &param, bool override, bool setting)
void DoLockChange(CommandSource &source, ChannelInfo *ci, ChanServ::ModeLocks *modelocks, const Anope::string &param, bool override, bool setting)
{
spacesepstream sep(param);
Anope::string modes;
@@ -992,7 +995,7 @@ public:
: Module(modname, creator, VENDOR)
, commandcsmode(this)
, commandcsmodes(this)
, modelocks(this, "modelocks")
, modelocks(this, CHANSERV_MODE_LOCK_EXT)
{
}
@@ -1025,7 +1028,7 @@ public:
if (!c || !c->ci)
return;
ModeLocks *locks = modelocks.Get(c->ci);
auto *locks = modelocks.Get(c->ci);
if (locks)
{
for (auto *ml : locks->GetMLock())
@@ -1072,7 +1075,7 @@ public:
void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *ml = modelocks.Require(ci);
ChanServ::ModeLocks *ml = modelocks.Require(ci);
Anope::string mlock;
spacesepstream sep(Config->GetModule(this).Get<const Anope::string>("mlock", "+nt"));
if (sep.GetToken(mlock))
@@ -1125,7 +1128,7 @@ public:
if (!show_hidden)
return;
ModeLocks *ml = modelocks.Get(ci);
auto *ml = modelocks.Get(ci);
if (ml)
info[_("Mode lock")] = ml->GetMLockAsString(true);
}
+2 -2
View File
@@ -536,7 +536,7 @@ public:
if (cm)
{
/* Add it to the channels mlock */
ModeLocks *ml = ci->Require<ModeLocks>("modelocks");
auto *ml = ci->Require<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (ml)
ml->SetMLock(cm, true, "", source.GetNick());
@@ -580,7 +580,7 @@ public:
if (cm)
{
/* Remove from mlock */
ModeLocks *ml = ci->GetExt<ModeLocks>("modelocks");
auto *ml = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (ml)
ml->RemoveMLock(cm, true);
+2 -2
View File
@@ -276,8 +276,8 @@ public:
if (topiclock.HasExt(ci))
info.AddOption(_("Topic lock"));
ModeLocks *ml = ci->GetExt<ModeLocks>("modelocks");
const ModeLock *secret = ml ? ml->GetMLock("SECRET") : NULL;
auto *ml = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
const auto *secret = ml ? ml->GetMLock("SECRET") : nullptr;
if (!ci->last_topic.empty() && (show_all || ((!secret || !secret->set) && (!ci->c || !ci->c->HasMode("SECRET")))))
{
info[_("Last topic")] = ci->last_topic;
+32 -32
View File
@@ -509,19 +509,19 @@ private:
if (!row)
return row.LogError(this);
if (!forbid_service)
if (!OperServ::forbid_service)
{
Log(this) << "Unable to convert forbidden email address " << email << " as os_forbid is not loaded";
return true;
}
auto *forbid = forbid_service->CreateForbid();
auto *forbid = OperServ::forbid_service->CreateForbid();
forbid->created = created;
forbid->creator = creator;
forbid->mask = email;
forbid->reason = reason;
forbid->type = FT_EMAIL;
forbid_service->AddForbid(forbid);
forbid->type = OperServ::FT_EMAIL;
OperServ::forbid_service->AddForbid(forbid);
return true;
}
@@ -570,21 +570,21 @@ private:
return false;
}
auto *bw = ci->Require<BadWords>("badwords");
auto *bw = ci->Require<BotServ::BadWords>(BOTSERV_BAD_WORDS_EXT);
if (!bw)
{
Log(this) << "Unable to import badwords for " << ci->name << " as bs_kick is not loaded";
return true;
}
auto *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (kd)
{
kd->badwords = true;
kd->ttb[TTB_BADWORDS] = 0;
kd->ttb[BotServ::TTB_BADWORDS] = 0;
}
bw->AddBadWord(badword, BW_ANY);
bw->AddBadWord(badword, BotServ::BW_ANY);
return true;
}
@@ -693,20 +693,20 @@ private:
if (!row)
return row.LogError(this);
if (!session_service)
if (!OperServ::session_service)
{
Log(this) << "Unable to import session limit for " << ip << " as os_session is not loaded";
return true;
}
auto *exception = session_service->CreateException();
auto *exception = OperServ::session_service->CreateException();
exception->mask = ip;
exception->limit = allowed;
exception->who = "Unknown";
exception->time = Anope::CurTime;
exception->expires = expires;
exception->reason = reason;
session_service->AddException(exception);
OperServ::session_service->AddException(exception);
return true;
}
@@ -752,7 +752,7 @@ private:
return false;
}
auto *hr = na->Require<HostRequest>("hostrequest");
auto *hr = na->Require<HostServ::HostRequest>(HOSTSERV_HOST_REQUEST_EXT);
if (!hr)
{
Log(this) << "Unable to convert host request for " << na->nick << " as hs_request is not loaded";
@@ -803,18 +803,18 @@ private:
if (!row)
return row.LogError(this);
if (!news_service)
if (!OperServ::news_service)
{
Log(this) << "Unable to convert logon news as os_news is not loaded";
return true;
}
auto *ni = news_service->CreateNewsItem();
ni->type = NEWS_LOGON;
auto *ni = OperServ::news_service->CreateNewsItem();
ni->type = OperServ::NEWS_LOGON;
ni->text = Anope::Format("[%s] %s", subject.c_str(), body.c_str());
ni->who = setter;
ni->time = ts;
news_service->AddNewsItem(ni);
OperServ::news_service->AddNewsItem(ni);
return true;
}
@@ -829,18 +829,18 @@ private:
if (!row)
return row.LogError(this);
if (!news_service)
if (!OperServ::news_service)
{
Log(this) << "Unable to convert oper news as os_news is not loaded";
return true;
}
auto *ni = news_service->CreateNewsItem();
ni->type = NEWS_OPER;
auto *ni = OperServ::news_service->CreateNewsItem();
ni->type = OperServ::NEWS_OPER;
ni->text = Anope::Format("[%s] %s", subject.c_str(), body.c_str());
ni->who = setter;
ni->time = ts;
news_service->AddNewsItem(ni);
OperServ::news_service->AddNewsItem(ni);
return true;
}
@@ -895,13 +895,13 @@ private:
pos = flags.find('f');
if (pos != Anope::string::npos)
{
auto *kd = ci->Require<KickerData>("kickerdata");
auto *kd = ci->Require<BotServ::KickerData>(BOTSERV_KICKER_DATA_EXT);
if (kd)
{
kd->flood = true;
kd->floodlines = 10;
kd->floodsecs = 60;
kd->ttb[TTB_FLOOD] = 0;
kd->ttb[BotServ::TTB_FLOOD] = 0;
flags.erase(pos, 1);
}
else
@@ -947,7 +947,7 @@ private:
return false;
}
auto *cl = nc->Require<NSCertList>("certificates");
auto *cl = nc->Require<NickServ::CertList>(NICKSERV_CERT_EXT);
if (!cl)
{
Log(this) << "Unable to convert certificate for " << nc->display << " as ns_cert is not loaded";
@@ -1023,7 +1023,7 @@ private:
data->suspend_ts = Anope::Convert<time_t>(value, 0);
else if (key == "private:entrymsg")
{
auto *eml = ci->Require<EntryMessageList>("entrymsg");
auto *eml = ci->Require<ChanServ::EntryMessageList>(CHANSERV_ENTRY_MESSAGE_EXT);
if (!eml)
{
Log(this) << "Unable to convert entry message for " << ci->name << " as cs_mode is not loaded";
@@ -1095,13 +1095,13 @@ private:
if (!row)
return row.LogError(this);
if (!forbid_service)
if (!OperServ::forbid_service)
{
Log(this) << "Unable to convert forbidden nick " << nick << " metadata as os_forbid is not loaded";
return true;
}
auto *forbid = forbid_service->FindForbidExact(nick, FT_NICK);
auto *forbid = OperServ::forbid_service->FindForbidExact(nick, OperServ::FT_NICK);
if (!forbid)
{
Log(this) << "Missing forbid for MDN: " << nick;
@@ -1425,18 +1425,18 @@ private:
if (!row)
return row.LogError(this);
if (!forbid_service)
if (!OperServ::forbid_service)
{
Log(this) << "Unable to convert forbidden nick " << nick << " as os_forbid is not loaded";
return true;
}
auto *forbid = forbid_service->CreateForbid();
auto *forbid = OperServ::forbid_service->CreateForbid();
forbid->creator = "Unknown";
forbid->mask = nick;
forbid->reason = "Unknown";
forbid->type = FT_NICK;
forbid_service->AddForbid(forbid);
forbid->type = OperServ::FT_NICK;
OperServ::forbid_service->AddForbid(forbid);
return true;
}
@@ -1498,7 +1498,7 @@ private:
return true;
}
nc->o = new MyOper(nc->display, ot);
nc->o = new OperServ::Oper(nc->display, ot);
return true;
}
@@ -1678,7 +1678,7 @@ public:
if (!data)
continue;
auto *ml = ci->Require<ModeLocks>("modelocks");
auto *ml = ci->Require<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (!ml)
{
Log(this) << "Unable to convert mode locks for " << ci->name << " as cs_mode is not loaded";
+7 -9
View File
@@ -13,18 +13,17 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/global/service.h"
class CommandGLGlobal final
: public Command
{
private:
ServiceReference<GlobalService> global;
BotInfo *GetSender(CommandSource &source)
{
Reference<BotInfo> sender;
if (global)
sender = global->GetDefaultSender();
if (Global::service)
sender = Global::service->GetDefaultSender();
if (!sender)
sender = source.service;
return sender;
@@ -33,7 +32,6 @@ private:
public:
CommandGLGlobal(Module *creator)
: Command(creator, "global/global", 0, 1)
, global("GlobalService", "Global")
{
this->SetDesc(_("Send a message to all users"));
this->SetSyntax(_("[\037message\037]"));
@@ -41,13 +39,13 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!global)
if (!Global::service)
{
source.Reply(SERVICE_UNAVAILABLE, source.service->nick.c_str());
return;
}
auto queuesize = global->CountQueue(source.nc);
auto queuesize = Global::service->CountQueue(source.nc);
if (!queuesize && params.empty())
{
source.Reply(GLOBAL_NO_MESSAGE);
@@ -63,12 +61,12 @@ public:
if (params.empty())
{
// We are sending the message queue.
global->SendQueue(source, GetSender(source));
Global::service->SendQueue(source, GetSender(source));
}
else
{
// We are sending a single message.
global->SendSingle(params[0], &source, GetSender(source));
Global::service->SendSingle(params[0], &source, GetSender(source));
queuesize = 1;
}
+12 -16
View File
@@ -13,6 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/global/service.h"
#define QUEUE_EMPTY _("You have no messages queued.")
@@ -21,13 +22,11 @@ class QueueDelCallback final
{
private:
unsigned deleted = 0;
ServiceReference<GlobalService> &global;
CommandSource &source;
public:
QueueDelCallback(CommandSource &src, ServiceReference<GlobalService>& gl, const Anope::string &list)
QueueDelCallback(CommandSource &src, const Anope::string &list)
: NumberList(list, true)
, global(gl)
, source(src)
{
}
@@ -42,10 +41,10 @@ public:
void HandleNumber(unsigned number) override
{
if (!number || number > global->CountQueue(source.nc))
if (!number || number > Global::service->CountQueue(source.nc))
return;
if (global->Unqueue(source.nc, number - 1))
if (Global::service->Unqueue(source.nc, number - 1))
deleted++;
}
};
@@ -54,8 +53,6 @@ class CommandGLQueue final
: public Command
{
private:
ServiceReference<GlobalService> global;
void DoAdd(CommandSource &source, const Anope::string &message)
{
if (message.empty())
@@ -65,26 +62,26 @@ private:
}
auto maxqueue = Config->GetModule(this->module).Get<size_t>("maxqueue", "10");
if (global->CountQueue(source.nc) >= maxqueue)
if (Global::service->CountQueue(source.nc) >= maxqueue)
{
source.Reply(_("You can not queue any more messages."));
return;
}
global->Queue(source.nc, message);
Global::service->Queue(source.nc, message);
source.Reply(_("Your message has been queued."));
Log(LOG_ADMIN, source, this) << "to queue: " << message;
}
void DoClear(CommandSource &source)
{
if (!global->CountQueue(source.nc))
if (!Global::service->CountQueue(source.nc))
{
source.Reply(_("You do not have any queued messages."));
return;
}
global->ClearQueue(source.nc);
Global::service->ClearQueue(source.nc);
source.Reply(_("Your message queue has been cleared."));
Log(LOG_ADMIN, source, this) << "to clear their queue.";
}
@@ -97,18 +94,18 @@ private:
return;
}
if (!global->CountQueue(source.nc))
if (!Global::service->CountQueue(source.nc))
{
source.Reply(QUEUE_EMPTY);
return;
}
QueueDelCallback(source, global, what).Process();
QueueDelCallback(source, what).Process();
}
void DoList(CommandSource &source)
{
const auto *q = global->GetQueue(source.nc);
const auto *q = Global::service->GetQueue(source.nc);
if (!q || q->empty())
{
source.Reply(QUEUE_EMPTY);
@@ -132,7 +129,6 @@ private:
public:
CommandGLQueue(Module *creator)
: Command(creator, "global/queue", 1, 2)
, global("GlobalService", "Global")
{
this->SetDesc(_("Manages your pending message queue."));
this->SetSyntax(_("ADD \037message\037"));
@@ -143,7 +139,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!global)
if (!Global::service)
{
source.Reply(SERVICE_UNAVAILABLE, source.service->nick.c_str());
return;
+7 -9
View File
@@ -13,18 +13,17 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/global/service.h"
class CommandGLServer final
: public Command
{
private:
ServiceReference<GlobalService> global;
BotInfo *GetSender(CommandSource &source)
{
Reference<BotInfo> sender;
if (global)
sender = global->GetDefaultSender();
if (Global::service)
sender = Global::service->GetDefaultSender();
if (!sender)
sender = source.service;
return sender;
@@ -33,7 +32,6 @@ private:
public:
CommandGLServer(Module *creator)
: Command(creator, "global/server", 1, 2)
, global("GlobalService", "Global")
{
this->SetDesc(_("Send a message to all users on a server"));
this->SetSyntax(_("\037server\037 [\037message\037]"));
@@ -41,7 +39,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!global)
if (!Global::service)
{
source.Reply(SERVICE_UNAVAILABLE, source.service->nick.c_str());
return;
@@ -54,7 +52,7 @@ public:
return;
}
auto queuesize = global->CountQueue(source.nc);
auto queuesize = Global::service->CountQueue(source.nc);
if (!queuesize && params.size() < 2)
{
source.Reply(GLOBAL_NO_MESSAGE);
@@ -70,12 +68,12 @@ public:
if (params.empty())
{
// We are sending the message queue.
global->SendQueue(source, GetSender(source), server);
Global::service->SendQueue(source, GetSender(source), server);
}
else
{
// We are sending a single message.
global->SendSingle(params[1], &source, GetSender(source), server);
Global::service->SendSingle(params[1], &source, GetSender(source), server);
queuesize = 1;
}
+3 -2
View File
@@ -13,10 +13,11 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/global/service.h"
class GlobalCore final
: public Module
, public GlobalService
, public Global::Service
{
private:
Reference<BotInfo> global;
@@ -37,7 +38,7 @@ private:
public:
GlobalCore(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, PSEUDOCLIENT | VENDOR)
, GlobalService(this)
, Global::Service(this)
, queue(this, "global-queue")
{
}
+21 -21
View File
@@ -15,9 +15,9 @@
#include "module.h"
#include "modules/dns.h"
#include "modules/hostserv/request.h"
#include "modules/memoserv/service.h"
static ServiceReference<DNS::Manager> dnsmanager("DNS::Manager", "dns/manager");
static ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vident, const Anope::string &vhost);
@@ -28,7 +28,7 @@ namespace
}
struct HostRequestImpl final
: HostRequest
: HostServ::HostRequest
, Serializable
{
HostRequestImpl(Extensible *)
@@ -38,7 +38,7 @@ struct HostRequestImpl final
static HostRequestImpl *Get(NickAlias *na)
{
return na ? na->GetExt<HostRequestImpl>("hostrequest") : nullptr;
return na ? na->GetExt<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT) : nullptr;
}
Anope::string Mask() const
@@ -86,7 +86,7 @@ struct HostRequestTypeImpl final
if (obj)
req = anope_dynamic_static_cast<HostRequestImpl *>(obj);
else
req = na->Extend<HostRequestImpl>("hostrequest");
req = na->Extend<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
if (req)
{
req->nick = na->nick;
@@ -122,7 +122,7 @@ private:
}
public:
DNSHostResolver(Command *cmd, HostRequest *hr, NickAlias *na, const CommandSource &src)
DNSHostResolver(Command *cmd, HostServ::HostRequest *hr, NickAlias *na, const CommandSource &src)
: Request(dnsmanager, cmd->module, hr->host, DNS::QUERY_TXT, false)
, command(cmd)
, nickalias(na)
@@ -169,12 +169,12 @@ public:
na->SetVHost(hr->ident, hr->host, source.GetNick(), hr->time);
FOREACH_MOD(OnSetVHost, (na));
if (Config->GetModule(command->module).Get<bool>("memouser") && memoserv)
memoserv->Send(source.service->nick, na->nick, _("Your requested vhost has been validated via DNS."), true);
if (Config->GetModule(command->module).Get<bool>("memouser") && MemoServ::service)
MemoServ::service->Send(source.service->nick, na->nick, _("Your requested vhost has been validated via DNS."), true);
source.Reply(_("VHost for %s has been validated using DNS."), na->nick.c_str());
Log(LOG_COMMAND, source, command) << "for " << na->nick << " for vhost " << hr->Mask();
na->Shrink<HostRequestImpl>("hostrequest");
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
return; // We're done.
}
@@ -281,7 +281,7 @@ public:
req.host = host;
req.time = Anope::CurTime;
req.validation_token = Anope::Random(Config->GetBlock("options").Get<size_t>("codelength", "15"));
na->Extend<HostRequestImpl>("hostrequest", req);
na->Extend<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT, req);
BotInfo *bi;
Anope::string cmd;
@@ -340,18 +340,18 @@ public:
const Anope::string &nick = params[0];
NickAlias *na = NickAlias::Find(nick);
HostRequestImpl *req = na ? na->GetExt<HostRequestImpl>("hostrequest") : NULL;
auto *req = HostRequestImpl::Get(na);
if (req)
{
na->SetVHost(req->ident, req->host, source.GetNick(), req->time);
FOREACH_MOD(OnSetVHost, (na));
if (Config->GetModule(this->owner).Get<bool>("memouser") && memoserv)
memoserv->Send(source.service->nick, na->nick, _("Your requested vhost has been approved."), true);
if (Config->GetModule(this->owner).Get<bool>("memouser") && MemoServ::service)
MemoServ::service->Send(source.service->nick, na->nick, _("Your requested vhost has been approved."), true);
source.Reply(_("VHost for %s has been activated."), na->nick.c_str());
Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host;
na->Shrink<HostRequestImpl>("hostrequest");
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
}
else
source.Reply(_("No request for nick %s found."), nick.c_str());
@@ -391,12 +391,12 @@ public:
const Anope::string &reason = params.size() > 1 ? params[1] : "";
NickAlias *na = NickAlias::Find(nick);
HostRequestImpl *req = na ? na->GetExt<HostRequestImpl>("hostrequest") : NULL;
auto *req = HostRequestImpl::Get(na);
if (req)
{
na->Shrink<HostRequestImpl>("hostrequest");
na->Shrink<HostRequestImpl>(HOSTSERV_HOST_REQUEST_EXT);
if (Config->GetModule(this->owner).Get<bool>("memouser") && memoserv)
if (Config->GetModule(this->owner).Get<bool>("memouser") && MemoServ::service)
{
Anope::string message;
if (!reason.empty())
@@ -404,7 +404,7 @@ public:
else
message = _("Your requested vhost has been rejected.");
memoserv->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
}
source.Reply(_("VHost for %s has been rejected."), nick.c_str());
@@ -446,7 +446,7 @@ public:
for (const auto &[nick, na] : *NickAliasList)
{
HostRequestImpl *hr = na->GetExt<HostRequestImpl>("hostrequest");
auto *hr = HostRequestImpl::Get(na);
if (!hr)
continue;
@@ -572,7 +572,7 @@ public:
, commandhsreject(this)
, commandhswaiting(this)
, commandhsvalidate(this)
, hostrequest(this, "hostrequest")
, hostrequest(this, HOSTSERV_HOST_REQUEST_EXT)
{
if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
@@ -594,7 +594,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin
else
host = vhost;
if (Config->GetModule(me).Get<bool>("memooper") && memoserv)
if (Config->GetModule(me).Get<bool>("memooper") && MemoServ::service)
{
for (auto *o : Oper::opers)
{
@@ -604,7 +604,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin
Anope::string message = Anope::Format(_("VHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str());
memoserv->Send(source.service->nick, na->nick, message, true);
MemoServ::service->Send(source.service->nick, na->nick, message, true);
}
}
}
+12 -10
View File
@@ -13,10 +13,11 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/memoserv/service.h"
class MemoServCore final
: public Module
, public MemoServService
, public MemoServ::Service
{
Reference<BotInfo> MemoServ;
@@ -37,18 +38,19 @@ class MemoServCore final
}
public:
MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
MemoServService(this)
MemoServCore(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, PSEUDOCLIENT | VENDOR)
, MemoServ::Service(this)
{
}
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override
MemoServ::MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) override
{
bool ischan;
MemoInfo *mi = MemoInfo::GetMemoInfo(target, ischan);
if (mi == NULL)
return MEMO_INVALID_TARGET;
return MemoServ::MEMO_INVALID_TARGET;
Anope::string sender_display = source;
@@ -59,13 +61,13 @@ public:
{
time_t send_delay = Config->GetModule("memoserv").Get<time_t>("senddelay");
if (send_delay > 0 && sender->lastmemosend + send_delay > Anope::CurTime)
return MEMO_TOO_FAST;
return MemoServ::MEMO_TOO_FAST;
else if (!mi->memomax)
return MEMO_TARGET_FULL;
return MemoServ::MEMO_TARGET_FULL;
else if (mi->memomax > 0 && mi->memos->size() >= static_cast<unsigned>(mi->memomax))
return MEMO_TARGET_FULL;
return MemoServ::MEMO_TARGET_FULL;
else if (mi->HasIgnore(sender))
return MEMO_SUCCESS;
return MemoServ::MEMO_SUCCESS;
}
NickCore *acc = sender->Account();
@@ -127,7 +129,7 @@ public:
SendMemoMail(nc, mi, m);
}
return MEMO_SUCCESS;
return MemoServ::MEMO_SUCCESS;
}
void Check(User *u) override
+3 -4
View File
@@ -13,13 +13,12 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ");
#include "modules/memoserv/service.h"
static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ)
{
/* Only send receipt if memos are allowed */
if (MemoServService && !Anope::ReadOnly)
if (MemoServ::service && !Anope::ReadOnly)
{
/* Get nick alias for sender */
const NickAlias *na = NickAlias::Find(m->sender);
@@ -38,7 +37,7 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Ano
Anope::string text = Anope::Format(Language::Translate(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")), targ.c_str());
/* Send notification */
MemoServService->Send(source.GetNick(), m->sender, text, true);
MemoServ::service->Send(source.GetNick(), m->sender, text, true);
/* Notify recipient of the memo that a notification has
been sent to the sender */
+7 -11
View File
@@ -13,11 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
namespace
{
ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
}
#include "modules/memoserv/service.h"
class CommandMSRSend final
: public Command
@@ -31,7 +27,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
if (!MemoServ::service)
return;
if (Anope::ReadOnly && !source.IsOper())
@@ -55,16 +51,16 @@ public:
source.Reply(ACCESS_DENIED);
else
{
MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text);
if (result == MemoServService::MEMO_INVALID_TARGET)
const auto result = MemoServ::service->Send(source.GetNick(), nick, text);
if (result == MemoServ::MEMO_INVALID_TARGET)
source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str());
else if (result == MemoServService::MEMO_TOO_FAST)
else if (result == MemoServ::MEMO_TOO_FAST)
{
auto lastmemosend = source.GetUser() ? source.GetUser()->lastmemosend : 0;
auto waitperiod = (lastmemosend + Config->GetModule("memoserv").Get<unsigned long>("senddelay")) - Anope::CurTime;
source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.nobreak().c_str());
}
else if (result == MemoServService::MEMO_TARGET_FULL)
else if (result == MemoServ::MEMO_TARGET_FULL)
source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str());
else
{
@@ -107,7 +103,7 @@ public:
MSRSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandmsrsend(this)
{
if (!memoserv)
if (!MemoServ::service)
throw ModuleException("No MemoServ!");
}
};
+8 -12
View File
@@ -13,11 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
namespace
{
ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
}
#include "modules/memoserv/service.h"
class CommandMSSend final
: public Command
@@ -31,7 +27,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
if (!MemoServ::service)
return;
const Anope::string &nick = params[0];
@@ -49,21 +45,21 @@ public:
return;
}
MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text);
if (result == MemoServService::MEMO_SUCCESS)
const auto result = MemoServ::service->Send(source.GetNick(), nick, text);
if (result == MemoServ::MEMO_SUCCESS)
{
source.Reply(_("Memo sent to \002%s\002."), nick.c_str());
Log(LOG_COMMAND, source, this) << "to send a memo to " << nick;
}
else if (result == MemoServService::MEMO_INVALID_TARGET)
else if (result == MemoServ::MEMO_INVALID_TARGET)
source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str());
else if (result == MemoServService::MEMO_TOO_FAST)
else if (result == MemoServ::MEMO_TOO_FAST)
{
auto lastmemosend = source.GetUser() ? source.GetUser()->lastmemosend : 0;
auto waitperiod = (lastmemosend + Config->GetModule("memoserv").Get<unsigned long>("senddelay")) - Anope::CurTime;
source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.nobreak().c_str());
}
else if (result == MemoServService::MEMO_TARGET_FULL)
else if (result == MemoServ::MEMO_TARGET_FULL)
source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str());
}
@@ -91,7 +87,7 @@ public:
commandmssend(this)
{
if (!memoserv)
if (!MemoServ::service)
throw ModuleException("No MemoServ!");
}
};
+4 -8
View File
@@ -13,11 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
namespace
{
ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
}
#include "modules/memoserv/service.h"
class CommandMSSendAll final
: public Command
@@ -31,7 +27,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
if (!MemoServ::service)
return;
const Anope::string &text = params[0];
@@ -41,7 +37,7 @@ public:
for (const auto &[_, nc] : *NickCoreList)
{
if (nc != source.nc)
memoserv->Send(source.GetNick(), nc->display, text);
MemoServ::service->Send(source.GetNick(), nc->display, text);
}
source.Reply(_("A massmemo has been sent to all registered users."));
@@ -65,7 +61,7 @@ public:
MSSendAll(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandmssendall(this)
{
if (!memoserv)
if (!MemoServ::service)
throw ModuleException("No MemoServ!");
}
};
+4 -8
View File
@@ -13,11 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
namespace
{
ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
}
#include "modules/memoserv/service.h"
class CommandMSStaff final
: public Command
@@ -31,7 +27,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!memoserv)
if (!MemoServ::service)
return;
const Anope::string &text = params[0];
@@ -39,7 +35,7 @@ public:
for (const auto &[_, nc] : *NickCoreList)
{
if (source.nc != nc && nc->IsServicesOper())
memoserv->Send(source.GetNick(), nc->display, text, true);
MemoServ::service->Send(source.GetNick(), nc->display, text, true);
}
}
@@ -62,7 +58,7 @@ public:
MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandmsstaff(this)
{
if (!memoserv)
if (!MemoServ::service)
throw ModuleException("No MemoServ!");
}
};
+12 -9
View File
@@ -13,6 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/nickserv/service.h"
#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. " \
"Passwords should not be something that could be easily guessed (e.g. your " \
@@ -31,15 +32,13 @@ static std::set<NickServCollide *> collides;
class NickServCollide final
: public Timer
{
NickServService *service;
Reference<User> u;
time_t ts;
Reference<NickAlias> na;
public:
NickServCollide(Module *me, NickServService *nss, User *user, NickAlias *nick, time_t delay)
NickServCollide(Module *me, User *user, NickAlias *nick, time_t delay)
: Timer(me, delay)
, service(nss)
, u(user)
, ts(user->timestamp)
, na(nick)
@@ -64,13 +63,14 @@ public:
void Tick() override
{
if (!u || !na)
if (!u || !na || !NickServ::service)
return;
/* If they identified or don't exist anymore, don't kill them. */
if (u->Account() == na->nc || u->timestamp > ts)
return;
service->Collide(u, na);
NickServ::service->Collide(u, na);
}
};
@@ -140,7 +140,7 @@ public:
class NickServCore final
: public Module
, public NickServService
, public NickServ::Service
{
Reference<BotInfo> NickServ;
std::vector<Anope::string> defaults;
@@ -162,8 +162,11 @@ class NickServCore final
}
public:
NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR),
NickServService(this), held(this, "HELD"), collided(this, "COLLIDED")
NickServCore(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, PSEUDOCLIENT | VENDOR)
, NickServ::Service(this)
, held(this, "HELD")
, collided(this, "COLLIDED")
{
}
@@ -242,7 +245,7 @@ public:
{
u->SendMessage(NickServ, _("Your nickname will be changed in %s if you do not identify."),
Anope::Duration(protect, u->Account()).c_str());
new NickServCollide(this, this, u, na, protect);
new NickServCollide(this, u, na, protect);
}
else
{
+19 -13
View File
@@ -18,9 +18,12 @@
static Anope::unordered_map<NickCore *> certmap;
struct CertServiceImpl final
: CertService
: NickServ::CertService
{
CertServiceImpl(Module *o) : CertService(o) { }
CertServiceImpl(Module *o)
: NickServ::CertService(o)
{
}
NickCore *FindAccountFromCert(const Anope::string &cert) override
{
@@ -36,14 +39,14 @@ struct CertServiceImpl final
if (!nc)
return;
auto *cl = nc->GetExt<NSCertList>("certificates");
auto *cl = nc->GetExt<NickServ::CertList>(NICKSERV_CERT_EXT);
if (cl)
cl->ReplaceCert(oldcert, newcert);
}
};
struct NSCertListImpl final
: NSCertList
: NickServ::CertList
{
Serialize::Reference<NickCore> nc;
std::vector<Anope::string> certs;
@@ -153,7 +156,7 @@ public:
void Check() override
{
if (this->certs.empty())
nc->Shrink<NSCertList>("certificates");
nc->Shrink<NickServ::CertList>(NICKSERV_CERT_EXT);
}
struct ExtensibleItem final
@@ -167,7 +170,7 @@ public:
return;
const NickCore *n = anope_dynamic_static_cast<const NickCore *>(e);
NSCertList *c = this->Get(n);
auto *c = this->Get(n);
if (c == NULL || !c->GetCertCount())
return;
@@ -183,7 +186,7 @@ public:
return;
NickCore *n = anope_dynamic_static_cast<NickCore *>(e);
NSCertListImpl *c = this->Require(n);
auto *c = this->Require(n);
Anope::string buf;
data["cert"] >> buf;
@@ -206,7 +209,7 @@ class CommandNSCert final
private:
void DoAdd(CommandSource &source, NickCore *nc, Anope::string certfp)
{
NSCertList *cl = nc->Require<NSCertList>("certificates");
auto *cl = nc->Require<NickServ::CertList>(NICKSERV_CERT_EXT);
unsigned max = Config->GetModule(this->owner).Get<unsigned>("max", "5");
if (cl->GetCertCount() >= max)
@@ -247,7 +250,7 @@ private:
void DoDel(CommandSource &source, NickCore *nc, Anope::string certfp)
{
NSCertList *cl = nc->Require<NSCertList>("certificates");
auto *cl = nc->Require<NickServ::CertList>(NICKSERV_CERT_EXT);
if (certfp.empty())
{
@@ -276,7 +279,7 @@ private:
static void DoList(CommandSource &source, const NickCore *nc)
{
NSCertList *cl = nc->GetExt<NSCertList>("certificates");
auto *cl = nc->GetExt<NickServ::CertList>(NICKSERV_CERT_EXT);
if (!cl || !cl->GetCertCount())
{
@@ -409,8 +412,11 @@ class NSCert final
}
public:
NSCert(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnscert(this), certs(this, "certificates"), cs(this)
NSCert(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, commandnscert(this)
, certs(this, NICKSERV_CERT_EXT)
, cs(this)
{
if (!IRCD || !IRCD->CanCertFP)
throw ModuleException("Your IRCd does not support ssl client certificates");
@@ -450,7 +456,7 @@ public:
EventReturn OnNickValidate(User *u, NickAlias *na) override
{
NSCertList *cl = certs.Get(na->nc);
auto *cl = certs.Get(na->nc);
if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint))
{
if (!CanLogin(u, na->nc))
+3 -4
View File
@@ -14,8 +14,7 @@
#include "module.h"
#include "modules/nickserv/cert.h"
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
#include "modules/nickserv/service.h"
class NSGroupRequest final
: public IdentifyRequest
@@ -168,7 +167,7 @@ public:
source.Reply(NICK_IDENTIFY_REQUIRED);
else if (maxaliases && target->nc->aliases->size() >= maxaliases && !target->nc->IsServicesOper())
source.Reply(_("There are too many nicks in your account."));
else if (nickserv && nickserv->IsGuestNick(source.GetNick()))
else if (NickServ::service && NickServ::service->IsGuestNick(source.GetNick()))
source.Reply(NICK_CANNOT_BE_REGISTERED, source.GetNick().c_str());
else
{
@@ -176,7 +175,7 @@ public:
if (!na && source.GetAccount() == target->nc)
ok = true;
NSCertList *cl = target->nc->GetExt<NSCertList>("certificates");
auto *cl = target->nc->GetExt<NickServ::CertList>(NICKSERV_CERT_EXT);
if (user != NULL && !user->fingerprint.empty() && cl && cl->FindCert(user->fingerprint))
ok = true;
+3 -4
View File
@@ -13,8 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
#include "modules/nickserv/service.h"
class CommandNSLogout final
: public Command
@@ -41,8 +40,8 @@ public:
source.Reply(_("You can't logout %s, they are a Services Operator."), nick.c_str());
else
{
if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServService)
NickServService->Validate(u2);
if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service)
NickServ::service->Validate(u2);
u2->super_admin = false; /* Don't let people logout and remain a SuperAdmin */
Log(LOG_COMMAND, source, this) << "to logout " << u2->nick;
+7 -8
View File
@@ -14,8 +14,7 @@
#include "module.h"
#include "modules/nickserv/cert.h"
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
#include "modules/nickserv/service.h"
typedef std::map<Anope::string, ChannelStatus> NSRecoverInfo;
@@ -53,7 +52,7 @@ public:
/* Nick is being held by us, release it */
if (na->HasExt("HELD"))
{
nickserv->Release(na);
NickServ::service->Release(na);
source.Reply(_("Services' hold on \002%s\002 has been released."), na->nick.c_str());
}
else if (!u)
@@ -114,14 +113,14 @@ public:
svs->to = u->nick;
}
if (nickserv)
nickserv->Collide(u, na);
if (NickServ::service)
NickServ::service->Collide(u, na);
if (IRCD->CanSVSNick)
{
/* If we can svsnick then release our hold and svsnick the user using the command */
if (nickserv)
nickserv->Release(na);
if (NickServ::service)
NickServ::service->Release(na);
source.Reply(_("You have regained control of \002%s\002."), u->nick.c_str());
}
@@ -189,7 +188,7 @@ public:
if (source.GetAccount() == na->nc)
ok = true;
NSCertList *cl = na->nc->GetExt<NSCertList>("certificates");
auto *cl = na->nc->GetExt<NickServ::CertList>(NICKSERV_CERT_EXT);
if (source.GetUser() && !source.GetUser()->fingerprint.empty() && cl && cl->FindCert(source.GetUser()->fingerprint))
ok = true;
+2 -3
View File
@@ -13,6 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/nickserv/service.h"
namespace
{
@@ -30,8 +31,6 @@ namespace
static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi);
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
class CommandNSRegister final
: public Command
{
@@ -76,7 +75,7 @@ public:
return;
}
if (nickserv && nickserv->IsGuestNick(u_nick))
if (NickServ::service && NickServ::service->IsGuestNick(u_nick))
{
source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str());
return;
+3 -6
View File
@@ -20,8 +20,6 @@ class External final
: public SASL::Mechanism
{
private:
ServiceReference<CertService> certs;
struct Session final
: SASL::Session
{
@@ -36,7 +34,6 @@ private:
public:
External(Module *o)
: SASL::Mechanism(o, "EXTERNAL")
, certs("CertService", "certs")
{
}
@@ -59,18 +56,18 @@ public:
}
else if (m.type == "C")
{
if (!certs || mysess->certs.empty())
if (!NickServ::cert_service || mysess->certs.empty())
return false;
for (auto it = mysess->certs.begin(); it != mysess->certs.end(); ++it)
{
auto *nc = certs->FindAccountFromCert(*it);
auto *nc = NickServ::cert_service->FindAccountFromCert(*it);
if (nc && !nc->HasExt("NS_SUSPENDED") && !nc->HasExt("UNCONFIRMED"))
{
// If we are using a fallback cert then upgrade it.
if (it != mysess->certs.begin())
{
auto *cl = nc->GetExt<NSCertList>("certificates");
auto *cl = nc->GetExt<NickServ::CertList>(NICKSERV_CERT_EXT);
if (cl)
cl->ReplaceCert(*it, mysess->certs[0]);
}
+3 -4
View File
@@ -13,10 +13,9 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/nickserv/service.h"
#include "modules/suspend.h"
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
struct NSSuspendInfo final
: SuspendInfo
, Serializable
@@ -144,8 +143,8 @@ public:
IRCD->SendLogout(u2);
u2->RemoveMode(source.service, "REGISTERED");
u2->Logout();
if (nickserv)
nickserv->Collide(u2, na2);
if (NickServ::service)
NickServ::service->Collide(u2, na2);
}
}
}
+7 -5
View File
@@ -13,6 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/nickserv/service.h"
class SGLineManager final
: public XLineManager
@@ -70,10 +71,11 @@ public:
class SQLineManager final
: public XLineManager
{
ServiceReference<NickServService> nickserv;
public:
SQLineManager(Module *creator) : XLineManager(creator, "xlinemanager/sqline", 'Q'), nickserv("NickServService", "NickServ") { }
SQLineManager(Module *creator)
: XLineManager(creator, "xlinemanager/sqline", 'Q')
{
}
void OnMatch(User *u, XLine *x) override
{
@@ -91,8 +93,8 @@ public:
{
if (!u)
;
else if (nickserv)
nickserv->Collide(u, NULL);
else if (NickServ::service)
NickServ::service->Collide(u, NULL);
else
u->Kill(Config->GetClient("OperServ"), "Q-Lined: " + x->reason);
}
+16 -15
View File
@@ -13,6 +13,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/global/service.h"
#include "modules/operserv/session.h"
enum DefconLevel
@@ -104,8 +105,6 @@ static DefconConfig DConfig;
static void runDefCon();
static Anope::string defconReverseModes(const Anope::string &modes);
static ServiceReference<GlobalService> GlobalService("GlobalService", "Global");
static Timer *timeout;
class DefConTimeout final
@@ -134,15 +133,15 @@ public:
FOREACH_MOD(OnDefconLevel, (level));
Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level;
if (DConfig.globalondefcon)
if (DConfig.globalondefcon && Global::service)
{
if (!DConfig.offmessage.empty())
GlobalService->SendSingle(DConfig.offmessage);
Global::service->SendSingle(DConfig.offmessage);
else
GlobalService->SendSingle(Anope::Format(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel));
Global::service->SendSingle(Anope::Format(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel));
if (!DConfig.message.empty())
GlobalService->SendSingle(DConfig.message);
Global::service->SendSingle(DConfig.message);
}
runDefCon();
@@ -217,15 +216,15 @@ public:
/* Global notice the user what is happening. Also any Message that
the Admin would like to add. Set in config file. */
if (DConfig.globalondefcon)
if (DConfig.globalondefcon && Global::service)
{
if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty())
GlobalService->SendSingle(DConfig.offmessage);
Global::service->SendSingle(DConfig.offmessage);
else if (DConfig.defaultlevel != 5)
{
GlobalService->SendSingle(Anope::Format(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel));
Global::service->SendSingle(Anope::Format(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel));
if (!DConfig.message.empty())
GlobalService->SendSingle(DConfig.message);
Global::service->SendSingle(DConfig.message);
}
}
@@ -249,7 +248,6 @@ public:
class OSDefcon final
: public Module
{
ServiceReference<SessionService> session_service;
ServiceReference<XLineManager> akills;
CommandOSDefcon commandosdefcon;
@@ -330,7 +328,10 @@ class OSDefcon final
}
public:
OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), session_service("SessionService", "session"), akills("XLineManager", "xlinemanager/sgline"), commandosdefcon(this)
OSDefcon(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, akills("XLineManager", "xlinemanager/sgline")
, commandosdefcon(this)
{
}
@@ -505,11 +506,11 @@ public:
return;
}
if (DConfig.sessionlimit <= 0 || !session_service)
if (DConfig.sessionlimit <= 0 || !OperServ::session_service)
return;
Session *session = session_service->FindSession(u->ip.addr());
Exception *exception = session_service->FindException(u);
auto *session = OperServ::session_service->FindSession(u->ip.addr());
auto *exception = OperServ::session_service->FindException(u);
if (DConfig.Check(DEFCON_REDUCE_SESSION) && !exception)
{
+82 -77
View File
@@ -13,59 +13,62 @@
// SPDX-License-Identifier: GPL-2.0-only
#include "module.h"
#include "modules/chanserv/service.h"
#include "modules/nickserv/service.h"
#include "modules/operserv/forbid.h"
namespace
{
Anope::string TypeToString(ForbidType ft)
Anope::string TypeToString(OperServ::ForbidType ft)
{
switch (ft)
{
case FT_NICK:
case OperServ::FT_NICK:
return "NICK";
case FT_CHAN:
case OperServ::FT_CHAN:
return "CHAN";
case FT_EMAIL:
case OperServ::FT_EMAIL:
return "EMAIL";
case FT_REGISTER:
case OperServ::FT_REGISTER:
return "REGISTER";
case FT_PASSWORD:
case OperServ::FT_PASSWORD:
return "PASSWORD";
default:
return "UNKNOWN"; // Should never happen.
}
}
ForbidType StringToType(const Anope::string &ft)
OperServ::ForbidType StringToType(const Anope::string &ft)
{
if (ft.equals_ci("NICK") || ft.equals_ci("1"))
return FT_NICK;
return OperServ::FT_NICK;
if (ft.equals_ci("CHAN") || ft.equals_ci("2"))
return FT_CHAN;
return OperServ::FT_CHAN;
if (ft.equals_ci("EMAIL") || ft.equals_ci("3"))
return FT_EMAIL;
return OperServ::FT_EMAIL;
if (ft.equals_ci("REGISTER") || ft.equals_ci("4"))
return FT_REGISTER;
return OperServ::FT_REGISTER;
if (ft.equals_ci("PASSWORD"))
return FT_PASSWORD;
return OperServ::FT_PASSWORD;
return FT_SIZE; // Should never happen.
return OperServ::FT_SIZE; // Should never happen.
}
}
static ServiceReference<NickServService> nickserv("NickServService", "NickServ");
struct ForbidDataImpl final
: ForbidData
: OperServ::ForbidData
, Serializable
{
ForbidDataImpl() : Serializable("ForbidData") { }
ForbidDataImpl()
: Serializable(OPERSERV_FORBID_DATA_TYPE)
{
}
};
struct ForbidDataFile final
: ForbidData
: OperServ::ForbidData
{
ForbidDataFile(ForbidType t, const Anope::string &c, const Anope::string &m, const Anope::string &r)
ForbidDataFile(OperServ::ForbidType t, const Anope::string &c, const Anope::string &m, const Anope::string &r)
{
created = Anope::CurTime;
creator = c;
@@ -80,7 +83,7 @@ struct ForbidDataTypeImpl final
: Serialize::Type
{
ForbidDataTypeImpl()
: Serialize::Type("ForbidData")
: Serialize::Type(OPERSERV_FORBID_DATA_TYPE)
{
}
@@ -101,7 +104,7 @@ void ForbidDataTypeImpl::Serialize(Serializable *obj, Serialize::Data &data) con
Serializable *ForbidDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
{
if (!forbid_service)
if (!OperServ::forbid_service)
return NULL;
ForbidDataImpl *fb;
@@ -119,30 +122,34 @@ Serializable *ForbidDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data
data["type"] >> t;
fb->type = StringToType(t);
if (fb->type == FT_SIZE)
if (fb->type == OperServ::FT_SIZE)
return NULL;
if (!obj)
forbid_service->AddForbid(fb);
OperServ::forbid_service->AddForbid(fb);
return fb;
}
class MyForbidService final
: public ForbidService
: public OperServ::ForbidService
{
Serialize::Checker<std::vector<ForbidData *>[FT_SIZE - 1]> forbid_data;
Serialize::Checker<std::vector<OperServ::ForbidData *>[OperServ::FT_SIZE - 1]> forbid_data;
inline std::vector<ForbidData *>& forbids(unsigned t) { return (*this->forbid_data)[t - 1]; }
inline std::vector<OperServ::ForbidData *>& forbids(unsigned t) { return (*this->forbid_data)[t - 1]; }
void Expire(ForbidData *fd, unsigned ft, size_t idx)
void Expire(OperServ::ForbidData *fd, unsigned ft, size_t idx)
{
Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << fd->mask << " type " << TypeToString(static_cast<ForbidType>(ft));
Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << fd->mask << " type " << TypeToString(static_cast<OperServ::ForbidType>(ft));
this->forbids(ft).erase(this->forbids(ft).begin() + idx);
delete fd;
}
public:
MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { }
MyForbidService(Module *m)
: OperServ::ForbidService(m)
, forbid_data(OPERSERV_FORBID_DATA_TYPE)
{
}
~MyForbidService() override
{
@@ -150,29 +157,29 @@ public:
delete forbid;
}
void AddForbid(ForbidData *d) override
void AddForbid(OperServ::ForbidData *d) override
{
this->forbids(d->type).push_back(d);
}
void RemoveForbid(ForbidData *d) override
void RemoveForbid(OperServ::ForbidData *d) override
{
std::vector<ForbidData *>::iterator it = std::find(this->forbids(d->type).begin(), this->forbids(d->type).end(), d);
auto it = std::find(this->forbids(d->type).begin(), this->forbids(d->type).end(), d);
if (it != this->forbids(d->type).end())
this->forbids(d->type).erase(it);
delete d;
}
ForbidData *CreateForbid() override
OperServ::ForbidData *CreateForbid() override
{
return new ForbidDataImpl();
}
ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) override
OperServ::ForbidData *FindForbid(const Anope::string &mask, OperServ::ForbidType ftype) override
{
for (unsigned i = this->forbids(ftype).size(); i > 0; --i)
{
ForbidData *d = this->forbids(ftype)[i - 1];
auto *d = this->forbids(ftype)[i - 1];
if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
{
@@ -186,11 +193,11 @@ public:
return NULL;
}
ForbidData *FindForbidExact(const Anope::string &mask, ForbidType ftype) override
OperServ::ForbidData *FindForbidExact(const Anope::string &mask, OperServ::ForbidType ftype) override
{
for (unsigned i = this->forbids(ftype).size(); i > 0; --i)
{
ForbidData *d = this->forbids(ftype)[i - 1];
auto *d = this->forbids(ftype)[i - 1];
if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
{
@@ -204,13 +211,13 @@ public:
return NULL;
}
std::vector<ForbidData *> GetForbids() override
std::vector<OperServ::ForbidData *> GetForbids() override
{
std::vector<ForbidData *> f;
for (unsigned j = FT_NICK; j < FT_SIZE; ++j)
std::vector<OperServ::ForbidData *> f;
for (unsigned j = OperServ::FT_NICK; j < OperServ::FT_SIZE; ++j)
for (unsigned i = this->forbids(j).size(); i > 0; --i)
{
ForbidData *d = this->forbids(j).at(i - 1);
auto *d = this->forbids(j).at(i - 1);
if (d->expires && !Anope::NoExpire && Anope::CurTime >= d->expires)
Expire(d, j, i - 1);
@@ -225,9 +232,9 @@ public:
class CommandOSForbid final
: public Command
{
ServiceReference<ForbidService> fs;
public:
CommandOSForbid(Module *creator) : Command(creator, "operserv/forbid", 1, 5), fs("ForbidService", "forbid")
CommandOSForbid(Module *creator)
: Command(creator, "operserv/forbid", 1, 5)
{
this->SetDesc(_("Forbid usage of nicknames, channels, and emails"));
this->SetSyntax(_("ADD {CHAN|EMAIL|NICK|PASSWORD|REGISTER} [+\037expiry\037] \037entry\037 \037reason\037"));
@@ -237,14 +244,14 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
if (!this->fs)
if (!OperServ::forbid_service)
return;
const Anope::string &command = params[0];
const Anope::string &subcommand = params.size() > 1 ? params[1] : "";
auto ftype = StringToType(subcommand);
if (command.equals_ci("ADD") && params.size() > 3 && ftype != FT_SIZE)
if (command.equals_ci("ADD") && params.size() > 3 && ftype != OperServ::FT_SIZE)
{
const Anope::string &expiry = params[2][0] == '+' ? params[2] : "";
const Anope::string &entry = !expiry.empty() ? params[3] : params[2];
@@ -282,7 +289,7 @@ public:
return;
}
ForbidData *d = this->fs->FindForbidExact(entry, ftype);
auto *d = OperServ::forbid_service->FindForbidExact(entry, ftype);
bool created = false;
if (d == NULL)
{
@@ -297,7 +304,7 @@ public:
d->expires = expiryt;
d->type = ftype;
if (created)
this->fs->AddForbid(d);
OperServ::forbid_service->AddForbid(d);
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
@@ -308,7 +315,7 @@ public:
/* apply forbid */
switch (ftype)
{
case FT_NICK:
case OperServ::FT_NICK:
{
int na_matches = 0;
@@ -320,7 +327,7 @@ public:
NickAlias *na = it->second;
++it;
d = this->fs->FindForbid(na->nick, FT_NICK);
d = OperServ::forbid_service->FindForbid(na->nick, OperServ::FT_NICK);
if (d == NULL)
continue;
@@ -332,7 +339,7 @@ public:
source.Reply(na_matches, N_("\002%d\002 nickname dropped.", "\002%d\002 nicknames dropped."), na_matches);
break;
}
case FT_CHAN:
case OperServ::FT_CHAN:
{
int chan_matches = 0, ci_matches = 0;
@@ -341,11 +348,10 @@ public:
Channel *c = it->second;
++it;
d = this->fs->FindForbid(c->name, FT_CHAN);
d = OperServ::forbid_service->FindForbid(c->name, OperServ::FT_CHAN);
if (d == NULL)
continue;
ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ");
BotInfo *OperServ = Config->GetClient("OperServ");
if (IRCD->CanSQLineChannel && OperServ)
{
@@ -353,9 +359,9 @@ public:
XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->reason);
IRCD->SendSQLine(NULL, &x);
}
else if (chanserv)
else if (ChanServ::service)
{
chanserv->Hold(c);
ChanServ::service->Hold(c);
}
++chan_matches;
@@ -379,7 +385,7 @@ public:
ChannelInfo *ci = it->second;
++it;
d = this->fs->FindForbid(ci->name, FT_CHAN);
d = OperServ::forbid_service->FindForbid(ci->name, OperServ::FT_CHAN);
if (d == NULL)
continue;
@@ -397,11 +403,11 @@ public:
}
}
else if (command.equals_ci("DEL") && params.size() > 2 && ftype != FT_SIZE)
else if (command.equals_ci("DEL") && params.size() > 2 && ftype != OperServ::FT_SIZE)
{
const Anope::string &entry = params[2];
ForbidData *d = this->fs->FindForbidExact(entry, ftype);
auto *d = OperServ::forbid_service->FindForbidExact(entry, ftype);
if (d != NULL)
{
if (Anope::ReadOnly)
@@ -412,7 +418,7 @@ public:
{
Log(LOG_ADMIN, source, this) << "to remove forbid on " << d->mask << " of type " << subcommand;
source.Reply(_("%s deleted from the %s forbid list."), d->mask.c_str(), subcommand.c_str());
this->fs->RemoveForbid(d);
OperServ::forbid_service->RemoveForbid(d);
}
}
else
@@ -420,7 +426,7 @@ public:
}
else if (command.equals_ci("LIST"))
{
const std::vector<ForbidData *> &forbids = this->fs->GetForbids();
const auto &forbids = OperServ::forbid_service->GetForbids();
if (forbids.empty())
source.Reply(_("Forbid list is empty."));
else
@@ -437,11 +443,11 @@ public:
size_t shown = 0;
for (auto *forbid : forbids)
{
if (ftype != FT_SIZE && ftype != forbid->type)
if (ftype != OperServ::FT_SIZE && ftype != forbid->type)
continue;
auto stype = TypeToString(forbid->type);
if (stype == FT_SIZE)
if (stype == OperServ::FT_SIZE)
continue;
ListFormatter::ListEntry entry;
@@ -505,7 +511,7 @@ private:
MyForbidService forbidService;
ForbidDataTypeImpl forbiddata_type;
CommandOSForbid commandosforbid;
std::vector<ForbidData *> fileforbids;
std::vector<OperServ::ForbidData *> fileforbids;
public:
OSForbid(const Anope::string &modname, const Anope::string &creator)
@@ -530,7 +536,7 @@ public:
const auto typestr = fileblock.Get<const Anope::string>("type");
auto type = StringToType(typestr);
if (type == FT_SIZE)
if (type == OperServ::FT_SIZE)
{
Log(this) << "Unknown forbid file type: " << typestr << ", ignoring.";
continue;
@@ -577,7 +583,7 @@ public:
if (u->HasMode("OPER"))
return;
ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK);
auto *d = this->forbidService.FindForbid(u->nick, OperServ::FT_NICK);
if (d != NULL)
{
BotInfo *bi = Config->GetClient("NickServ");
@@ -585,8 +591,8 @@ public:
bi = Config->GetClient("OperServ");
if (bi)
u->SendMessage(bi, _("This nickname has been forbidden: %s"), d->reason.c_str());
if (nickserv)
nickserv->Collide(u, NULL);
if (NickServ::service)
NickServ::service->Collide(u, NULL);
}
}
@@ -596,19 +602,18 @@ public:
if (u->HasMode("OPER") || !OperServ)
return EVENT_CONTINUE;
ForbidData *d = this->forbidService.FindForbid(c->name, FT_CHAN);
auto *d = this->forbidService.FindForbid(c->name, OperServ::FT_CHAN);
if (d != NULL)
{
ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ");
if (IRCD->CanSQLineChannel)
{
time_t inhabit = Config->GetModule("chanserv").Get<time_t>("inhabit", "1m");
XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->reason);
IRCD->SendSQLine(NULL, &x);
}
else if (chanserv)
else if (ChanServ::service)
{
chanserv->Hold(c);
ChanServ::service->Hold(c);
}
reason = Anope::Format(Language::Translate(u, _("This channel has been forbidden: %s")), d->reason.c_str());
@@ -621,7 +626,7 @@ public:
EventReturn OnPasswordValidate(CommandSource &source, NickCore *nc, const Anope::string &pass) override
{
const auto* forbid = this->forbidService.FindForbid(pass, FT_PASSWORD);
const auto* forbid = this->forbidService.FindForbid(pass, OperServ::FT_PASSWORD);
if (forbid != nullptr)
{
if (source.IsOper())
@@ -637,7 +642,7 @@ public:
{
if (command->name == "nickserv/info" && !params.empty() && params[0][0] != '=')
{
ForbidData *d = this->forbidService.FindForbid(params[0], FT_NICK);
auto *d = this->forbidService.FindForbid(params[0], OperServ::FT_NICK);
if (d != NULL)
{
if (source.IsOper())
@@ -649,7 +654,7 @@ public:
}
else if (command->name == "chanserv/info" && params.size() > 0)
{
ForbidData *d = this->forbidService.FindForbid(params[0], FT_CHAN);
auto *d = this->forbidService.FindForbid(params[0], OperServ::FT_CHAN);
if (d != NULL)
{
if (source.IsOper())
@@ -663,14 +668,14 @@ public:
return EVENT_CONTINUE;
else if (command->name == "nickserv/register" && params.size() > 1)
{
ForbidData *d = this->forbidService.FindForbid(source.GetNick(), FT_REGISTER);
auto *d = this->forbidService.FindForbid(source.GetNick(), OperServ::FT_REGISTER);
if (d != NULL)
{
source.Reply(NICK_CANNOT_BE_REGISTERED, source.GetNick().c_str());
return EVENT_STOP;
}
d = this->forbidService.FindForbid(params[1], FT_EMAIL);
d = this->forbidService.FindForbid(params[1], OperServ::FT_EMAIL);
if (d != NULL)
{
source.Reply(_("Your email address is not allowed, choose a different one."));
@@ -679,7 +684,7 @@ public:
}
else if (command->name == "nickserv/set/email" && params.size() > 0)
{
ForbidData *d = this->forbidService.FindForbid(params[0], FT_EMAIL);
auto *d = this->forbidService.FindForbid(params[0], OperServ::FT_EMAIL);
if (d != NULL)
{
source.Reply(_("Your email address is not allowed, choose a different one."));
@@ -688,7 +693,7 @@ public:
}
else if (command->name == "chanserv/register" && !params.empty())
{
ForbidData *d = this->forbidService.FindForbid(params[0], FT_REGISTER);
auto *d = this->forbidService.FindForbid(params[0], OperServ::FT_REGISTER);
if (d != NULL)
{
source.Reply(CHAN_X_INVALID, params[0].c_str());
+36 -29
View File
@@ -16,24 +16,27 @@
#include "modules/operserv/ignore.h"
struct IgnoreDataImpl final
: IgnoreData
: OperServ::IgnoreData
, Serializable
{
IgnoreDataImpl() : Serializable("IgnoreData") { }
IgnoreDataImpl()
: Serializable(OPERSERV_IGNORE_DATA_TYPE)
{
}
~IgnoreDataImpl() override;
};
IgnoreDataImpl::~IgnoreDataImpl()
{
if (ignore_service)
ignore_service->DelIgnore(this);
if (OperServ::ignore_service)
OperServ::ignore_service->DelIgnore(this);
}
struct IgnoreDataTypeImpl final
: public Serialize::Type
{
IgnoreDataTypeImpl()
: Serialize::Type("IgnoreData")
: Serialize::Type(OPERSERV_IGNORE_DATA_TYPE)
{
}
void Serialize(Serializable *obj, Serialize::Data &data) const override;
@@ -51,7 +54,7 @@ void IgnoreDataTypeImpl::Serialize(Serializable *obj, Serialize::Data &data) con
Serializable *IgnoreDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
{
if (!ignore_service)
if (!OperServ::ignore_service)
return NULL;
IgnoreDataImpl *ign;
@@ -60,7 +63,7 @@ Serializable *IgnoreDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data
else
{
ign = new IgnoreDataImpl();
ignore_service->AddIgnore(ign);
OperServ::ignore_service->AddIgnore(ign);
}
data["mask"] >> ign->mask;
@@ -73,21 +76,25 @@ Serializable *IgnoreDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data
class OSIgnoreService final
: public IgnoreService
: public OperServ::IgnoreService
{
Serialize::Checker<std::vector<IgnoreData *> > ignores;
Serialize::Checker<std::vector<OperServ::IgnoreData *>> ignores;
public:
OSIgnoreService(Module *o) : IgnoreService(o), ignores("IgnoreData") { }
OSIgnoreService(Module *o)
: OperServ::IgnoreService(o)
, ignores(OPERSERV_IGNORE_DATA_TYPE)
{
}
void AddIgnore(IgnoreData *ign) override
void AddIgnore(OperServ::IgnoreData *ign) override
{
ignores->push_back(ign);
}
void DelIgnore(IgnoreData *ign) override
void DelIgnore(OperServ::IgnoreData *ign) override
{
std::vector<IgnoreData *>::iterator it = std::find(ignores->begin(), ignores->end(), ign);
auto it = std::find(ignores->begin(), ignores->end(), ign);
if (it != ignores->end())
ignores->erase(it);
}
@@ -96,20 +103,20 @@ public:
{
for (unsigned i = ignores->size(); i > 0; --i)
{
IgnoreData *ign = ignores->at(i - 1);
auto *ign = ignores->at(i - 1);
delete ign;
}
}
IgnoreData *Create() override
OperServ::IgnoreData *Create() override
{
return new IgnoreDataImpl();
}
IgnoreData *Find(const Anope::string &mask) override
OperServ::IgnoreData *Find(const Anope::string &mask) override
{
User *u = User::Find(mask, true);
std::vector<IgnoreData *>::iterator ign = this->ignores->begin(), ign_end = this->ignores->end();
auto ign = this->ignores->begin(), ign_end = this->ignores->end();
if (u)
{
@@ -150,7 +157,7 @@ public:
/* Check whether the entry has timed out */
if (ign != ign_end)
{
IgnoreData *id = *ign;
auto *id = *ign;
if (id->time && !Anope::NoExpire && id->time <= Anope::CurTime)
{
@@ -164,7 +171,7 @@ public:
return NULL;
}
std::vector<IgnoreData *> &GetIgnores() override
std::vector<OperServ::IgnoreData *> &GetIgnores() override
{
return *ignores;
}
@@ -206,7 +213,7 @@ private:
void DoAdd(CommandSource &source, const std::vector<Anope::string> &params)
{
if (!ignore_service)
if (!OperServ::ignore_service)
return;
const Anope::string &time = params.size() > 1 ? params[1] : "";
@@ -244,7 +251,7 @@ private:
ign->reason = reason;
ign->time = t ? Anope::CurTime + t : 0;
ignore_service->AddIgnore(ign);
OperServ::ignore_service->AddIgnore(ign);
if (!t)
{
source.Reply(_("\002%s\002 will now permanently be ignored."), mask.c_str());
@@ -260,13 +267,13 @@ private:
static void DoList(CommandSource &source)
{
if (!ignore_service)
if (!OperServ::ignore_service)
return;
std::vector<IgnoreData *> &ignores = ignore_service->GetIgnores();
auto &ignores = OperServ::ignore_service->GetIgnores();
for (unsigned i = ignores.size(); i > 0; --i)
{
IgnoreData *id = ignores[i - 1];
auto *id = ignores[i - 1];
if (id->time && !Anope::NoExpire && id->time <= Anope::CurTime)
{
@@ -290,7 +297,7 @@ private:
for (unsigned i = ignores.size(); i > 0; --i)
{
const IgnoreData *ignore = ignores[i - 1];
const auto *ignore = ignores[i - 1];
ListFormatter::ListEntry entry;
entry["Mask"] = ignore->mask;
@@ -307,7 +314,7 @@ private:
void DoDel(CommandSource &source, const std::vector<Anope::string> &params)
{
if (!ignore_service)
if (!OperServ::ignore_service)
return;
const Anope::string nick = params.size() > 1 ? params[1] : "";
@@ -324,7 +331,7 @@ private:
return;
}
IgnoreData *ign = ignore_service->Find(mask);
auto *ign = OperServ::ignore_service->Find(mask);
if (ign)
{
if (Anope::ReadOnly)
@@ -340,13 +347,13 @@ private:
void DoClear(CommandSource &source)
{
if (!ignore_service)
if (!OperServ::ignore_service)
return;
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
ignore_service->ClearIgnores();
OperServ::ignore_service->ClearIgnores();
Log(LOG_ADMIN, source, this) << "to CLEAR the list";
source.Reply(_("Ignore list has been cleared."));
}
+56 -57
View File
@@ -22,30 +22,30 @@
namespace
{
Anope::string TypeToString(NewsType nt)
Anope::string TypeToString(OperServ::NewsType nt)
{
switch (nt)
{
case NEWS_LOGON:
case OperServ::NEWS_LOGON:
return "LOGON";
case NEWS_RANDOM:
case OperServ::NEWS_RANDOM:
return "RANDOM";
case NEWS_OPER:
case OperServ::NEWS_OPER:
return "OPER";
}
return ""; // Should never happen.
}
NewsType StringToType(const Anope::string &nt)
OperServ::NewsType StringToType(const Anope::string &nt)
{
if (nt.equals_ci("LOGON") || nt.equals_ci("0"))
return NEWS_LOGON;
return OperServ::NEWS_LOGON;
if (nt.equals_ci("RANDOM") || nt.equals_ci("1"))
return NEWS_RANDOM;
return OperServ::NEWS_RANDOM;
if (nt.equals_ci("OPER") || nt.equals_ci("2"))
return NEWS_OPER;
return OperServ::NEWS_OPER;
return NEWS_LOGON; // Should never happen.
return OperServ::NEWS_LOGON; // Should never happen.
}
}
@@ -64,13 +64,13 @@ enum
struct NewsMessages final
{
NewsType type;
OperServ::NewsType type;
Anope::string name;
const char *msgs[MSG_END];
};
struct NewsMessages msgarray[] = {
{NEWS_LOGON, "LOGON",
{OperServ::NEWS_LOGON, "LOGON",
{_("[\002Logon News\002] %s"),
_("[\002Logon News\002 - %s] %s"),
_("Logon news items:"),
@@ -80,7 +80,7 @@ struct NewsMessages msgarray[] = {
_("Logon news item #%u deleted."),
_("All logon news items deleted.")}
},
{NEWS_OPER, "OPER",
{OperServ::NEWS_OPER, "OPER",
{_("[\002Oper News\002] %s"),
_("[\002Oper News\002 - %s] %s"),
_("Oper news items:"),
@@ -90,7 +90,7 @@ struct NewsMessages msgarray[] = {
_("Oper news item #%u deleted."),
_("All oper news items deleted.")}
},
{NEWS_RANDOM, "RANDOM",
{OperServ::NEWS_RANDOM, "RANDOM",
{_("[\002Random News\002] %s"),
_("[\002Random News\002 - %s] %s"),
_("Random news items:"),
@@ -106,13 +106,13 @@ struct NewsItemType final
: Serialize::Type
{
NewsItemType()
: Serialize::Type("NewsItem")
: Serialize::Type(OPERSERV_NEWS_ITEM_TYPE)
{
}
void Serialize(Serializable *obj, Serialize::Data &data) const override
{
const auto *ni = static_cast<const NewsItem *>(obj);
const auto *ni = static_cast<const OperServ::NewsItem *>(obj);
data.Store("type", TypeToString(ni->type));
data.Store("text", ni->text);
data.Store("who", ni->who);
@@ -121,14 +121,14 @@ struct NewsItemType final
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
if (!news_service)
if (!OperServ::news_service)
return NULL;
NewsItem *ni;
OperServ::NewsItem *ni;
if (obj)
ni = anope_dynamic_static_cast<NewsItem *>(obj);
ni = anope_dynamic_static_cast<OperServ::NewsItem *>(obj);
else
ni = new NewsItem();
ni = new OperServ::NewsItem();
Anope::string t;
data["type"] >> t;
@@ -138,15 +138,15 @@ struct NewsItemType final
data["time"] >> ni->time;
if (!obj)
news_service->AddNewsItem(ni);
OperServ::news_service->AddNewsItem(ni);
return ni;
}
};
class MyNewsService final
: public NewsService
: public OperServ::NewsService
{
std::vector<NewsItem *> newsItems[3];
std::vector<OperServ::NewsItem *> newsItems[3];
public:
MyNewsService(Module *m) : NewsService(m) { }
@@ -159,33 +159,33 @@ public:
}
}
NewsItem *CreateNewsItem() override
OperServ::NewsItem *CreateNewsItem() override
{
return new NewsItem();
return new OperServ::NewsItem();
}
void AddNewsItem(NewsItem *n) override
void AddNewsItem(OperServ::NewsItem *n) override
{
this->newsItems[n->type].push_back(n);
}
void DelNewsItem(NewsItem *n) override
void DelNewsItem(OperServ::NewsItem *n) override
{
std::vector<NewsItem *> &list = this->GetNewsList(n->type);
std::vector<NewsItem *>::iterator it = std::find(list.begin(), list.end(), n);
auto &list = this->GetNewsList(n->type);
auto it = std::find(list.begin(), list.end(), n);
if (it != list.end())
list.erase(it);
delete n;
}
std::vector<NewsItem *> &GetNewsList(NewsType t) override
std::vector<OperServ::NewsItem *> &GetNewsList(OperServ::NewsType t) override
{
return this->newsItems[t];
}
};
#define lenof(a) (sizeof(a) / sizeof(*(a)))
static const char **findmsgs(NewsType type)
static const char **findmsgs(OperServ::NewsType type)
{
for (auto &msg : msgarray)
if (msg.type == type)
@@ -196,12 +196,10 @@ static const char **findmsgs(NewsType type)
class NewsBase
: public Command
{
ServiceReference<NewsService> ns;
protected:
void DoList(CommandSource &source, NewsType ntype, const char **msgs)
void DoList(CommandSource &source, OperServ::NewsType ntype, const char **msgs)
{
std::vector<NewsItem *> &list = this->ns->GetNewsList(ntype);
auto &list = OperServ::news_service->GetNewsList(ntype);
if (list.empty())
source.Reply(msgs[MSG_LIST_NONE]);
else
@@ -226,7 +224,7 @@ protected:
}
}
void DoAdd(CommandSource &source, const std::vector<Anope::string> &params, NewsType ntype, const char **msgs)
void DoAdd(CommandSource &source, const std::vector<Anope::string> &params, OperServ::NewsType ntype, const char **msgs)
{
const Anope::string text = params.size() > 1 ? params[1] : "";
@@ -237,20 +235,20 @@ protected:
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
NewsItem *news = new NewsItem();
auto *news = new OperServ::NewsItem();
news->type = ntype;
news->text = text;
news->time = Anope::CurTime;
news->who = source.GetNick();
this->ns->AddNewsItem(news);
OperServ::news_service->AddNewsItem(news);
source.Reply(msgs[MSG_ADDED]);
Log(LOG_ADMIN, source, this) << "to add a news item";
}
}
void DoDel(CommandSource &source, const std::vector<Anope::string> &params, NewsType ntype, const char **msgs)
void DoDel(CommandSource &source, const std::vector<Anope::string> &params, OperServ::NewsType ntype, const char **msgs)
{
const Anope::string &text = params.size() > 1 ? params[1] : "";
@@ -258,7 +256,7 @@ protected:
this->OnSyntaxError(source, "DEL");
else
{
std::vector<NewsItem *> &list = this->ns->GetNewsList(ntype);
auto list = OperServ::news_service->GetNewsList(ntype);
if (list.empty())
source.Reply(msgs[MSG_LIST_NONE]);
else
@@ -270,7 +268,7 @@ protected:
unsigned num = Anope::Convert<unsigned>(text, 0);
if (num > 0 && num <= list.size())
{
this->ns->DelNewsItem(list[num - 1]);
OperServ::news_service->DelNewsItem(list[num - 1]);
source.Reply(msgs[MSG_DELETED], num);
Log(LOG_ADMIN, source, this) << "to delete a news item";
return;
@@ -281,7 +279,7 @@ protected:
else
{
for (unsigned i = list.size(); i > 0; --i)
this->ns->DelNewsItem(list[i - 1]);
OperServ::news_service->DelNewsItem(list[i - 1]);
source.Reply(msgs[MSG_DELETED_ALL]);
Log(LOG_ADMIN, source, this) << "to delete all news items";
}
@@ -289,9 +287,9 @@ protected:
}
}
void DoNews(CommandSource &source, const std::vector<Anope::string> &params, NewsType ntype)
void DoNews(CommandSource &source, const std::vector<Anope::string> &params, OperServ::NewsType ntype)
{
if (!this->ns)
if (!OperServ::news_service)
return;
const Anope::string &cmd = params[0];
@@ -310,7 +308,8 @@ protected:
this->OnSyntaxError(source, "");
}
public:
NewsBase(Module *creator, const Anope::string &newstype) : Command(creator, newstype, 1, 2), ns("NewsService", "news")
NewsBase(Module *creator, const Anope::string &newstype)
: Command(creator, newstype, 1, 2)
{
this->SetSyntax(_("ADD \037text\037"));
this->SetSyntax(_("DEL {\037num\037 | ALL}"));
@@ -337,7 +336,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_LOGON);
return this->DoNews(source, params, OperServ::NEWS_LOGON);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -367,7 +366,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_OPER);
return this->DoNews(source, params, OperServ::NEWS_OPER);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -397,7 +396,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
return this->DoNews(source, params, NEWS_RANDOM);
return this->DoNews(source, params, OperServ::NEWS_RANDOM);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -428,15 +427,15 @@ class OSNews final
Anope::string oper_announcer, announcer;
unsigned news_count;
void DisplayNews(User *u, NewsType Type)
void DisplayNews(User *u, OperServ::NewsType Type)
{
std::vector<NewsItem *> &newsList = this->newsservice.GetNewsList(Type);
auto &newsList = this->newsservice.GetNewsList(Type);
if (newsList.empty())
return;
const auto &modconf = Config->GetModule(this);
BotInfo *bi = NULL;
if (Type == NEWS_OPER)
if (Type == OperServ::NEWS_OPER)
bi = BotInfo::Find(modconf.Get<const Anope::string>("oper_announcer", "OperServ"), true);
else
bi = BotInfo::Find(modconf.Get<const Anope::string>("announcer", "Global"), true);
@@ -449,7 +448,7 @@ class OSNews final
int start = 0;
if (Type != NEWS_RANDOM)
if (Type != OperServ::NEWS_RANDOM)
{
start = newsList.size() - news_count;
if (start < 0)
@@ -459,7 +458,7 @@ class OSNews final
const auto showdate = modconf.Get<bool>("showdate", "yes");
for (unsigned i = start, end = newsList.size(); i < end; ++i)
{
if (Type == NEWS_RANDOM && i != cur_rand_news)
if (Type == OperServ::NEWS_RANDOM && i != cur_rand_news)
continue;
const auto *news = newsList[i];
@@ -468,7 +467,7 @@ class OSNews final
else
u->SendMessage(bi, msgs[MSG_NEWS_SHORT], news->text.c_str());
if (Type == NEWS_RANDOM)
if (Type == OperServ::NEWS_RANDOM)
{
++cur_rand_news;
break;
@@ -476,7 +475,7 @@ class OSNews final
}
/* Reset to head of list to get first random news value */
if (Type == NEWS_RANDOM && cur_rand_news >= newsList.size())
if (Type == OperServ::NEWS_RANDOM && cur_rand_news >= newsList.size())
cur_rand_news = 0;
}
@@ -500,7 +499,7 @@ public:
void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override
{
if (mname == "OPER")
DisplayNews(u, NEWS_OPER);
DisplayNews(u, OperServ::NEWS_OPER);
}
void OnUserConnect(User *user, bool &) override
@@ -508,8 +507,8 @@ public:
if (user->Quitting() || !user->server->IsSynced())
return;
DisplayNews(user, NEWS_LOGON);
DisplayNews(user, NEWS_RANDOM);
DisplayNews(user, OperServ::NEWS_LOGON);
DisplayNews(user, OperServ::NEWS_RANDOM);
}
};
+8 -8
View File
@@ -19,13 +19,13 @@ struct OSOperType
: Serialize::Type
{
OSOperType()
: Serialize::Type("Oper")
: Serialize::Type(OPERSERV_OPER_TYPE)
{
}
void Serialize(Serializable *obj, Serialize::Data &data) const override
{
const auto *myo = static_cast<const MyOper *>(obj);
const auto *myo = static_cast<const OperServ::Oper *>(obj);
data.Store("name", myo->name);
data.Store("type", myo->ot->GetName());
}
@@ -44,11 +44,11 @@ struct OSOperType
if (nc == NULL)
return NULL;
MyOper *myo;
OperServ::Oper *myo;
if (obj)
myo = anope_dynamic_static_cast<MyOper *>(obj);
myo = anope_dynamic_static_cast<OperServ::Oper *>(obj);
else
myo = new MyOper(nc->display, ot);
myo = new OperServ::Oper(nc->display, ot);
nc->o = myo;
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
return myo;
@@ -121,7 +121,7 @@ public:
return;
}
na->nc->o = new MyOper(na->nc->display, ot);
na->nc->o = new OperServ::Oper(na->nc->display, ot);
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
@@ -280,7 +280,7 @@ public:
{
for (const auto &[_, nc] : *NickCoreList)
{
if (nc->o && dynamic_cast<MyOper *>(nc->o))
if (nc->o && dynamic_cast<OperServ::Oper *>(nc->o))
{
delete nc->o;
nc->o = NULL;
@@ -290,7 +290,7 @@ public:
void OnDelCore(NickCore *nc) override
{
if (nc->o && dynamic_cast<MyOper *>(nc->o))
if (nc->o && dynamic_cast<OperServ::Oper *>(nc->o))
{
delete nc->o;
nc->o = NULL;
+56 -50
View File
@@ -42,13 +42,13 @@ struct ExceptionType final
: public Serialize::Type
{
ExceptionType()
: Serialize::Type("Exception")
: Serialize::Type(OPERSERV_SESSION_EXCEPTION_TYPE)
{
}
void Serialize(Serializable *obj, Serialize::Data &data) const override
{
const auto *ex = static_cast<const Exception *>(obj);
const auto *ex = static_cast<const OperServ::Exception *>(obj);
data.Store("mask", ex->mask);
data.Store("limit", ex->limit);
data.Store("who", ex->who);
@@ -58,14 +58,14 @@ struct ExceptionType final
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
if (!session_service)
if (!OperServ::session_service)
return NULL;
Exception *ex;
OperServ::Exception *ex;
if (obj)
ex = anope_dynamic_static_cast<Exception *>(obj);
ex = anope_dynamic_static_cast<OperServ::Exception *>(obj);
else
ex = new Exception;
ex = new OperServ::Exception();
data["mask"] >> ex->mask;
data["limit"] >> ex->limit;
data["who"] >> ex->who;
@@ -74,37 +74,43 @@ struct ExceptionType final
data["expires"] >> ex->expires;
if (!obj)
session_service->AddException(ex);
OperServ::session_service->AddException(ex);
return ex;
}
};
class MySessionService final
: public SessionService
: public OperServ::SessionService
{
SessionMap Sessions;
Serialize::Checker<ExceptionVector> Exceptions;
public:
MySessionService(Module *m) : SessionService(m), Exceptions("Exception") { }
private:
OperServ::SessionMap Sessions;
Serialize::Checker<OperServ::ExceptionVector> Exceptions;
Exception *CreateException() override
public:
MySessionService(Module *m)
: OperServ::SessionService(m)
, Exceptions(OPERSERV_SESSION_EXCEPTION_TYPE)
{
return new Exception();
}
void AddException(Exception *e) override
OperServ::Exception *CreateException() override
{
return new OperServ::Exception();
}
void AddException(OperServ::Exception *e) override
{
this->Exceptions->push_back(e);
}
void DelException(Exception *e) override
void DelException(OperServ::Exception *e) override
{
ExceptionVector::iterator it = std::find(this->Exceptions->begin(), this->Exceptions->end(), e);
auto it = std::find(this->Exceptions->begin(), this->Exceptions->end(), e);
if (it != this->Exceptions->end())
this->Exceptions->erase(it);
}
Exception *FindException(User *u) override
OperServ::Exception *FindException(User *u) override
{
for (auto *e : *this->Exceptions)
{
@@ -117,7 +123,7 @@ public:
return NULL;
}
Exception *FindException(const Anope::string &host) override
OperServ::Exception *FindException(const Anope::string &host) override
{
for (auto *e : *this->Exceptions)
{
@@ -131,28 +137,28 @@ public:
return NULL;
}
ExceptionVector &GetExceptions() override
OperServ::ExceptionVector &GetExceptions() override
{
return this->Exceptions;
}
void DelSession(Session *s)
void DelSession(OperServ::Session *s)
{
this->Sessions.erase(s->addr);
}
Session *FindSession(const Anope::string &ip) override
OperServ::Session *FindSession(const Anope::string &ip) override
{
cidr c(ip, ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr);
if (!c.valid())
return NULL;
SessionMap::iterator it = this->Sessions.find(c);
auto it = this->Sessions.find(c);
if (it != this->Sessions.end())
return it->second;
return NULL;
}
SessionMap::iterator FindSessionIterator(const sockaddrs &ip)
OperServ::SessionMap::iterator FindSessionIterator(const sockaddrs &ip)
{
cidr c(ip, ip.ipv6() ? ipv6_cidr : ipv4_cidr);
if (!c.valid())
@@ -160,12 +166,12 @@ public:
return this->Sessions.find(c);
}
Session *&FindOrCreateSession(const cidr &ip)
OperServ::Session *&FindOrCreateSession(const cidr &ip)
{
return this->Sessions[ip];
}
SessionMap &GetSessions() override
OperServ::SessionMap &GetSessions() override
{
return this->Sessions;
}
@@ -204,10 +210,10 @@ public:
void HandleNumber(unsigned number) override
{
if (!number || number > session_service->GetExceptions().size())
if (!number || number > OperServ::session_service->GetExceptions().size())
return;
lastdeleted = session_service->GetExceptions()[number - 1]->mask;
lastdeleted = OperServ::session_service->GetExceptions()[number - 1]->mask;
Log(LOG_ADMIN, source, cmd) << "to remove the session limit exception for " << lastdeleted;
++deleted;
@@ -216,10 +222,10 @@ public:
static void DoDel(CommandSource &source, unsigned index)
{
Exception *e = session_service->GetExceptions()[index];
auto *e = OperServ::session_service->GetExceptions()[index];
FOREACH_MOD(OnExceptionDel, (source, e));
session_service->DelException(e);
OperServ::session_service->DelException(e);
delete e;
}
};
@@ -241,7 +247,7 @@ private:
list.AddColumn(_("Session")).AddColumn(_("Host"));
list.SetFlexible(_("\002{host}\002: {session} sessions"));
for (const auto &[_, session] : session_service->GetSessions())
for (const auto &[_, session] : OperServ::session_service->GetSessions())
{
if (session->count >= mincount)
{
@@ -260,9 +266,9 @@ private:
static void DoView(CommandSource &source, const std::vector<Anope::string> &params)
{
Anope::string param = params[1];
Session *session = session_service->FindSession(param);
auto *session = OperServ::session_service->FindSession(param);
Exception *exception = session_service->FindException(param);
auto *exception = OperServ::session_service->FindException(param);
Anope::string entry = "no entry";
unsigned limit = session_limit;
if (exception)
@@ -386,7 +392,7 @@ private:
return;
}
for (auto *e : session_service->GetExceptions())
for (auto *e : OperServ::session_service->GetExceptions())
{
if (e->mask.equals_ci(mask))
{
@@ -401,7 +407,7 @@ private:
}
}
auto *exception = new Exception();
auto *exception = new OperServ::Exception();
exception->mask = mask;
exception->limit = limit;
exception->reason = reason;
@@ -416,7 +422,7 @@ private:
else
{
Log(LOG_ADMIN, source, this) << "to set the session limit for " << mask << " to " << limit;
session_service->AddException(exception);
OperServ::session_service->AddException(exception);
source.Reply(_("Session limit for \002%s\002 set to \002%d\002."), mask.c_str(), limit);
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
@@ -441,9 +447,9 @@ private:
}
else
{
unsigned i = 0, end = session_service->GetExceptions().size();
unsigned i = 0, end = OperServ::session_service->GetExceptions().size();
for (; i < end; ++i)
if (mask.equals_ci(session_service->GetExceptions()[i]->mask))
if (mask.equals_ci(OperServ::session_service->GetExceptions()[i]->mask))
{
Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << mask;
ExceptionDelCallback::DoDel(source, i);
@@ -462,7 +468,7 @@ private:
{
const Anope::string &mask = params.size() > 1 ? params[1] : "";
if (session_service->GetExceptions().empty())
if (OperServ::session_service->GetExceptions().empty())
{
source.Reply(_("The session exception list is empty."));
return;
@@ -482,10 +488,10 @@ private:
void HandleNumber(unsigned Number) override
{
if (!Number || Number > session_service->GetExceptions().size())
if (!Number || Number > OperServ::session_service->GetExceptions().size())
return;
Exception *e = session_service->GetExceptions()[Number - 1];
auto *e = OperServ::session_service->GetExceptions()[Number - 1];
ListFormatter::ListEntry entry;
entry["Number"] = Anope::ToString(Number);
@@ -503,9 +509,9 @@ private:
}
else
{
for (unsigned i = 0, end = session_service->GetExceptions().size(); i < end; ++i)
for (unsigned i = 0, end = OperServ::session_service->GetExceptions().size(); i < end; ++i)
{
Exception *e = session_service->GetExceptions()[i];
auto *e = OperServ::session_service->GetExceptions()[i];
if (mask.empty() || Anope::Match(e->mask, mask))
{
ListFormatter::ListEntry entry;
@@ -675,7 +681,7 @@ public:
if (!u_ip.valid())
return;
Session *&session = this->ss.FindOrCreateSession(u_ip);
auto *&session = this->ss.FindOrCreateSession(u_ip);
if (session)
{
@@ -683,7 +689,7 @@ public:
if (session->count >= session_limit)
{
kill = true;
Exception *exception = this->ss.FindException(u);
auto *exception = this->ss.FindException(u);
if (exception)
{
kill = false;
@@ -735,7 +741,7 @@ public:
}
else
{
session = new Session(u->ip, u->ip.ipv6() ? ipv6_cidr : ipv4_cidr);
session = new OperServ::Session(u->ip, u->ip.ipv6() ? ipv6_cidr : ipv4_cidr);
}
}
@@ -744,13 +750,13 @@ public:
if (!session_limit || !u->server || u->server->IsULined())
return;
SessionService::SessionMap &sessions = this->ss.GetSessions();
SessionService::SessionMap::iterator sit = this->ss.FindSessionIterator(u->ip);
auto &sessions = this->ss.GetSessions();
auto sit = this->ss.FindSessionIterator(u->ip);
if (sit == sessions.end())
return;
Session *session = sit->second;
auto *session = sit->second;
if (session->count > 1)
{
@@ -768,7 +774,7 @@ public:
return;
for (unsigned i = this->ss.GetExceptions().size(); i > 0; --i)
{
Exception *e = this->ss.GetExceptions()[i - 1];
auto *e = this->ss.GetExceptions()[i - 1];
if (!e->expires || e->expires > Anope::CurTime)
continue;
+2 -2
View File
@@ -183,9 +183,9 @@ private:
GetHashStats(*NickCoreList, entries, buckets, max_chain);
source.Reply(_("Registered accounts: %zu entries, %zu buckets, longest chain is %zu"), entries, buckets, max_chain);
if (session_service)
if (OperServ::session_service)
{
GetHashStats(session_service->GetSessions(), entries, buckets, max_chain);
GetHashStats(OperServ::session_service->GetSessions(), entries, buckets, max_chain);
source.Reply(_("Sessions: %zu entries, %zu buckets, longest chain is %zu"), entries, buckets, max_chain);
}
}
+6 -6
View File
@@ -443,7 +443,7 @@ struct IRCDMessageMLock final
if (c && c->ci)
{
ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = c->ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
Anope::string modes;
if (modelocks)
@@ -804,7 +804,7 @@ public:
if (!c->ci)
return;
ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = c->ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (modelocks && Servers::Capab.count("MLOCK"))
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -818,9 +818,9 @@ public:
Uplink::Send("MLOCK", ci->c->created, ci->name, Anope::CurTime, "");
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK"))
{
@@ -831,9 +831,9 @@ public:
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnUnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK"))
{
+8 -10
View File
@@ -1755,7 +1755,6 @@ class IRCDMessageMetadata final
: IRCDMessage
{
private:
ServiceReference<CertService> certs;
PrimitiveExtensibleItem<ListLimits> &maxlist;
ExtensibleItem<bool> ssl;
@@ -1827,7 +1826,7 @@ private:
return; // Not registered.
Anope::string modes;
const auto *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
const auto *modelocks = c->ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (modelocks)
modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -1920,8 +1919,8 @@ private:
FOREACH_MOD(OnFingerprint, (u));
// Any extra fingerprints are using backup algorithms.
while (certs && fingerprints.GetToken(data))
certs->ReplaceCert(data, u->fingerprint);
while (NickServ::cert_service && fingerprints.GetToken(data))
NickServ::cert_service->ReplaceCert(data, u->fingerprint);
}
static void HandleTopicLock(Channel *c, const Anope::string &value)
@@ -1939,7 +1938,6 @@ private:
public:
IRCDMessageMetadata(Module *creator, PrimitiveExtensibleItem<ListLimits> &listlimits)
: IRCDMessage(creator, "METADATA", 2)
, certs("CertService", "certs")
, maxlist(listlimits)
, ssl(creator, "ssl")
{
@@ -2523,7 +2521,7 @@ public:
void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (ci->c && modelocks && !modelocks->GetMLockAsString(false).empty())
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -2543,9 +2541,9 @@ public:
SendChannelMetadata(ci->c, "topiclock", "");
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM))
{
@@ -2556,9 +2554,9 @@ public:
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnUnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM))
{
+5 -5
View File
@@ -597,7 +597,7 @@ public:
if (!c->ci)
return;
ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = c->ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (modelocks && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -605,9 +605,9 @@ public:
}
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
@@ -618,9 +618,9 @@ public:
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnUnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
+6 -6
View File
@@ -1868,7 +1868,7 @@ public:
if (!c->ci)
return;
ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = c->ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (Servers::Capab.count("MLOCK") > 0 && modelocks)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -1878,7 +1878,7 @@ public:
void OnChanRegistered(ChannelInfo *ci) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
if (!ci->c || !modelocks || !Servers::Capab.count("MLOCK"))
return;
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
@@ -1892,9 +1892,9 @@ public:
Uplink::Send("MLOCK", ci->c->created, ci->name, "");
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
@@ -1905,9 +1905,9 @@ public:
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) override
EventReturn OnUnMLock(ChannelInfo *ci, ChanServ::ModeLock *lock) override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
auto *modelocks = ci->GetExt<ChanServ::ModeLocks>(CHANSERV_MODE_LOCK_EXT);
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
+8 -18
View File
@@ -32,26 +32,22 @@ enum
class MessageNetworkRPCEvent final
: public RPC::Event
{
private:
ServiceReference<GlobalService> &global;
public:
MessageNetworkRPCEvent(Module *o, ServiceReference<GlobalService> &g)
MessageNetworkRPCEvent(Module *o)
: RPC::Event(o, "anope.messageNetwork", 1)
, global(g)
{
}
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
{
if (!global)
if (!Global::service)
{
request.Error(ERR_NO_GLOBAL_SERVICE, "No global service");
return true;
}
for (const auto &message : request.data)
global->SendSingle(message);
Global::service->SendSingle(message);
return true;
}
};
@@ -59,19 +55,15 @@ public:
class MessageServerRPCEvent final
: public RPC::Event
{
private:
ServiceReference<GlobalService> &global;
public:
MessageServerRPCEvent(Module *o, ServiceReference<GlobalService> &g)
MessageServerRPCEvent(Module *o)
: RPC::Event(o, "anope.messageServer", 2)
, global(g)
{
}
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
{
if (!global)
if (!Global::service)
{
request.Error(ERR_NO_GLOBAL_SERVICE, "No global service");
return true;
@@ -86,7 +78,7 @@ public:
std::vector<Anope::string> messages(request.data.begin() + 1, request.data.end());
for (const auto &message : messages)
global->SendSingle(message, nullptr, nullptr, s);
Global::service->SendSingle(message, nullptr, nullptr, s);
return true;
}
};
@@ -125,7 +117,6 @@ class ModuleRPCSystem final
: public Module
{
private:
ServiceReference<GlobalService> global;
ServiceReference<RPC::ServiceInterface> rpc;
MessageNetworkRPCEvent messagenetworkrpcevent;
MessageServerRPCEvent messageserverrpcevent;
@@ -134,9 +125,8 @@ private:
public:
ModuleRPCSystem(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, EXTRA | VENDOR)
, global("GlobalService", "Global")
, messagenetworkrpcevent(this, global)
, messageserverrpcevent(this, global)
, messagenetworkrpcevent(this)
, messageserverrpcevent(this)
, messageuserrpcevent(this)
{
}
+1 -1
View File
@@ -38,7 +38,7 @@ bool WebCPanel::NickServ::Cert::OnRequest(HTTP::Provider *server, const Anope::s
WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements);
}
NSCertList *cl = na->nc->GetExt<NSCertList>("certificates");
auto *cl = na->nc->GetExt<::NickServ::CertList>(NICKSERV_CERT_EXT);
if (cl)
for (unsigned i = 0; i < cl->GetCertCount(); ++i)
replacements["CERTS"] = cl->GetCert(i);