File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ const (
2424 iERR byte = 0xff
2525)
2626
27+ // https://dev.mysql.com/doc/internals/en/capability-flags.html#packet-Protocol::CapabilityFlags
28+
2729type clientFlag uint32
2830
2931const (
@@ -45,6 +47,13 @@ const (
4547 clientSecureConn
4648 clientMultiStatements
4749 clientMultiResults
50+ clientPsMultiResults
51+ clientPluginAuth
52+ clientConnectAttrs
53+ clientPluginAuthLenencClientData
54+ clientExpiredPassword
55+ clientSessionTrack
56+ clientDeprecateEOF
4857)
4958
5059const (
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
214214 clientLongPassword |
215215 clientTransactions |
216216 clientLocalFiles |
217+ clientConnectAttrs |
217218 mc .flags & clientLongFlag
218219
219220 if mc .cfg .clientFoundRows {
@@ -228,7 +229,12 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
228229 // User Password
229230 scrambleBuff := scramblePassword (cipher , []byte (mc .cfg .passwd ))
230231
232+ attrname := []byte ("_client_name" )
233+ attrvalue := []byte ("Go MySQL Driver" )
234+ attrlen := len (attrname ) + len (attrvalue ) + 2
235+
231236 pktLen := 4 + 4 + 1 + 23 + len (mc .cfg .user ) + 1 + 1 + len (scrambleBuff )
237+ pktLen += len (attrname ) + len (attrvalue ) + 3
232238
233239 // To specify a db name
234240 if n := len (mc .cfg .dbname ); n > 0 {
@@ -295,6 +301,17 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
295301 pos += copy (data [pos :], mc .cfg .dbname )
296302 data [pos ] = 0x00
297303 }
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 )
298315
299316 // Send Auth packet
300317 return mc .writePacket (data )
You can’t perform that action at this time.
0 commit comments