diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index bc11a1e9..33e2a6ca 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -39,6 +39,7 @@ #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" +#include "common/PluginVersion.h" #include "common/stdexcept.h" #include @@ -46,8 +47,6 @@ #include #include -static const char s_networkSecurity[] = { "ns" }; - // // Client // @@ -103,7 +102,7 @@ Client::Client( } if (m_args.m_enableCrypto) { - m_useSecureNetwork = ARCH->plugin().exists(s_networkSecurity); + m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]); if (m_useSecureNetwork == false) { LOG((CLOG_NOTE "crypto disabled because of ns plugin not available")); } @@ -585,7 +584,7 @@ Client::cleanupStream() // we need to tell the dynamic lib that allocated this object // to do the deletion. if (m_useSecureNetwork) { - ARCH->plugin().invoke(s_networkSecurity, "deleteSocket", NULL); + ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "deleteSocket", NULL); } } diff --git a/src/lib/common/PluginVersion.cpp b/src/lib/common/PluginVersion.cpp index a34fd9ad..656b80fc 100644 --- a/src/lib/common/PluginVersion.cpp +++ b/src/lib/common/PluginVersion.cpp @@ -19,14 +19,11 @@ #include -static const int kpluginCount = 1; static const char kUnknownVersion[] = "unknown"; -static const char* s_pluginNames[] = { "ns" }; -static const char* s_pluginVersions[] = { "1.2" }; const char* getExpectedPluginVersion(const char* name) { - for (int i = 0; i < kpluginCount; i++) { + for (int i = 0; i < kPluginCount; i++) { if (strcmp(name, s_pluginNames[i]) == 0) { return s_pluginVersions[i]; break; diff --git a/src/lib/common/PluginVersion.h b/src/lib/common/PluginVersion.h index 738afef9..02839ef6 100644 --- a/src/lib/common/PluginVersion.h +++ b/src/lib/common/PluginVersion.h @@ -17,6 +17,15 @@ #pragma once +enum EPluginType { + kSecureSocket, + kPluginCount +}; + +static const char* s_pluginNames[] = { "ns" }; +static const char* s_pluginVersions[] = { "1.2" }; + + //! Get expected plugin version /*! Returns the plugin version expected by the plugin loader. diff --git a/src/lib/net/TCPSocketFactory.cpp b/src/lib/net/TCPSocketFactory.cpp index 8a4acef2..0f92ffb9 100644 --- a/src/lib/net/TCPSocketFactory.cpp +++ b/src/lib/net/TCPSocketFactory.cpp @@ -21,14 +21,13 @@ #include "net/TCPSocket.h" #include "net/TCPListenSocket.h" #include "arch/Arch.h" +#include "common/PluginVersion.h" #include "base/Log.h" // // TCPSocketFactory // -static const char s_networkSecurity[] = { "ns" }; - TCPSocketFactory::TCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer) : m_events(events), m_socketMultiplexer(socketMultiplexer) @@ -51,7 +50,7 @@ TCPSocketFactory::create(bool secure) const m_socketMultiplexer }; socket = static_cast( - ARCH->plugin().invoke(s_networkSecurity, "getSocket", args)); + ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getSocket", args)); } else { socket = new TCPSocket(m_events, m_socketMultiplexer); @@ -70,7 +69,7 @@ TCPSocketFactory::createListen(bool secure) const m_socketMultiplexer }; socket = static_cast( - ARCH->plugin().invoke(s_networkSecurity, "getListenSocket", args)); + ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getListenSocket", args)); } else { socket = new TCPListenSocket(m_events, m_socketMultiplexer); diff --git a/src/lib/plugin/ns/ns.cpp b/src/lib/plugin/ns/ns.cpp index a053d705..e7ae164e 100644 --- a/src/lib/plugin/ns/ns.cpp +++ b/src/lib/plugin/ns/ns.cpp @@ -32,7 +32,6 @@ SecureSocket* g_secureSocket = NULL; SecureListenSocket* g_secureListenSocket = NULL; Arch* g_arch = NULL; Log* g_log = NULL; -static const char kPluginName[] = "ns"; std::string helperGetLibsUsed(void) @@ -107,7 +106,7 @@ invoke(const char* command, void** args) } } else if (strcmp(command, "version") == 0) { - return (void*)getExpectedPluginVersion(kPluginName); + return (void*)getExpectedPluginVersion(s_pluginNames[kSecureSocket]); } return NULL; diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index e335f575..9b103493 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -25,6 +25,7 @@ #include "net/IListenSocket.h" #include "net/ISocketFactory.h" #include "net/XSocket.h" +#include "common/PluginVersion.h" #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" @@ -33,8 +34,6 @@ // ClientListener // -static const char s_networkSecurity[] = { "ns" }; - ClientListener::ClientListener(const NetworkAddress& address, ISocketFactory* socketFactory, IEventQueue* events, @@ -49,7 +48,7 @@ ClientListener::ClientListener(const NetworkAddress& address, try { // create listen socket if (enableCrypto) { - m_useSecureNetwork = ARCH->plugin().exists(s_networkSecurity); + m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]); if (m_useSecureNetwork == false) { LOG((CLOG_NOTE "crypto disabled because of ns plugin not available")); } @@ -249,7 +248,7 @@ ClientListener::cleanupListenSocket() } else { ARCH->plugin().invoke( - s_networkSecurity, + s_pluginNames[kSecureSocket], "deleteListenSocket", NULL); }