diff --git a/include/Web_Interface.hpp b/include/Web_Interface.hpp index 03eb2ef9e8..65640f67e2 100644 --- a/include/Web_Interface.hpp +++ b/include/Web_Interface.hpp @@ -5,6 +5,8 @@ class Web_Interface { public: Web_Interface() {}; virtual ~Web_Interface() {}; + virtual void start(int p) {}; + virtual void stop() {}; virtual void print_version() {}; }; diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f76ec125cc..f4d9ee790e 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -20,6 +20,8 @@ #include "MySQL_Logger.hpp" #include "SQLite3_Server.h" +#include "Web_Interface.hpp" + #include #include #include @@ -236,6 +238,8 @@ extern MySQL_Logger *GloMyLogger; extern MySQL_STMT_Manager_v14 *GloMyStmt; extern MySQL_Monitor *GloMyMon; +extern Web_Interface *GloWebInterface; + extern ProxySQL_Cluster *GloProxyCluster; #ifdef PROXYSQLCLICKHOUSE extern ClickHouse_Authentication *GloClickHouseAuth; @@ -5290,29 +5294,7 @@ void ProxySQL_Admin::flush_admin_variables___database_to_runtime(SQLite3DB *db, } if (variables.web_enabled != variables.web_enabled_old) { if (variables.web_enabled) { - char *key_pem; - char *cert_pem; - key_pem = load_file(ssl_key_fp); - cert_pem = load_file(ssl_cert_fp); - Admin_HTTP_Server = MHD_start_daemon(MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_SSL, - variables.web_port, - NULL, NULL, http_handler, NULL, - MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_STRICT_FOR_CLIENT, (int) 1, - MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 4, - MHD_OPTION_NONCE_NC_SIZE, (unsigned int) 300, - MHD_OPTION_HTTPS_MEM_KEY, key_pem, - MHD_OPTION_HTTPS_MEM_CERT, cert_pem, - MHD_OPTION_END); - } else { - MHD_stop_daemon(Admin_HTTP_Server); - Admin_HTTP_Server = NULL; - } - variables.web_enabled_old = variables.web_enabled; - } else { - if (variables.web_port != variables.web_port_old) { - if (variables.web_enabled) { - MHD_stop_daemon(Admin_HTTP_Server); - Admin_HTTP_Server = NULL; + if (GloVars.web_interface_plugin == NULL) { char *key_pem; char *cert_pem; key_pem = load_file(ssl_key_fp); @@ -5326,6 +5308,40 @@ void ProxySQL_Admin::flush_admin_variables___database_to_runtime(SQLite3DB *db, MHD_OPTION_HTTPS_MEM_KEY, key_pem, MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END); + } else { + GloWebInterface->start(variables.web_port); + } + } else { + if (GloVars.web_interface_plugin == NULL) { + MHD_stop_daemon(Admin_HTTP_Server); + Admin_HTTP_Server = NULL; + } else { + GloWebInterface->stop(); + } + } + variables.web_enabled_old = variables.web_enabled; + } else { + if (variables.web_port != variables.web_port_old) { + if (variables.web_enabled) { + if (GloVars.web_interface_plugin == NULL) { + MHD_stop_daemon(Admin_HTTP_Server); + Admin_HTTP_Server = NULL; + char *key_pem; + char *cert_pem; + key_pem = load_file(ssl_key_fp); + cert_pem = load_file(ssl_cert_fp); + Admin_HTTP_Server = MHD_start_daemon(MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_SSL, + variables.web_port, + NULL, NULL, http_handler, NULL, + MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_STRICT_FOR_CLIENT, (int) 1, + MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 4, + MHD_OPTION_NONCE_NC_SIZE, (unsigned int) 300, + MHD_OPTION_HTTPS_MEM_KEY, key_pem, + MHD_OPTION_HTTPS_MEM_CERT, cert_pem, + MHD_OPTION_END); + } else { + GloWebInterface->start(variables.web_port); + } } variables.web_port_old = variables.web_port; } diff --git a/src/main.cpp b/src/main.cpp index 2798d23fe2..005c3fd770 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -530,9 +530,10 @@ int ssl_mkit(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days) { proxy_error("Unable to run EVP_PKEY_assign_RSA()\n"); exit(EXIT_SUCCESS); // we exit gracefully to avoid being restarted } - x1 = generate_x509(pk, (const unsigned char *)"ProxySQL_Auto_Generated_CA_Certificate", 2, 3650, NULL, NULL); + time_t t = time(NULL); + x1 = generate_x509(pk, (const unsigned char *)"ProxySQL_Auto_Generated_CA_Certificate", t, 3650, NULL, NULL); write_x509(ssl_ca_fp, x1); - x2 = generate_x509(pk, (const unsigned char *)"ProxySQL_Auto_Generated_Server_Certificate", 3, 3650, x1, pk); + x2 = generate_x509(pk, (const unsigned char *)"ProxySQL_Auto_Generated_Server_Certificate", t, 3650, x1, pk); write_x509(ssl_cert_fp, x2); rsa = NULL; @@ -978,9 +979,9 @@ void ProxySQL_Main_init_Query_module() { GloQPro->print_version(); GloAdmin->init_mysql_query_rules(); GloAdmin->init_mysql_firewall(); - if (GloWebInterface) { - GloWebInterface->print_version(); - } +// if (GloWebInterface) { +// GloWebInterface->print_version(); +// } } void ProxySQL_Main_init_MySQL_Threads_Handler_module() { @@ -1262,6 +1263,8 @@ static void LoadPlugins() { void ProxySQL_Main_init_phase2___not_started() { + LoadPlugins(); + ProxySQL_Main_init_main_modules(); ProxySQL_Main_init_Admin_module(); GloMTH->print_version(); @@ -1278,7 +1281,6 @@ void ProxySQL_Main_init_phase2___not_started() { GloVars.confFile->CloseFile(); } - LoadPlugins(); ProxySQL_Main_init_Auth_module(); diff --git a/src/proxysql.cfg b/src/proxysql.cfg index 480b811d2f..d210cc56ea 100644 --- a/src/proxysql.cfg +++ b/src/proxysql.cfg @@ -8,7 +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 +web_interface_plugin="../../proxysql_web_interface_plugin/src/Web_Interface_plugin.so" admin_variables= {