@@ -64,6 +64,7 @@ function FakeConnection(socket) {
64
64
this . _handshakeInitializationPacket = null ;
65
65
this . _clientAuthenticationPacket = null ;
66
66
this . _oldPasswordPacket = null ;
67
+ this . _authSwitchResponse = null ;
67
68
this . _handshakeOptions = { } ;
68
69
69
70
socket . on ( 'data' , this . _handleData . bind ( this ) ) ;
@@ -268,7 +269,9 @@ FakeConnection.prototype._parsePacket = function(header) {
268
269
case Packets . ClientAuthenticationPacket :
269
270
this . _clientAuthenticationPacket = packet ;
270
271
if ( this . _handshakeOptions . oldPassword ) {
271
- this . _sendPacket ( new Packets . UseOldPasswordPacket ( ) ) ;
272
+ this . _sendPacket ( new Packets . AuthenticationMethodSwitchRequestPacket ( { methodName : 'mysql_old_password' } ) ) ;
273
+ } else if ( this . _handshakeOptions . forceAuthSwitch ) {
274
+ this . _sendPacket ( new Packets . AuthenticationMethodSwitchRequestPacket ( { pluginData : Buffer . from ( '00112233445566778899AABBCCDDEEFF0102030400' , 'hex' ) } ) ) ;
272
275
} else if ( this . _handshakeOptions . password === 'passwd' ) {
273
276
var expected = Buffer . from ( '3DA0ADA7C9E1BB3A110575DF53306F9D2DE7FD09' , 'hex' ) ;
274
277
this . _sendAuthResponse ( packet , expected ) ;
@@ -287,6 +290,13 @@ FakeConnection.prototype._parsePacket = function(header) {
287
290
288
291
var expected = Auth . scramble323 ( this . _handshakeInitializationPacket . scrambleBuff ( ) , this . _handshakeOptions . password ) ;
289
292
293
+ this . _sendAuthResponse ( packet , expected ) ;
294
+ break ;
295
+ case Packets . AuthenticationSwitchResponsePacket :
296
+ this . _authSwitchResponse = packet ;
297
+
298
+ var expected = Auth . token ( this . _handshakeOptions . password , Buffer . from ( '00112233445566778899AABBCCDDEEFF01020304' , 'hex' ) ) ;
299
+
290
300
this . _sendAuthResponse ( packet , expected ) ;
291
301
break ;
292
302
case Packets . ComQueryPacket :
@@ -355,6 +365,10 @@ FakeConnection.prototype._determinePacket = function(header) {
355
365
return Packets . OldPasswordPacket ;
356
366
}
357
367
368
+ if ( this . _handshakeOptions . forceAuthSwitch && ! this . _authSwitchResponse ) {
369
+ return Packets . AuthenticationSwitchResponsePacket ;
370
+ }
371
+
358
372
var firstByte = this . _parser . peak ( ) ;
359
373
switch ( firstByte ) {
360
374
case 0x01 : return Packets . ComQuitPacket ;
0 commit comments