Skip to content

Commit

Permalink
code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Nov 11, 2024
1 parent a343408 commit 782166f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ func (mc *mysqlConn) readHandshakePacket() (data []byte, plugin string, err erro
if len(data) > pos {
// character set [1 byte]
// status flags [2 bytes]
pos += 1 + 2
pos += 3
// capability flags (upper 2 bytes) [2 bytes]
mc.flags |= clientFlag(binary.LittleEndian.Uint16(data[pos:pos+2])) << 16
pos += 2
// length of auth-plugin-data [1 byte]
// reserved (all [00]) [10 bytes]
pos += 2 + 1 + 10
pos += 11

// second part of the password cipher [minimum 13 bytes],
// where len=MAX(13, length of auth-plugin-data - 8)
Expand Down Expand Up @@ -266,7 +267,7 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
mc.flags&clientConnectAttrs |
mc.flags&clientLongFlag

serverSupportClientConnectAttrs := mc.flags&clientConnectAttrs != 0
sendConnectAttrs := mc.flags&clientConnectAttrs != 0

if mc.cfg.ClientFoundRows {
clientFlags |= clientFoundRows
Expand Down Expand Up @@ -299,9 +300,9 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
pktLen += n + 1
}

var connAttrsLEI []byte
// encode length of the connection attributes
if serverSupportClientConnectAttrs {
var connAttrsLEI []byte
if sendConnectAttrs {
var connAttrsLEIBuf [9]byte
connAttrsLen := len(mc.connector.encodedAttributes)
connAttrsLEI = appendLengthEncodedInteger(connAttrsLEIBuf[:0], uint64(connAttrsLen))
Expand Down Expand Up @@ -389,7 +390,7 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
pos++

// Connection Attributes
if serverSupportClientConnectAttrs {
if sendConnectAttrs {
pos += copy(data[pos:], connAttrsLEI)
pos += copy(data[pos:], []byte(mc.connector.encodedAttributes))
}
Expand Down

0 comments on commit 782166f

Please sign in to comment.