GENERIC_SERVER
0.0.0.9
A light-weight, cross-platform, pluggable, extensible and secure framework for deploying C++ plug-ins.
|
This is a singleton class and provides framework functionality. More...
#include <generic_server.h>
Public Member Functions | |
int | init () |
int | log (unsigned int, unsigned int, char *) |
enables logging to framework managed log file. | |
int | log (unsigned int, unsigned int, string) |
enables logging to framework managed log file. | |
int | get_log_size (void) |
int | rollover_logs (void) |
Rolls over log files, configured in Master configuation file. | |
int | close_log (void) |
int | sock_init (void) |
Really useful only for Windows, just invokes WSAStartup API. | |
int | swap_bytes (unsigned char *key) |
A simple utility to swap upper / lower 8 bytes of a 16 bytes buffer. | |
int | bb_getline (char *sav_buffer, size_t length, size_t conn_s) |
int | bb_getline (char *sav_buffer, size_t length, size_t conn_s, int) |
int | get_status (unsigned char *buff) |
string | get_cur_time (void) |
string | trim (const std::string &) |
int | socket_close (SOCKET) |
int | close_thread_ids (void) |
SOCKET | create_socket (int) |
bool | get_verify_client (void) |
int | set_verify_client (bool) |
int | check_enabled_plugin (string) |
int | check_allocated_port (string in_plugin_id, string in_plugin_port) |
int | set_conf_file (char *cfile) |
int | set_process_name (char *cfile) |
int | reload_conf_file (void) |
int | get_command_port (void) |
int | plugin_read_conf_file (GENERIC_PLUGIN *, int thread_no) |
int | syslog_msg (unsigned int debug_level, unsigned int verbose_level, string data) |
string | get_framework_version (void) |
int | print_key_message () |
int | get_thread_id () |
int | rel_thread_id (int) |
bool | check_plugin_aliases (vector< string > &alias) |
int | set_plugins_path (vector< string > &plugin_parms) |
string | get_plugins_path () |
int | setnonblocking (SOCKET) |
int | setblocking (SOCKET) |
int | get_thread_sync_mutex (void) |
int | rel_thread_sync_mutex (void) |
int | ssl_async_write (SSL *ssl, char *buf, int size) |
int | ssl_async_read (SSL *ssl, char *buf, int size) |
int | ssl_async_accept (SSL *ssl) |
vector< string > | split (const string &s, const string &delim, const bool keep_empty) |
GENERIC_PLUGIN * | load_shared_lib (string library_image, string) |
int | unload_shared_lib (string plugin_type) |
vector< GENERIC_PLUGIN * > ::iterator | get_start_iterator (void) |
vector< GENERIC_PLUGIN * > ::iterator | get_end_iterator (void) |
Static Public Member Functions | |
static generic_server * | instance (void) |
Instantiate tis singleton class only once and return pointer to instantiated object later on.. | |
Public Attributes | |
vector< GENERIC_PLUGIN * > ::iterator | itr |
vector< GENERIC_PLUGIN * > | v |
Vector to hold all plug-ins. | |
unsigned int | timeout_seconds |
int | max_threads |
int | command_port |
ofstream | log_file |
string | logname |
map< string, void * > | dll_handles |
map< int, THREAD_INFO > | thread_ids |
Map to store all currently running threads. | |
map< string, create_fp > | factory |
Map that has function pointers to 'create_instance()' factory method for all plug-in libraries. | |
SSLServer | sslserver |
bool | syslog_flag |
map< string, bool > | bootstrap_jobs |
string | server_cert |
TLS certificate stuff. | |
string | rsa_private_key |
string | ca_certificate |
Static Public Attributes | |
static generic_server * | pinstance = 0 |
Pointer to singleton framework instance. | |
Private Member Functions | |
int | get_log_file_mutex (void) |
int | rel_log_file_mutex (void) |
int | get_server_params (string, int) |
int | tls_setup (void) |
Initializes TLS. | |
int | remove_plugins (map< string, int > &new_ports) |
This is invoked when any plug-in entry gets removed from Master configuration file and framework gets signaled. | |
int | remove_all_aliases () |
GENERIC_PLUGIN * | initialize_plugin_object (vector< string > plugin_parms, GENERIC_PLUGIN *plugin) |
int | tls_initialize () |
Validates generic_server framework and CA certificates, calls tls_setup(). | |
int | set_access_control (char daemon_flag) |
This is a singleton class and provides framework functionality.
Definition at line 83 of file generic_server.h.
int generic_server::bb_getline | ( | char * | sav_buffer, |
size_t | length, | ||
size_t | conn_s | ||
) |
Asynchronous socket read utility.
[out] | sav_buffer | Buffer to store read data. |
[in] | length | Maximum number of bytes to read from socket. |
Definition at line 904 of file generic_server.cpp.
bool generic_server::check_plugin_aliases | ( | vector< string > & | alias | ) |
Checks for 'alias' plug-ins. An 'alias' is any plug-in that uses the same TCP port of primary plug-in. Framework would use one TCP port/socket to service all 'aliased' plug-ins.
[in] | &alias | Reference to alias Vector within every |
Definition at line 290 of file generic_server.cpp.
SOCKET generic_server::create_socket | ( | int | port | ) |
Creates a 'listen'ing socket for every plugin, sets socket to 'nonblocking' mode.
[in] | port | TCP port for socket to bind. |
Definition at line 1244 of file generic_server.cpp.
Referenced by process_data().
int generic_server::init | ( | ) |
Reads master configuration file, loads plug-in shared libraries and initializes master Vector to store plug-ins.
Definition at line 472 of file generic_server.cpp.
|
private |
Update plug-in object with plug-in specific configuration parameters from plug-in conf file.
[in] | plugin_parms | Vector that holds plug-in configuration details. |
[in] | plugin | Plug-in object to be updated. |
Definition at line 1138 of file generic_server.cpp.
References generic_plugin::bootstrap_init(), generic_plugin::bootstrap_name(), generic_plugin::initialize_socket(), generic_plugin::pinstance, and generic_plugin::server_init().
GENERIC_PLUGIN * generic_server::load_shared_lib | ( | string | library_image, |
string | plugin_type | ||
) |
Dynamically loads plug-in shared library.
[in] | library_image | Path to shared library image. |
[in] | plugin_type | PLUGIN_TYPE to load. |
Definition at line 599 of file generic_server.cpp.