summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h14
-rw-r--r--src/helperfuncs.cpp2
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp9
4 files changed, 14 insertions, 13 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index cbd43da43..00a705dd0 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -165,8 +165,6 @@ class serverstats
}
};
-DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
-
/** The main class of the irc server.
* This class contains instances of all the other classes in this software.
* Amongst other things, it contains a ModeParser, a DNS object, a CommandParser
@@ -209,9 +207,6 @@ class CoreExport InspIRCd
/** Actions that must happen outside of the current call stack */
ActionList AtomicActions;
- /**** Functors ****/
- GenRandomHandler HandleGenRandom;
-
/** Globally accessible fake user record. This is used to force mode changes etc across s2s, etc.. bit ugly, but.. better than how this was done in 1.1
* Reason for it:
* kludge alert!
@@ -339,7 +334,14 @@ class CoreExport InspIRCd
unsigned long GenRandomInt(unsigned long max);
/** Fill a buffer with random bits */
- caller2<void, char*, size_t> GenRandom;
+ TR1NS::function<void(char*, size_t)> GenRandom;
+
+ /** Fills the output buffer with the specified number of random characters.
+ * This is the default function for InspIRCd::GenRandom.
+ * @param output The output buffer to store random characters in.
+ * @param max The maximum number of random characters to put in the buffer.
+ */
+ static void DefaultGenRandom(char* output, size_t max);
/** Bind all ports specified in the configuration file.
* @return The number of ports bound without error
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index a24401542..b80a3897c 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -415,7 +415,7 @@ unsigned long InspIRCd::GenRandomInt(unsigned long max)
}
// This is overridden by a higher-quality algorithm when SSL support is loaded
-void GenRandomHandler::Call(char *output, size_t max)
+void InspIRCd::DefaultGenRandom(char* output, size_t max)
{
for(unsigned int i=0; i < max; i++)
#ifdef _WIN32
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 5f7dfd06f..d7b616ecc 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -226,7 +226,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
* THIS MUST MATCH THE ORDER OF DECLARATION OF THE FUNCTORS, e.g. the methods
* themselves within the class.
*/
- GenRandom(&HandleGenRandom),
+ GenRandom(&DefaultGenRandom),
IsChannel(&DefaultIsChannel),
IsNick(&DefaultIsNick),
IsIdent(&DefaultIsIdent)
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 2d278c967..97fdf504c 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -112,10 +112,10 @@ typedef gnutls_connection_end_t inspircd_gnutls_session_init_flags_t;
static Module* thismod;
-class RandGen : public HandlerBase2<void, char*, size_t>
+class RandGen
{
public:
- void Call(char* buffer, size_t len) CXX11_OVERRIDE
+ static void Call(char* buffer, size_t len)
{
#ifdef GNUTLS_HAS_RND
gnutls_rnd(GNUTLS_RND_RANDOM, buffer, len);
@@ -1272,7 +1272,6 @@ class ModuleSSLGnuTLS : public Module
// First member of the class, gets constructed first and destructed last
GnuTLS::Init libinit;
- RandGen randhandler;
ProfileList profiles;
void ReadProfiles()
@@ -1352,7 +1351,7 @@ class ModuleSSLGnuTLS : public Module
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "GnuTLS lib version %s module was compiled for " GNUTLS_VERSION, gnutls_check_version(NULL));
ReadProfiles();
- ServerInstance->GenRandom = &randhandler;
+ ServerInstance->GenRandom = RandGen::Call;
}
void OnModuleRehash(User* user, const std::string &param) CXX11_OVERRIDE
@@ -1372,7 +1371,7 @@ class ModuleSSLGnuTLS : public Module
~ModuleSSLGnuTLS()
{
- ServerInstance->GenRandom = &ServerInstance->HandleGenRandom;
+ ServerInstance->GenRandom = &InspIRCd::DefaultGenRandom;
}
void OnCleanup(ExtensionItem::ExtensibleType type, Extensible* item) CXX11_OVERRIDE