首页 / 更多教程 / dbproxy-user/pwd
dbproxy-user/pwd
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了dbproxy-user/pwd,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4495字,纯文字阅读大概需要7分钟。
内容图文
配置文件
#dbproxy账号密码与real 主mysql 和 从mysql 隔离
dbproxy-user=test
dbproxy-pwd=7O7YJJEK
master-user = master
master-pwd = 7O7YJJEK
slave-user = slave
slave-pwd = 7O7YJJEK
struct chassis_plugin_config
位置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
位置:/plugins/proxy/proxy-plugin.c
chassis_plugin_config * network_mysqld_proxy_plugin_new(void) {
...
config = g_new0(chassis_plugin_config, 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
位置:/plugins/proxy/proxy-plugin.c
void network_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
位置:/plugins/proxy/proxy-plugin.c
static chassis_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;
}
return config->opts;
}
network_mysqld_proxy_plugin_apply_config
位置:/plugins/proxy/proxy-plugin.c
int network_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));
/*
主库 设置密码
*/
GString* hashed_password_master = g_string_new(NULL);
network_mysqld_proto_password_hash(hashed_password_master, raw_pwd_master, strlen(raw_pwd_master));
/*
从库 设置密码
*/
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->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
标签:sla 配置 inf table 设置密码 ssi ati lookup ast
本文系统来源:https://www.cnblogs.com/taek/p/8353971.html
内容总结
以上是互联网集市为您收集整理的dbproxy-user/pwd全部内容,希望文章能够帮你解决dbproxy-user/pwd所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。