Make CLIENT_SSL configurable

pull/1464/head
René Cannaò 8 years ago
parent 06030f8b85
commit 5863d9c2f1

@ -367,6 +367,7 @@ class MySQL_Threads_Handler
bool query_digests_lowercase;
bool default_reconnect;
bool have_compress;
bool have_ssl;
bool client_found_rows;
bool multiplexing;
// bool stmt_multiplexing;

@ -628,6 +628,7 @@ __thread uint8_t mysql_thread___default_charset;
__thread int mysql_thread___poll_timeout;
__thread int mysql_thread___poll_timeout_on_failure;
__thread bool mysql_thread___have_compress;
__thread bool mysql_thread___have_ssl;
__thread bool mysql_thread___client_found_rows;
__thread bool mysql_thread___multiplexing;
__thread bool mysql_thread___forward_autocommit;
@ -735,6 +736,7 @@ extern __thread uint8_t mysql_thread___default_charset;
extern __thread int mysql_thread___poll_timeout;
extern __thread int mysql_thread___poll_timeout_on_failure;
extern __thread bool mysql_thread___have_compress;
extern __thread bool mysql_thread___have_ssl;
extern __thread bool mysql_thread___client_found_rows;
extern __thread bool mysql_thread___multiplexing;
extern __thread bool mysql_thread___forward_autocommit;

@ -1043,10 +1043,17 @@ bool MySQL_Protocol::generate_pkt_initial_handshake(bool send, void **ptr, unsig
}
}
memcpy(_ptr+l, (*myds)->myconn->scramble_buff+0, 8); l+=8;
_ptr[l]=0x00; l+=1; //0x00
memcpy(_ptr+l, (*myds)->myconn->scramble_buff+0, 8); l+=8;
_ptr[l]=0x00; l+=1; //0x00
if (mysql_thread___have_compress) {
mysql_thread___server_capabilities |= CLIENT_COMPRESS; // FIXME: shouldn't be here
mysql_thread___server_capabilities |= CLIENT_COMPRESS;
} else {
mysql_thread___server_capabilities &= ~CLIENT_COMPRESS;
}
if (mysql_thread___have_ssl) {
mysql_thread___server_capabilities |= CLIENT_SSL;
} else {
mysql_thread___server_capabilities &= ~CLIENT_SSL;
}
(*myds)->myconn->options.server_capabilities=mysql_thread___server_capabilities;
memcpy(_ptr+l,&mysql_thread___server_capabilities, sizeof(mysql_thread___server_capabilities)); l+=sizeof(mysql_thread___server_capabilities);

@ -224,6 +224,7 @@ static char * mysql_thread_variables_names[]= {
#ifdef IDLE_THREADS
(char *)"session_idle_ms",
#endif // IDLE_THREADS
(char *)"have_ssl",
(char *)"have_compress",
(char *)"client_found_rows",
(char *)"interfaces",
@ -408,6 +409,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.poll_timeout=2000;
variables.poll_timeout_on_failure=100;
variables.have_compress=true;
variables.have_ssl = false; // disable by default for performance reason
variables.client_found_rows=true;
variables.commands_stats=true;
variables.multiplexing=true;
@ -663,6 +665,7 @@ int MySQL_Threads_Handler::get_variable_int(char *name) {
if (!strcasecmp(name,"ping_interval_server_msec")) return (int)variables.ping_interval_server_msec;
if (!strcasecmp(name,"ping_timeout_server")) return (int)variables.ping_timeout_server;
if (!strcasecmp(name,"have_compress")) return (int)variables.have_compress;
if (!strcasecmp(name,"have_ssl")) return (int)variables.have_ssl;
if (!strcasecmp(name,"client_found_rows")) return (int)variables.client_found_rows;
if (!strcasecmp(name,"multiplexing")) return (int)variables.multiplexing;
if (!strcasecmp(name,"forward_autocommit")) return (int)variables.forward_autocommit;
@ -1024,6 +1027,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
if (!strcasecmp(name,"have_compress")) {
return strdup((variables.have_compress ? "true" : "false"));
}
if (!strcasecmp(name,"have_ssl")) {
return strdup((variables.have_ssl ? "true" : "false"));
}
if (!strcasecmp(name,"client_found_rows")) {
return strdup((variables.client_found_rows ? "true" : "false"));
}
@ -1804,7 +1810,7 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
// for now disable CLIENT_SSL
// variables.server_capabilities &= ~CLIENT_SSL;
// }
variables.server_capabilities |= CLIENT_SSL;
// variables.server_capabilities |= CLIENT_SSL;
return true;
} else {
@ -1885,10 +1891,25 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
if (!strcasecmp(name,"have_compress")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.have_compress=true;
variables.server_capabilities |= CLIENT_COMPRESS;
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.have_compress=false;
variables.server_capabilities &= ~CLIENT_COMPRESS;
return true;
}
return false;
}
if (!strcasecmp(name,"have_ssl")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.have_ssl=true;
variables.server_capabilities |= CLIENT_SSL;
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.have_ssl=false;
variables.server_capabilities &= ~CLIENT_SSL;
return true;
}
return false;
@ -3393,6 +3414,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___poll_timeout=GloMTH->get_variable_int((char *)"poll_timeout");
mysql_thread___poll_timeout_on_failure=GloMTH->get_variable_int((char *)"poll_timeout_on_failure");
mysql_thread___have_compress=(bool)GloMTH->get_variable_int((char *)"have_compress");
mysql_thread___have_ssl=(bool)GloMTH->get_variable_int((char *)"have_ssl");
mysql_thread___client_found_rows=(bool)GloMTH->get_variable_int((char *)"client_found_rows");
mysql_thread___multiplexing=(bool)GloMTH->get_variable_int((char *)"multiplexing");
mysql_thread___forward_autocommit=(bool)GloMTH->get_variable_int((char *)"forward_autocommit");

Loading…
Cancel
Save