Skip to content

Commit 49e2480

Browse files
committed
fix broken build.
1 parent a1d847f commit 49e2480

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

connector_go1.10.go renamed to connector_go1.8.go

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
77
// You can obtain one at http://mozilla.org/MPL/2.0/.
88

9+
// +build go1.8
10+
911
package mysql
1012

1113
import (
@@ -67,20 +69,31 @@ func (c *Config) Connect(ctx context.Context) (driver.Conn, error) {
6769
mc.writeTimeout = mc.cfg.WriteTimeout
6870

6971
// Reading Handshake Initialization Packet
70-
cipher, err := mc.readInitPacket()
72+
authData, plugin, err := mc.readHandshakePacket()
7173
if err != nil {
7274
mc.cleanup()
7375
return nil, err
7476
}
7577

7678
// Send Client Authentication Packet
77-
if err = mc.writeAuthPacket(cipher); err != nil {
79+
authResp, addNUL, err := mc.auth(authData, plugin)
80+
if err != nil {
81+
// try the default auth plugin, if using the requested plugin failed
82+
errLog.Print("could not use requested auth plugin '"+plugin+"': ", err.Error())
83+
plugin = defaultAuthPlugin
84+
authResp, addNUL, err = mc.auth(authData, plugin)
85+
if err != nil {
86+
mc.cleanup()
87+
return nil, err
88+
}
89+
}
90+
if err = mc.writeHandshakeResponsePacket(authResp, addNUL, plugin); err != nil {
7891
mc.cleanup()
7992
return nil, err
8093
}
8194

8295
// Handle response to auth packet, switch methods if possible
83-
if err = handleAuthResult(mc, cipher); err != nil {
96+
if err = mc.handleAuthResult(authData, plugin); err != nil {
8497
// Authentication failed and MySQL has already closed the connection
8598
// (https://dev.mysql.com/doc/internals/en/authentication-fails.html).
8699
// Do not send COM_QUIT, just cleanup and return the error.

driver_go1.10.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
77
// You can obtain one at http://mozilla.org/MPL/2.0/.
88

9+
// +build go1.10
10+
911
package mysql
1012

1113
import (

driver_go1.10_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
77
// You can obtain one at http://mozilla.org/MPL/2.0/.
88

9+
// +build go1.10
10+
911
package mysql
1012

1113
import (

0 commit comments

Comments
 (0)