File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ const (
24
24
iERR byte = 0xff
25
25
)
26
26
27
+ // https://dev.mysql.com/doc/internals/en/capability-flags.html#packet-Protocol::CapabilityFlags
28
+
27
29
type clientFlag uint32
28
30
29
31
const (
@@ -45,6 +47,13 @@ const (
45
47
clientSecureConn
46
48
clientMultiStatements
47
49
clientMultiResults
50
+ clientPsMultiResults
51
+ clientPluginAuth
52
+ clientConnectAttrs
53
+ clientPluginAuthLenencClientData
54
+ clientExpiredPassword
55
+ clientSessionTrack
56
+ clientDeprecateEOF
48
57
)
49
58
50
59
const (
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
214
214
clientLongPassword |
215
215
clientTransactions |
216
216
clientLocalFiles |
217
+ clientConnectAttrs |
217
218
mc .flags & clientLongFlag
218
219
219
220
if mc .cfg .clientFoundRows {
@@ -228,7 +229,12 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
228
229
// User Password
229
230
scrambleBuff := scramblePassword (cipher , []byte (mc .cfg .passwd ))
230
231
232
+ attrname := []byte ("_client_name" )
233
+ attrvalue := []byte ("Go MySQL Driver" )
234
+ attrlen := len (attrname ) + len (attrvalue ) + 2
235
+
231
236
pktLen := 4 + 4 + 1 + 23 + len (mc .cfg .user ) + 1 + 1 + len (scrambleBuff )
237
+ pktLen += len (attrname ) + len (attrvalue ) + 3
232
238
233
239
// To specify a db name
234
240
if n := len (mc .cfg .dbname ); n > 0 {
@@ -295,6 +301,17 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
295
301
pos += copy (data [pos :], mc .cfg .dbname )
296
302
data [pos ] = 0x00
297
303
}
304
+ pos ++
305
+
306
+ // Connection attributes
307
+ data [pos ] = byte (attrlen )
308
+ pos ++
309
+
310
+ data [pos ] = byte (len (attrname ))
311
+ pos += 1 + copy (data [pos + 1 :], attrname )
312
+
313
+ data [pos ] = byte (len (attrvalue ))
314
+ pos += 1 + copy (data [pos + 1 :], attrvalue )
298
315
299
316
// Send Auth packet
300
317
return mc .writePacket (data )
You can’t perform that action at this time.
0 commit comments