Dbproxy-user/pwd

Source: Internet
Author: User
Tags decrypt

Dbproxy account is unified, that is, connect dbproxy, connect the main MySQL, the connection from the MySQL account must be the same, in order to isolate the use of dbproxy people do not perceive MySQL, need to separate

Configuration file

#dbproxy账号密码与real master MySQL and isolated from MySQL dbproxy-user=testdbproxy-pwd=7o7yjjekmaster-user = mastermaster-pwd = 7o7yjjekslave-user = slaveslave-pwd = 7o7yjjek

struct Chassis_plugin_config
Location Plugins/proxy/proxy-plugin.h

struct chassis_plugin_config {    ...    Gchar* id_generate;    Gchar* dbproxy_user;    Gchar* dbproxy_pwd;    Gchar* master_user;    Gchar* master_pwd;    Gchar* slave_user;    Gchar* slave_pwd;    ...}

Network_mysqld_proxy_plugin_new
Location:/PLUGINS/PROXY/PROXY-PLUGIN.C

Chassis_plugin_config * network_mysqld_proxy_plugin_new (void) {    ... 1 );    Config->id_generate    = NULL;    Config->dbproxy_user = NULL;    Config->dbproxy_pwd = NULL;    Config->master_user  = NULL;    Config->master_pwd  = NULL;    Config->slave_user    = NULL;    Config->slave_pwd    = NULL;    ...}

Network_mysqld_proxy_plugin_free
Location:/PLUGINS/PROXY/PROXY-PLUGIN.C

voidNetwork_mysqld_proxy_plugin_free (Chassis_plugin_config *oldconfig) {    ...    if(config->id_generate) G_free (config->id_generate); if(Config->dbproxy_user) G_free (config->dbproxy_user); if(config->dbproxy_pwd) G_free (config->dbproxy_pwd); if(Config->master_user) G_free (config->master_user); if(config->master_pwd) G_free (config->master_pwd); if(Config->slave_user) G_free (config->slave_user); if(config->slave_pwd) G_free (config->slave_pwd); ...}

Network_mysqld_proxy_plugin_get_options
Location:/PLUGINS/PROXY/PROXY-PLUGIN.C

Staticchassis_options_t * Network_mysqld_proxy_plugin_get_options (Chassis_plugin_config *oldconfig) {    if(Config->opts = =NULL) {chassis_options_t*opts =chassis_options_new (); Chassis_options_add (opts,"id-generate",0,0, G_option_arg_string, & (Config->id_generate),"id-generate", NULL, NULL, NULL,0); Chassis_options_add (opts,"Dbproxy-user",0,0, G_option_arg_string, & (Config->dbproxy_user),"Dbproxy-user", NULL, NULL, NULL,0); Chassis_options_add (opts,"dbproxy-pwd",0,0, G_option_arg_string, & (CONFIG->DBPROXY_PWD),"dbproxy-pwd", NULL, NULL, NULL,0); Chassis_options_add (opts,"Master-user",0,0, G_option_arg_string, & (Config->master_user),"Master-user", NULL, NULL, NULL,0); Chassis_options_add (opts,"master-pwd",0,0, G_option_arg_string, & (CONFIG->MASTER_PWD),"master-pwd", NULL, NULL, NULL,0); Chassis_options_add (opts,"Slave-user",0,0, G_option_arg_string, & (Config->slave_user),"Slave-user", NULL, NULL, NULL,0); Chassis_options_add (opts,"slave-pwd",0,0, G_option_arg_string, & (CONFIG->SLAVE_PWD),"slave-pwd", NULL, NULL, NULL,0); Config->opts =opts; }    returnConfig->opts;}

Network_mysqld_proxy_plugin_apply_config
Location:/PLUGINS/PROXY/PROXY-PLUGIN.C

intNetwork_mysqld_proxy_plugin_apply_config (Chassis *chas, Chassis_plugin_config *oldconfig) {Gchar*user = null, *PWD = NULL, *user_master = NULL, *pwd_master = NULL, *user_slave = NULL, *pwd_slave =NULL; User= config->Dbproxy_user; PWD= config->dbproxy_pwd; User_master= config->Master_user; Pwd_master= config->master_pwd; User_slave= config->Slave_user; Pwd_slave= config->slave_pwd; Char* Raw_pwd =Decrypt (PWD); Char* Raw_pwd_master =decrypt (Pwd_master); Char* Raw_pwd_slave =decrypt (Pwd_slave); if(Raw_pwd && Raw_pwd_master &&Raw_pwd_slave) {gstring* Hashed_password =g_string_new (NULL);                Network_mysqld_proto_password_hash (Hashed_password, Raw_pwd, strlen (raw_pwd)); /*Master Library setup password*/gstring* Hashed_password_master =g_string_new (NULL);                        Network_mysqld_proto_password_hash (Hashed_password_master, Raw_pwd_master, strlen (Raw_pwd_master)); /*To set a password from a library*/gstring* Hashed_password_slave =g_string_new (NULL);                    Network_mysqld_proto_password_hash (Hashed_password_slave, Raw_pwd_slave, strlen (Raw_pwd_slave)); User_info_hval*hval =user_info_hval_new (Hashed_password, Hashed_password_master, User_master, Hashed_password_slave, User_slave); //G_log_dbproxy (g_critical, "Hashed_password_slave is%s, Len is%d", Hval->hashed_password_slave->str, hval-& Gt;hashed_password_slave->len);Raw_user_info *rwi =raw_user_info_new (user, PWD, null, NULL, User_master, Pwd_master, User_slave, Pwd_slave); G_rw_lock_writer_lock (&bs->User_mgr_lock); if(G_hash_table_lookup (bs->pwd_table, user) = =NULL) {G_hash_table_insert (BS-pwd_table, G_strdup (user), Hval); G_ptr_array_add (BS-Raw_pwds, RWI); } g_rw_lock_writer_unlock (&bs->User_mgr_lock); //G_free (tmp_for_free);G_free (RAW_PWD);}

Dbproxy-user/pwd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.