fix: Cassandra CQL 协议头缺少 flags 字节 + version 方向位错误

cqlSend 写 8 字节头(缺 flags),实际 CQL v4 需要 9 字节。
version byte 0x84 是 response 方向,request 应为 0x04。

同时扩展集成测试至 17 个协议:新增 Memcached、Elasticsearch、
MSSQL、RabbitMQ、MQTT、LDAP、Cassandra、Neo4j、Kafka、SMTP。
This commit is contained in:
ZacharyZcR
2026-06-17 12:51:42 +08:00
parent 9b8e4f3f3b
commit 1c6f3b80d0
4 changed files with 347 additions and 7 deletions
+8 -7
View File
@@ -74,7 +74,7 @@ func (p *CassandraPlugin) createAuthFunc(info *common.HostInfo, config *common.C
//
// [1B version|flags] [2B stream] [1B opcode] [4B length] [body]
const (
cqlVersion = 0x84 // version=4, direction=request
cqlVersion = 0x04 // version=4, direction=request
cqlOpStartup = 0x01
cqlOpAuthRsp = 0x0f
cqlOpQuery = 0x07
@@ -178,12 +178,13 @@ func nextCQLStreamID() uint16 {
func cqlSend(conn net.Conn, opcode byte, body []byte) error {
id := nextCQLStreamID()
// frame: [1B version|flags] [2B stream] [1B opcode] [4B length] [body]
header := make([]byte, 8)
header[0] = cqlVersion
binary.BigEndian.PutUint16(header[1:3], id)
header[3] = opcode
binary.BigEndian.PutUint32(header[4:8], uint32(len(body)))
// CQL v4 frame: [1B version] [1B flags] [2B stream] [1B opcode] [4B length] [body]
header := make([]byte, 9)
header[0] = cqlVersion // 0x04 = request, version 4
header[1] = 0x00 // flags
binary.BigEndian.PutUint16(header[2:4], id)
header[4] = opcode
binary.BigEndian.PutUint32(header[5:9], uint32(len(body)))
buf := append(header, body...)
_, err := conn.Write(buf)