summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-11-25 12:50:11 +0000
committerPeter Powell <petpow@saberuk.com>2017-11-25 13:38:02 +0000
commit6abc789577a86ffcdce8fae81b37f825d9ca4226 (patch)
tree6c485e33261a0e4dfab8005e2f93b3063a7b98b5 /src
parent1dca8b79edf65c0e5e846cc120f1321fb0a1d15c (diff)
Convert GenRandom to std::function.
Diffstat (limited to 'src')
-rw-r--r--src/helperfuncs.cpp2
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp9
3 files changed, 6 insertions, 7 deletions
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