diff options
author | Adam <Adam@anope.org> | 2012-11-30 02:49:09 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-11-30 02:53:03 -0500 |
commit | a4468dd56e96ea915d40627f3cb067084238e34a (patch) | |
tree | a8a497965346e55eeb79fc56797da6bea81bf841 /src | |
parent | 337f3615264f30d4c9f06653d2dd2a21805546ce (diff) |
Allow modules to use the encryption modules to encrypt arbitrary things.
Made enc_old depend on enc_md5.
Allow not loading any encryption modules if you want to only use an
external mechanism.
Removed ns_sendpass since it's just a bad idea.
Diffstat (limited to 'src')
-rw-r--r-- | src/encrypt.cpp | 50 | ||||
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/messages.cpp | 4 | ||||
-rw-r--r-- | src/misc.cpp | 24 |
4 files changed, 26 insertions, 54 deletions
diff --git a/src/encrypt.cpp b/src/encrypt.cpp deleted file mode 100644 index 0227be2ef..000000000 --- a/src/encrypt.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * (C) 2003-2012 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - */ - -#include "services.h" -#include "modules.h" - -/******************************************************************************/ - -/** Encrypt the string src into dest - * @param src The source string - * @param dest The destination strnig - */ -void Anope::Encrypt(const Anope::string &src, Anope::string &dest) -{ - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest)); -} - -/** Decrypt the encrypted string src into dest - * @param src The encrypted string - * @param desc The destination string - * @return true on success - */ -bool Anope::Decrypt(const Anope::string &src, Anope::string &dest) -{ - size_t pos = src.find(':'); - if (pos == Anope::string::npos) - { - Log() << "Error: Anope::Decrypt() called with invalid password string (" << src << ")"; - return false; - } - Anope::string hashm(src.begin(), src.begin() + pos); - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnDecrypt, OnDecrypt(hashm, src, dest)); - if (MOD_RESULT == EVENT_ALLOW) - return true; - - return false; -} - diff --git a/src/init.cpp b/src/init.cpp index e831351ec..e45d2a6f9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -451,8 +451,6 @@ void Anope::Init(int ac, char **av) Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); if (protocol == NULL) throw CoreException("You must load a protocol module!"); - else if (ModuleManager::FindFirstOf(ENCRYPTION) == NULL) - throw CoreException("You must load at least one encryption module"); Log() << "Using IRCd protocol " << protocol->name; diff --git a/src/messages.cpp b/src/messages.cpp index f5e598945..f9dc81c85 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -326,7 +326,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m else if (message.substr(0, 9).equals_ci("\1VERSION\1")) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str()); + IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str()); } return; } @@ -448,7 +448,7 @@ void Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) void Version::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str()); + IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str()); return; } diff --git a/src/misc.cpp b/src/misc.cpp index 7196a1534..417849df4 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -450,6 +450,30 @@ bool Anope::Match(const Anope::string &str, const Anope::string &mask, bool case return m == mask_len; } +void Anope::Encrypt(const Anope::string &src, Anope::string &dest) +{ + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest)); +} + +bool Anope::Decrypt(const Anope::string &src, Anope::string &dest) +{ + size_t pos = src.find(':'); + if (pos == Anope::string::npos) + { + Log() << "Error: Anope::Decrypt() called with invalid password string (" << src << ")"; + return false; + } + Anope::string hashm(src.begin(), src.begin() + pos); + + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnDecrypt, OnDecrypt(hashm, src, dest)); + if (MOD_RESULT == EVENT_ALLOW) + return true; + + return false; +} + Anope::string Anope::printf(const char *fmt, ...) { va_list args; |