Skip to content

Commit

Permalink
Preparing skelethon for web ui
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Feb 7, 2020
1 parent a0bd85e commit d266e29
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/Web_Interface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CLASS_WEB_INTERFACE
#define CLASS_WEB_INTERFACE

class Web_Interface {
public:
Web_Interface() {};
virtual ~Web_Interface() {};
virtual void print_version() {};
};

typedef Web_Interface * create_Web_Interface_t();

#endif /* CLASS_WEB_INTERFACE */
1 change: 1 addition & 0 deletions include/proxysql_glovars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ProxySQL_GlobalVariables {
char *pid;
int restart_on_missing_heartbeats;
char * execute_on_exit_failure;
char * web_interface_plugin;
char * ldap_auth_plugin;
struct {
unsigned long long start_time;
Expand Down
49 changes: 48 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "MySQL_Authentication.hpp"
#include "MySQL_LDAP_Authentication.hpp"
#include "proxysql_restapi.h"
#include "Web_Interface.hpp"


#include <libdaemon/dfork.h>
Expand All @@ -40,6 +41,9 @@ extern "C" MySQL_LDAP_Authentication * create_MySQL_LDAP_Authentication_func() {
volatile create_MySQL_LDAP_Authentication_t * create_MySQL_LDAP_Authentication = NULL;
void * __mysql_ldap_auth;

volatile create_Web_Interface_t * create_Web_Interface = NULL;
void * __web_interface;

// absolute path of ssl files
char *ssl_key_fp = NULL;
char *ssl_cert_fp = NULL;
Expand Down Expand Up @@ -695,7 +699,7 @@ ClickHouse_Authentication *GloClickHouseAuth;
Query_Processor *GloQPro;
ProxySQL_Admin *GloAdmin;
MySQL_Threads_Handler *GloMTH = NULL;

Web_Interface *GloWebInterface;
MySQL_STMT_Manager_v14 *GloMyStmt;

MySQL_Monitor *GloMyMon;
Expand Down Expand Up @@ -819,6 +823,14 @@ void ProxySQL_Main_process_global_variables(int argc, const char **argv) {
GloVars.errorlog = strdup(errorlog_path.c_str());
}
}
if (root.exists("web_interface_plugin")==true) {
string web_interface_plugin;
bool rc;
rc=root.lookupValue("web_interface_plugin", web_interface_plugin);
if (rc==true) {
GloVars.web_interface_plugin=strdup(web_interface_plugin.c_str());
}
}
if (root.exists("ldap_auth_plugin")==true) {
string ldap_auth_plugin;
bool rc;
Expand Down Expand Up @@ -966,6 +978,9 @@ void ProxySQL_Main_init_Query_module() {
GloQPro->print_version();
GloAdmin->init_mysql_query_rules();
GloAdmin->init_mysql_firewall();
if (GloWebInterface) {
GloWebInterface->print_version();
}
}

void ProxySQL_Main_init_MySQL_Threads_Handler_module() {
Expand Down Expand Up @@ -1184,6 +1199,35 @@ void ProxySQL_Main_init() {


static void LoadPlugins() {
if (GloVars.web_interface_plugin) {
dlerror();
char * dlsym_error = NULL;
dlerror();
dlsym_error=NULL;
__web_interface = dlopen(GloVars.web_interface_plugin, RTLD_NOW);
if (!__web_interface) {
cerr << "Cannot load library: " << dlerror() << '\n';
exit(EXIT_FAILURE);
} else {
dlerror();
create_Web_Interface = (create_Web_Interface_t *) dlsym(__web_interface, "create_Web_Interface_func");
dlsym_error = dlerror();
if (dlsym_error!=NULL) {
cerr << "Cannot load symbol create_Web_Interface: " << dlsym_error << '\n';
exit(EXIT_FAILURE);
}
}
if (__web_interface==NULL || dlsym_error) {
proxy_error("Unable to load Web_Interface from %s\n", GloVars.web_interface_plugin);
exit(EXIT_FAILURE);
} else {
GloWebInterface = create_Web_Interface();
if (GloWebInterface) {
//GloAdmin->init_WebInterfacePlugin();
//GloAdmin->load_ldap_variables_to_runtime();
}
}
}
if (GloVars.ldap_auth_plugin) {
dlerror();
char * dlsym_error = NULL;
Expand Down Expand Up @@ -1814,6 +1858,9 @@ int main(int argc, const char * argv[]) {

#ifdef RUNNING_ON_VALGRIND
if (RUNNING_ON_VALGRIND==0) {
if (__web_interface) {
dlclose(__web_interface);
}
if (__mysql_ldap_auth) {
dlclose(__mysql_ldap_auth);
}
Expand Down
1 change: 1 addition & 0 deletions src/proxysql.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ restart_on_missing_heartbeats=10
datadir="/var/lib/proxysql"
//execute_on_exit_failure="/path/to/script"
//ldap_auth_plugin="../../proxysql_ldap_plugin/MySQL_LDAP_Authentication_plugin.so"
//web_interface_plugin="../web_interface_plugin/Web_Interface_Plugin.so
admin_variables=
{
Expand Down

0 comments on commit d266e29

Please sign in to comment.