mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
ISSUES-4006 split connection packets
This commit is contained in:
parent
c0d42b764e
commit
57c772e3aa
@ -13,6 +13,19 @@ namespace DB
|
|||||||
namespace MySQLProtocol
|
namespace MySQLProtocol
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum Capability
|
||||||
|
{
|
||||||
|
CLIENT_CONNECT_WITH_DB = 0x00000008,
|
||||||
|
CLIENT_PROTOCOL_41 = 0x00000200,
|
||||||
|
CLIENT_SSL = 0x00000800,
|
||||||
|
CLIENT_TRANSACTIONS = 0x00002000, // TODO
|
||||||
|
CLIENT_SESSION_TRACK = 0x00800000, // TODO
|
||||||
|
CLIENT_SECURE_CONNECTION = 0x00008000,
|
||||||
|
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000,
|
||||||
|
CLIENT_PLUGIN_AUTH = 0x00080000,
|
||||||
|
CLIENT_DEPRECATE_EOF = 0x01000000,
|
||||||
|
};
|
||||||
|
|
||||||
class SSLRequest : public IMySQLReadPacket
|
class SSLRequest : public IMySQLReadPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <Core/MySQL/PacketsConnection.h>
|
#include <Core/MySQL/PacketsConnection.h>
|
||||||
#include <Core/MySQLProtocol.h>
|
#include <IO/ReadHelpers.h>
|
||||||
|
#include <IO/WriteHelpers.h>
|
||||||
|
#include <Core/MySQL/MySQLPackets.h>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -10,6 +12,9 @@ namespace MySQLProtocol
|
|||||||
namespace ConnectionPhase
|
namespace ConnectionPhase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const size_t SCRAMBLE_LENGTH = 20;
|
||||||
|
static const size_t AUTH_PLUGIN_DATA_PART_1_LENGTH = 8;
|
||||||
|
|
||||||
Handshake::Handshake() : connection_id(0x00), capability_flags(0x00), character_set(0x00), status_flags(0x00)
|
Handshake::Handshake() : connection_id(0x00), capability_flags(0x00), character_set(0x00), status_flags(0x00)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -44,7 +49,7 @@ void Handshake::readPayloadImpl(ReadBuffer & payload)
|
|||||||
payload.readStrict((reinterpret_cast<char *>(&capability_flags)) + 2, 2);
|
payload.readStrict((reinterpret_cast<char *>(&capability_flags)) + 2, 2);
|
||||||
|
|
||||||
UInt8 auth_plugin_data_length = 0;
|
UInt8 auth_plugin_data_length = 0;
|
||||||
if (capability_flags & MySQLProtocol::CLIENT_PLUGIN_AUTH)
|
if (capability_flags & Capability::CLIENT_PLUGIN_AUTH)
|
||||||
{
|
{
|
||||||
payload.readStrict(reinterpret_cast<char *>(&auth_plugin_data_length), 1);
|
payload.readStrict(reinterpret_cast<char *>(&auth_plugin_data_length), 1);
|
||||||
}
|
}
|
||||||
@ -54,7 +59,7 @@ void Handshake::readPayloadImpl(ReadBuffer & payload)
|
|||||||
}
|
}
|
||||||
|
|
||||||
payload.ignore(10);
|
payload.ignore(10);
|
||||||
if (capability_flags & MySQLProtocol::CLIENT_SECURE_CONNECTION)
|
if (capability_flags & Capability::CLIENT_SECURE_CONNECTION)
|
||||||
{
|
{
|
||||||
UInt8 part2_length = (SCRAMBLE_LENGTH - AUTH_PLUGIN_DATA_PART_1_LENGTH);
|
UInt8 part2_length = (SCRAMBLE_LENGTH - AUTH_PLUGIN_DATA_PART_1_LENGTH);
|
||||||
auth_plugin_data.resize(SCRAMBLE_LENGTH);
|
auth_plugin_data.resize(SCRAMBLE_LENGTH);
|
||||||
@ -62,7 +67,7 @@ void Handshake::readPayloadImpl(ReadBuffer & payload)
|
|||||||
payload.ignore(1);
|
payload.ignore(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capability_flags & MySQLProtocol::CLIENT_PLUGIN_AUTH)
|
if (capability_flags & Capability::CLIENT_PLUGIN_AUTH)
|
||||||
{
|
{
|
||||||
readNullTerminated(auth_plugin_name, payload);
|
readNullTerminated(auth_plugin_name, payload);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ namespace MySQLProtocol
|
|||||||
|
|
||||||
//const size_t MAX_PACKET_LENGTH = (1 << 24) - 1; // 16 mb
|
//const size_t MAX_PACKET_LENGTH = (1 << 24) - 1; // 16 mb
|
||||||
const size_t SCRAMBLE_LENGTH = 20;
|
const size_t SCRAMBLE_LENGTH = 20;
|
||||||
const size_t AUTH_PLUGIN_DATA_PART_1_LENGTH = 8;
|
|
||||||
const size_t MYSQL_ERRMSG_SIZE = 512;
|
const size_t MYSQL_ERRMSG_SIZE = 512;
|
||||||
const size_t PACKET_HEADER_SIZE = 4;
|
const size_t PACKET_HEADER_SIZE = 4;
|
||||||
const size_t SSL_REQUEST_PAYLOAD_SIZE = 32;
|
const size_t SSL_REQUEST_PAYLOAD_SIZE = 32;
|
||||||
@ -67,19 +66,6 @@ enum StatusFlags
|
|||||||
SERVER_SESSION_STATE_CHANGED = 0x4000
|
SERVER_SESSION_STATE_CHANGED = 0x4000
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Capability
|
|
||||||
{
|
|
||||||
CLIENT_CONNECT_WITH_DB = 0x00000008,
|
|
||||||
CLIENT_PROTOCOL_41 = 0x00000200,
|
|
||||||
CLIENT_SSL = 0x00000800,
|
|
||||||
CLIENT_TRANSACTIONS = 0x00002000, // TODO
|
|
||||||
CLIENT_SESSION_TRACK = 0x00800000, // TODO
|
|
||||||
CLIENT_SECURE_CONNECTION = 0x00008000,
|
|
||||||
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000,
|
|
||||||
CLIENT_PLUGIN_AUTH = 0x00080000,
|
|
||||||
CLIENT_DEPRECATE_EOF = 0x01000000,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Command
|
enum Command
|
||||||
{
|
{
|
||||||
COM_SLEEP = 0x0,
|
COM_SLEEP = 0x0,
|
||||||
|
Loading…
Reference in New Issue
Block a user