提交 93b2e020 编写于 作者: W wgs13579 提交者: guangshu.wgs

support client_ip cross obproxy to observer

上级 4e8dbd5f
......@@ -5137,6 +5137,7 @@ void ObMysqlSM::do_internal_request()
// current not support compress to client
handshake.disable_use_compress();
handshake.enable_session_track();
handshake.enable_connection_attr();
// use cs id (proxy connection id)
// before receive ok pkt from observer, the conn_id_ is always 0, means has not set
uint32_t conn_id = client_session_->get_cs_id();
......
......@@ -189,7 +189,7 @@ int ObMysqlPacketRewriter::add_connect_attr(const char *key, const common::ObStr
int ObMysqlPacketRewriter::rewrite_handshake_response_packet(
ObMysqlAuthRequest &orig_auth_req,
const ObHandshakeResponseParam &param,
ObHandshakeResponseParam &param,
OMPKHandshakeResponse &tg_hsr)
{
int ret = OB_SUCCESS;
......@@ -211,6 +211,18 @@ int ObMysqlPacketRewriter::rewrite_handshake_response_packet(
tg_hsr.set_database(ObString::make_empty_string());
}
// find client_ip
ObStringKV string_kv;
for (int64_t i = 0; OB_SUCC(ret) && i < tg_hsr.get_connect_attrs().count(); ++i) {
string_kv = tg_hsr.get_connect_attrs().at(i);
if (0 == string_kv.key_.case_compare(OB_MYSQL_CLIENT_IP)) {
if (!string_kv.value_.empty()) {
snprintf(param.client_ip_buf_, ObHandshakeResponseParam::OB_MAX_IP_BUF_LEN, "%.*s", string_kv.value_.length(), string_kv.value_.ptr());
}
break;
}
}
// reset before add
tg_hsr.reset_connect_attr();
// 4. add obproxy specified connect attrs:
......
......@@ -94,7 +94,7 @@ public:
const bool need_save_sys_var);
static int rewrite_handshake_response_packet(ObMysqlAuthRequest &orig_auth_req,
const ObHandshakeResponseParam &param,
ObHandshakeResponseParam &param,
obmysql::OMPKHandshakeResponse &tg_hsr);
static int add_connect_attr(const char *key,
......
......@@ -55,6 +55,11 @@ public:
server_capabilities_upper_.capability_flag_.OB_SERVER_SESSION_VARIABLE_TRACK = 1;
}
void enable_connection_attr()
{
server_capabilities_upper_.capability_flag_.OB_SERVER_CONNECT_ATTRS = 1;
}
void disable_ssl()
{
server_capabilities_lower_.capability_flag_.OB_SERVER_SSL = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册