Skip to content

Commit

Permalink
[WIP] Second commit for mysql firewall whitelist
Browse files Browse the repository at this point in the history
Improved also compiling time
  • Loading branch information
renecannao committed Nov 18, 2019
1 parent 5023f2d commit 80e92b1
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 11 deletions.
8 changes: 4 additions & 4 deletions include/cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#endif /* PROXYSQLCLICKHOUSE */
#include "MySQL_HostGroups_Manager.h"
#include "MySQL_Logger.hpp"
#include "MySQL_PreparedStatement.h"
#include "ProxySQL_Cluster.hpp" // cluster
#include "ProxySQL_Statistics.hpp" // statistics
#include "ProxySQL_HTTP_Server.hpp" // HTTP server
//#include "MySQL_PreparedStatement.h"
//#include "ProxySQL_Cluster.hpp" // cluster
//#include "ProxySQL_Statistics.hpp" // statistics
//#include "ProxySQL_HTTP_Server.hpp" // HTTP server
#undef swap
#undef min
#undef max
Expand Down
5 changes: 5 additions & 0 deletions include/proxysql_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class ProxySQL_Admin {
void init_users();
void init_mysql_servers();
void init_mysql_query_rules();
void init_mysql_firewall();
void init_proxysql_servers();
void save_mysql_users_runtime_to_database(bool _runtime);
void save_mysql_servers_runtime_to_database(bool);
Expand All @@ -222,11 +223,15 @@ class ProxySQL_Admin {
void flush_mysql_servers__from_disk_to_memory();
void flush_mysql_query_rules__from_memory_to_disk();
void flush_mysql_query_rules__from_disk_to_memory();
void flush_mysql_firewall__from_memory_to_disk();
void flush_mysql_firewall__from_disk_to_memory();
void load_mysql_servers_to_runtime();
void save_mysql_servers_from_runtime();
char * load_mysql_query_rules_to_runtime();
void save_mysql_query_rules_from_runtime(bool);
void save_mysql_query_rules_fast_routing_from_runtime(bool);
char * load_mysql_firewall_to_runtime();
void save_mysql_firewall_from_runtime(bool);

void load_scheduler_to_runtime();
void save_scheduler_runtime_to_database(bool);
Expand Down
5 changes: 5 additions & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ class SQLite3_result;
class stmt_execute_metadata_t;
class MySQL_STMTs_meta;
class MySQL_HostGroups_Manager;
class ProxySQL_HTTP_Server;
class MySQL_STMTs_local_v14;
class MySQL_STMT_Global_info;
class StmtLongDataHandler;
class ProxySQL_Cluster;
#endif /* PROXYSQL_CLASSES */
//#endif /* __cplusplus */

Expand Down
3 changes: 3 additions & 0 deletions include/query_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ class Query_Processor {
void load_fast_routing(SQLite3_result *resultset);
SQLite3_result * get_current_query_rules_fast_routing();
int testing___find_HG_in_mysql_query_rules_fast_routing(char *username, char *schemaname, int flagIN);

// firewall
void load_mysql_firewall(SQLite3_result *u, SQLite3_result *r);
};

typedef Query_Processor * create_Query_Processor_t();
Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "cpp.h"
#include "SpookyV2.h"

#include "MySQL_PreparedStatement.h"

#define char_malloc (char *)malloc
#define itostr(__s, __i) { __s=char_malloc(32); sprintf(__s, "%lld", __i); }

Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_Logger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <fstream>
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_PreparedStatement.h"

#include <dirent.h>
#include <libgen.h>

Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "SpookyV2.h"

#include "MySQL_PreparedStatement.h"

//extern MySQL_STMT_Manager *GloMyStmt;
//static uint32_t add_prepared_statement_calls = 0;
//static uint32_t find_prepared_statement_by_hash_calls = 0;
Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "proxysql.h"
#include "cpp.h"

#include "MySQL_PreparedStatement.h"

extern MySQL_Authentication *GloMyAuth;
extern MySQL_LDAP_Authentication *GloMyLdapAuth;
extern MySQL_Threads_Handler *GloMTH;
Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "SpookyV2.h"
#include "set_parser.h"

#include "MySQL_PreparedStatement.h"

#define SELECT_VERSION_COMMENT "select @@version_comment limit 1"
#define SELECT_VERSION_COMMENT_LEN 32
#define PROXYSQL_VERSION_COMMENT "\x01\x00\x00\x01\x01\x27\x00\x00\x02\x03\x64\x65\x66\x00\x00\x00\x11\x40\x40\x76\x65\x72\x73\x69\x6f\x6e\x5f\x63\x6f\x6d\x6d\x65\x6e\x74\x00\x0c\x21\x00\x18\x00\x00\x00\xfd\x00\x00\x1f\x00\x00\x05\x00\x00\x03\xfe\x00\x00\x02\x00\x0b\x00\x00\x04\x0a(ProxySQL)\x05\x00\x00\x05\xfe\x00\x00\x02\x00"
Expand Down
2 changes: 2 additions & 0 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "re2/re2.h"
#include "re2/regexp.h"

#include "MySQL_PreparedStatement.h"

#ifdef DEBUG
MySQL_Session *sess_stopat;
#endif
Expand Down
200 changes: 193 additions & 7 deletions lib/ProxySQL_Admin.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/ProxySQL_Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "cpp.h"
#include "SpookyV2.h"

#include "ProxySQL_Cluster.hpp"

#ifdef DEBUG
#define DEB "_DEBUG"
#else
Expand Down
2 changes: 2 additions & 0 deletions lib/ProxySQL_HTTP_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "re2/regexp.h"
#include "proxysql.h"
#include "cpp.h"
#include "ProxySQL_HTTP_Server.hpp" // HTTP server
#include "ProxySQL_Statistics.hpp"

#include <search.h>
#include <stdlib.h>
Expand Down
2 changes: 2 additions & 0 deletions lib/ProxySQL_Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "proxysql.h"
#include "cpp.h"

#include "ProxySQL_Statistics.hpp"

//#include "thread.h"
//#include "wqueue.h"

Expand Down
7 changes: 7 additions & 0 deletions lib/Query_Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "proxysql.h"
#include "cpp.h"

#include "MySQL_PreparedStatement.h"

#include "SpookyV2.h"

#include "pcrecpp.h"
Expand Down Expand Up @@ -2781,3 +2783,8 @@ int Query_Processor::testing___find_HG_in_mysql_query_rules_fast_routing(char *u
#endif
return ret;
}

void Query_Processor::load_mysql_firewall(SQLite3_result *u, SQLite3_result *r) {
// TODO: complete
return;
}
2 changes: 2 additions & 0 deletions lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "SpookyV2.h"
#include <fcntl.h>

#include "MySQL_PreparedStatement.h"

extern const MARIADB_CHARSET_INFO * proxysql_find_charset_nr(unsigned int nr);

#define PROXYSQL_USE_RESULT
Expand Down
2 changes: 2 additions & 0 deletions lib/mysql_data_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define UNIX_PATH_MAX 108
#endif

#include "MySQL_PreparedStatement.h"

struct bio_st {
const BIO_METHOD *method;
long (*callback) (struct bio_st *, int, const char *, int, long, long);
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
//#define PROXYSQL_EXTERN
#include "cpp.h"

#include "ProxySQL_Statistics.hpp"
#include "MySQL_PreparedStatement.h"
#include "ProxySQL_Cluster.hpp"

#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
Expand Down

0 comments on commit 80e92b1

Please sign in to comment.