From 9c0134ee2c76fe7ff1509501b3904f9db9b29454 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 17 Feb 2014 00:41:36 +0100 Subject: Rename m_ssl to m_ssl_openssl and update docs --- include/service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/service.h b/include/service.h index db0b2af4b..8142363d6 100644 --- a/include/service.h +++ b/include/service.h @@ -20,7 +20,7 @@ /** Anything that inherits from this class can be referred to * using ServiceReference. Any interfaces provided by modules, * such as commands, use this. This is also used for modules - * that publish a service (m_ssl, etc). + * that publish a service (m_ssl_openssl, etc). */ class CoreExport Service : public virtual Base { -- cgit From baff417652ac7058babbbc478a9bcbcb47867378 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 17 Feb 2014 13:53:04 -0500 Subject: Move encryption.h to include/modules --- include/modules/encryption.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/modules/encryption.h (limited to 'include') diff --git a/include/modules/encryption.h b/include/modules/encryption.h new file mode 100644 index 000000000..95c5703aa --- /dev/null +++ b/include/modules/encryption.h @@ -0,0 +1,37 @@ +/* + * + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + */ + +namespace Encryption +{ + typedef std::pair Hash; + typedef std::pair IV; + + class Context + { + public: + virtual ~Context() { } + virtual void Update(const unsigned char *data, size_t len) = 0; + virtual void Finalize() = 0; + virtual Hash GetFinalizedHash() = 0; + }; + + class Provider : public Service + { + public: + Provider(Module *creator, const Anope::string &sname) : Service(creator, "Encryption::Provider", sname) { } + virtual ~Provider() { } + + virtual Context *CreateContext(IV * = NULL) = 0; + virtual IV GetDefaultIV() = 0; + }; +} + -- cgit From ef7dc94f8891e1dba8ac3dcad5966d1025b6226a Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 17 Feb 2014 19:39:25 -0500 Subject: Move most of the implementation details out of os_forbid.h, fixes crashing if a module adding a forbid is unloaded without removing the forbid --- include/modules/os_forbid.h | 48 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h index 3f1fe9a7f..fe96ba5c6 100644 --- a/include/modules/os_forbid.h +++ b/include/modules/os_forbid.h @@ -10,7 +10,7 @@ enum ForbidType FT_SIZE }; -struct ForbidData : Serializable +struct ForbidData { Anope::string mask; Anope::string creator; @@ -19,9 +19,9 @@ struct ForbidData : Serializable time_t expires; ForbidType type; - ForbidData() : Serializable("ForbidData") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); + virtual ~ForbidData() { } + protected: + ForbidData() : created(0), expires(0) { } }; class ForbidService : public Service @@ -33,6 +33,8 @@ class ForbidService : public Service virtual void RemoveForbid(ForbidData *d) = 0; + virtual ForbidData* CreateForbid() = 0; + virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0; virtual std::vector GetForbids() = 0; @@ -40,43 +42,5 @@ class ForbidService : public Service static ServiceReference forbid_service("ForbidService", "forbid"); -void ForbidData::Serialize(Serialize::Data &data) const -{ - data["mask"] << this->mask; - data["creator"] << this->creator; - data["reason"] << this->reason; - data["created"] << this->created; - data["expires"] << this->expires; - data["type"] << this->type; -} - -Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!forbid_service) - return NULL; - - ForbidData *fb; - if (obj) - fb = anope_dynamic_static_cast(obj); - else - fb = new ForbidData; - - data["mask"] >> fb->mask; - data["creator"] >> fb->creator; - data["reason"] >> fb->reason; - data["created"] >> fb->created; - data["expires"] >> fb->expires; - unsigned int t; - data["type"] >> t; - fb->type = static_cast(t); - - if (t > FT_SIZE - 1) - return NULL; - - if (!obj) - forbid_service->AddForbid(fb); - return fb; -} - #endif -- cgit From 80588fba818b746d43adf978d09933fda79b5e1f Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 17 Feb 2014 19:43:19 -0500 Subject: Fix os_ignore to work correctly with SQL --- include/modules/os_ignore.h | 54 +++++++++------------------------------------ 1 file changed, 10 insertions(+), 44 deletions(-) (limited to 'include') diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h index 0f2c2f0d8..2511d47b2 100644 --- a/include/modules/os_ignore.h +++ b/include/modules/os_ignore.h @@ -10,70 +10,36 @@ */ -struct IgnoreData : Serializable +struct IgnoreData { Anope::string mask; Anope::string creator; Anope::string reason; time_t time; /* When do we stop ignoring them? */ - IgnoreData() : Serializable("IgnoreData") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); + virtual ~IgnoreData() { } + protected: + IgnoreData() : time(0) { } }; class IgnoreService : public Service { protected: - std::list ignores; - IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { } public: - virtual IgnoreData* AddIgnore(const Anope::string &mask, const Anope::string &creator, const Anope::string &reason, time_t delta = Anope::CurTime) = 0; + virtual void AddIgnore(IgnoreData *) = 0; + + virtual void DelIgnore(IgnoreData *) = 0; - virtual bool DelIgnore(const Anope::string &mask) = 0; + virtual void ClearIgnores() = 0; - inline void ClearIgnores() { this->ignores.clear(); } + virtual IgnoreData *Create() = 0; virtual IgnoreData *Find(const Anope::string &mask) = 0; - inline std::list &GetIgnores() { return this->ignores; } + virtual std::vector &GetIgnores() = 0; }; static ServiceReference ignore_service("IgnoreService", "ignore"); -void IgnoreData::Serialize(Serialize::Data &data) const -{ - data["mask"] << this->mask; - data["creator"] << this->creator; - data["reason"] << this->reason; - data["time"] << this->time; -} - -Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!ignore_service) - return NULL; - - if (obj) - { - IgnoreData *ign = anope_dynamic_static_cast(obj); - data["mask"] >> ign->mask; - data["creator"] >> ign->creator; - data["reason"] >> ign->reason; - data["time"] >> ign->time; - return ign; - } - - Anope::string smask, screator, sreason; - time_t t; - - data["mask"] >> smask; - data["creator"] >> screator; - data["reason"] >> sreason; - data["time"] >> t; - - return ignore_service->AddIgnore(smask, screator, sreason, t); -} - -- cgit From 3883716883fbcaade9b8f26af8451bf4b6dac66b Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 18 Feb 2014 03:28:02 +0100 Subject: Turn BinarySocket::Write() into a no-op when called with l == 0 --- include/sockets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/sockets.h b/include/sockets.h index 744f1a23e..0dfa5d9d0 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -347,7 +347,7 @@ class CoreExport BinarySocket : public virtual Socket /** Write data to the socket * @param buffer The data to write - * @param l The length of the data + * @param l The length of the data; if 0 then this function returns without doing anything */ virtual void Write(const char *buffer, size_t l); void Write(const char *message, ...); -- cgit