A light-weight, cross-platform, pluggable, extensible and secure framework for deploying C++ plug-ins.
GENERIC_SERVER is a cross-platform, pluggable, extensible, secure framework for deploying C++ plug-ins. Multi-threaded framework can support multiple plug-ins. GENERIC_SERVER makes extensive use of pluggable shared libraries to 'plugin' specific functionality to the framework. Framework dynamically loads,unloads plug-ins and dispatches each plug-in in a separate thread. Plug-ins would just focus on implementing business logic, framework handles plug-in lifecycle management, network management, threads management and provides a host of other functionality that any plug-in could utilitze.
GENERIC_SERVER has been packaged as an Autoconf package. You could just:
$ ./configure $ make $ make install
to build and install the framework. The following components would be built:
A Visual Studio solution is available to build GENERIC_SERVER on Windows. This is generic_server.sln under WINDOWS/generic_server directory. Visual Studio 2010 has been used to develop and test on Windows. This solution has five projects:
GENERIC_SERVER is a true Windows service. Generic_Server cleanly handles Windows service events. Service Manager can be used to have fine-grained control over generic_server process.
Edit generic_server.conf file in install directory and ensure correct path is configured for different files and plug-ins. Assuming framework is installed under C:\generic_server directory, the following command should be used to install GENERIC_SERVER service: C:\generic_server>generic_server -i <SERVICE_NAME> <INSTANCE_SPECIFIC_CONF_FILE> Example: C:\generic_server>generic_server -i MAIN_SERVER generic_server.conf Once the above step is done, a service named MAIN_SERVER will be created on Windows.
Go to Windows Service Manager and confirm a service named <SERVICE_NAME> is installed. Start --> Control Panel --> Administrative Tools --> Services
Example: $ ./sample_client x.x.x.x 60103 TEST_PLUGIN "Hello from sample_client.." 2 1
Run the command: # generic_server <INSTANCE_NAME> <INSTANCE_SPECIFIC_CONF_FILE> Example: # generic_server MAIN_SERVER generic_server.conf
A sample server configuration file is shown below:
LOG_FILE=/tmp/TEST/generic_server.log #LOG_FILE=SYSLOG # This is the seconds interval a thread will do idle wait client TIMEOUT_SECONDS=300 # Max. concurrent threads the will framework will spawn for all plugins MAX_THREADS=100 # next 2 entries are self-explanatory MAX_LOG_SIZE_IN_MB=100 MAX_LOGS_SAVED=5 # TLS certificate in PEM format, if TLS is enabled for any plugin SERVER_CERTIFICATE=/tmp/TEST/CERT/generic_server.crt # TLS private_key in PEM format, if TLS is enabled for any plugin RSA_PRIVATE_KEY=/tmp/TEST/CERT/generic_server.key # CA cert file CA_CERTIFICATE=/tmp/TEST//CERT/CAfile.pem #VERIFY_CLIENT option will validate client TLS certificate. Default is #not to validate certificates. VERIFY_CLIENT=0 # COMMAND_PORT should be unique per instance. Please set any free port COMMAND_PORT=10000 # PLUGINS_PATH set the base DIR of plugins shared library / DLL PLUGINS_PATH=/tmp/TEST/plugins # #PLUGIN_NAME|PLUGIN_TYPE|TCP_PORT|PLUGIN_NUMBER|PLUGIN_SHARED_LIBRARY|TLS_FLAG|PLUGIN_SPECIFIC_CONF_FILE #PLUGIN_SPECIFIC_CONF_FILE and PLUGIN LIB path is relative to server install directory # SAMPLE1|SAMPLE|60103|1|sample/libsample.1.0.so|1|sample/sample.conf SAMPLE2|FILE_UPLOAD|60104|1|sample2/libsample2.1.0.so|1|sample2/sample2.conf
GENERIC_SERVER has the following main components:
This is a singleton class and provides framework functionality. Source files are in: framework directory.
This component provides functionality that are common across plug-ins. Source files are in generic_plugin directory. Framework would instantiate and load objects of type GENERIC_PLUGIN to framework from plugin shared library. Generic_plugin is packaged into a shared library: libgeneric_plugin.so or generic_plugin.dll.
Plug-ins are where business logic gets implemented. All plug-ins should derive from class GENERIC_PLUGIN and should have a function named create_instance(). A sample plug-in is in directory: plugins/sample.
Master program that bootstraps GENERIC_SERVER. Source is in control.cpp. Listens and does 'select()'on all sockets configured in generic_server.conf file. Spawns a thread for each plug-in and runs message loop for that plug-in.
Generic_Server has been designed to easily enable addition or deletion of plug-ins to the framework without restartng the framework:
Add or remove plug-ins from generic_server.conf file, then go to service manager and 'pause' and 'resume' the service <SERVICE_NAME>. Check out log file to ensure server has picked up the changes.
Add or remove plug-ins from generic_server conf file and then send signal SIGHUP to generic_server process via 'kill' command. Check out log file to ensure server has picked up the changes.
GENERIC_SERVER has been designed to provide flexibility to plug-ins on messaging structure and protocol. GENERIC_SERVER today implements a very simplified message structure shown below:
If VALIDATE_PLUGIN is set to 1 in framework configuration file, then all client requests should have PLUGIN_NAME_LEN and PLUGIN_NAME within the message.
OpenSSL 1.0 was used to develop and test GENERIC_SERVER for Windows. Please download and install OpenSSL windows development package from: http://www.shininglightpro.com/download/Win32OpenSSL_Light-1_0_0a.exe Once OpenSSL is installed, please ensure path to OpenSSL include and lib directories is correctly configured in all Visual Studio projects
Please use platform specific tools to install OpenSSL development package for Linux.
Git link for this project is at: https://github.com/surajvijayan/GENERIC_SERVER
This has been developed by Suraj Vijayan suraj.nosp@m.@firstname.lastname@example.org@m..com.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA