From 0a8ba1ab6c8e72fc486c9b7fc0172ff108e69d2e Mon Sep 17 00:00:00 2001 From: sunzhengfang Date: Mon, 11 Sep 2017 16:33:03 +0800 Subject: [PATCH] #241 delete useHandshakeV10 in server.xml --- .../dble/backend/mysql/MySQLMessage.java | 8 + .../backend/mysql/nio/MySQLConnection.java | 8 +- .../nio/MySQLConnectionAuthenticator.java | 4 +- .../backend/mysql/nio/MySQLDataSource.java | 4 +- .../dble/config/model/SystemConfig.java | 11 - .../dble/net/FrontendConnection.java | 44 ++-- .../net/handler/FrontendAuthenticator.java | 6 + .../actiontech/dble/net/mysql/AuthPacket.java | 35 +++- .../dble/net/mysql/HandshakePacket.java | 193 ------------------ .../dble/net/mysql/HandshakeV10Packet.java | 102 ++++++--- 10 files changed, 132 insertions(+), 283 deletions(-) delete mode 100644 src/main/java/com/actiontech/dble/net/mysql/HandshakePacket.java diff --git a/src/main/java/com/actiontech/dble/backend/mysql/MySQLMessage.java b/src/main/java/com/actiontech/dble/backend/mysql/MySQLMessage.java index d624dd1d55..77868f1ba9 100644 --- a/src/main/java/com/actiontech/dble/backend/mysql/MySQLMessage.java +++ b/src/main/java/com/actiontech/dble/backend/mysql/MySQLMessage.java @@ -322,4 +322,12 @@ private static Calendar getLocalCalendar() { return cal; } + + public byte[] readBytesWithInputLength(int size) { + byte[] ab = new byte[size]; + System.arraycopy(data, position, ab, 0, ab.length); + position += size; + return ab; + } + } diff --git a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnection.java b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnection.java index 6a12da02e9..3c2c3bf37a 100644 --- a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnection.java +++ b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnection.java @@ -133,7 +133,7 @@ private static long initClientFlags() { private MySQLDataSource pool; private boolean fromSlaveDB; private long threadId; - private HandshakePacket handshake; + private HandshakeV10Packet handshake; private long clientFlags; private boolean isAuthenticated; private String user; @@ -212,11 +212,11 @@ public void setPassword(String password) { this.password = password; } - public HandshakePacket getHandshake() { + public HandshakeV10Packet getHandshake() { return handshake; } - public void setHandshake(HandshakePacket handshake) { + public void setHandshake(HandshakeV10Packet handshake) { this.handshake = handshake; } @@ -526,7 +526,7 @@ public void writeQueueAvailable() { } } - private static byte[] passwd(String pass, HandshakePacket hs) + private static byte[] passwd(String pass, HandshakeV10Packet hs) throws NoSuchAlgorithmException { if (pass == null || pass.length() == 0) { return null; diff --git a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnectionAuthenticator.java b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnectionAuthenticator.java index 57c616b72a..2c71531c9e 100644 --- a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnectionAuthenticator.java +++ b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLConnectionAuthenticator.java @@ -61,7 +61,7 @@ public void handle(byte[] data) { try { switch (data[4]) { case OkPacket.FIELD_COUNT: - HandshakePacket packet = source.getHandshake(); + HandshakeV10Packet packet = source.getHandshake(); if (packet == null) { processHandShakePacket(data); // send auth packet @@ -114,7 +114,7 @@ public void handle(byte[] data) { } private void processHandShakePacket(byte[] data) { - HandshakePacket packet = new HandshakePacket(); + HandshakeV10Packet packet = new HandshakeV10Packet(); packet.read(data); source.setHandshake(packet); source.setThreadId(packet.getThreadId()); diff --git a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLDataSource.java b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLDataSource.java index 00b9c1a26f..e76f23d2ab 100644 --- a/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLDataSource.java +++ b/src/main/java/com/actiontech/dble/backend/mysql/nio/MySQLDataSource.java @@ -81,7 +81,7 @@ private long getClientFlags() { } - private byte[] passwd(String pass, HandshakePacket hs) throws NoSuchAlgorithmException { + private byte[] passwd(String pass, HandshakeV10Packet hs) throws NoSuchAlgorithmException { if (pass == null || pass.length() == 0) { return null; } @@ -119,7 +119,7 @@ public boolean testConnection(String schema) throws IOException { BinaryPacket bin1 = new BinaryPacket(); bin1.read(in); - HandshakePacket handshake = new HandshakePacket(); + HandshakeV10Packet handshake = new HandshakeV10Packet(); handshake.read(bin1); /** diff --git a/src/main/java/com/actiontech/dble/config/model/SystemConfig.java b/src/main/java/com/actiontech/dble/config/model/SystemConfig.java index c731d64f10..43bc0a1853 100644 --- a/src/main/java/com/actiontech/dble/config/model/SystemConfig.java +++ b/src/main/java/com/actiontech/dble/config/model/SystemConfig.java @@ -128,8 +128,6 @@ public final class SystemConfig { private int useCompression = 0; private int useSqlStat = 1; - //TODO: DELETE ,just USE HandshakeV10Packet - private int useHandshakeV10 = 1; private int checkTableConsistency = 0; private long checkTableConsistencyPeriod = CHECK_TABLE_CONSISTENCY_PERIOD; private int useGlobleTableCheck = 1; @@ -745,15 +743,6 @@ public void setCheckTableConsistencyPeriod(long checkTableConsistencyPeriod) { this.checkTableConsistencyPeriod = checkTableConsistencyPeriod; } - public int getUseHandshakeV10() { - return useHandshakeV10; - } - - @SuppressWarnings("unused") - public void setUseHandshakeV10(int useHandshakeV10) { - this.useHandshakeV10 = useHandshakeV10; - } - public int getNestLoopRowsSize() { return nestLoopRowsSize; } diff --git a/src/main/java/com/actiontech/dble/net/FrontendConnection.java b/src/main/java/com/actiontech/dble/net/FrontendConnection.java index 8b3f98426a..182678e8ad 100644 --- a/src/main/java/com/actiontech/dble/net/FrontendConnection.java +++ b/src/main/java/com/actiontech/dble/net/FrontendConnection.java @@ -420,33 +420,18 @@ public void register() throws IOException { System.arraycopy(rand2, 0, rand, rand1.length, rand2.length); this.seed = rand; - // send auth data - boolean useHandshakeV10 = DbleServer.getInstance().getConfig().getSystem().getUseHandshakeV10() == 1; - if (useHandshakeV10) { - HandshakeV10Packet hs = new HandshakeV10Packet(); - hs.setPacketId(0); - hs.setProtocolVersion(Versions.PROTOCOL_VERSION); - hs.setServerVersion(Versions.getServerVersion()); - hs.setThreadId(id); - hs.setSeed(rand1); - hs.setServerCapabilities(getServerCapabilities()); - hs.setServerCharsetIndex((byte) (charsetIndex & 0xff)); - hs.setServerStatus(2); - hs.setRestOfScrambleBuff(rand2); - hs.write(this); - } else { - HandshakePacket hs = new HandshakePacket(); - hs.setPacketId(0); - hs.setProtocolVersion(Versions.PROTOCOL_VERSION); - hs.setServerVersion(Versions.getServerVersion()); - hs.setThreadId(id); - hs.setSeed(rand1); - hs.setServerCapabilities(getServerCapabilities()); - hs.setServerCharsetIndex((byte) (charsetIndex & 0xff)); - hs.setServerStatus(2); - hs.setRestOfScrambleBuff(rand2); - hs.write(this); - } + + HandshakeV10Packet hs = new HandshakeV10Packet(); + hs.setPacketId(0); + hs.setProtocolVersion(Versions.PROTOCOL_VERSION); // [0a] protocol version V10 + hs.setServerVersion(Versions.getServerVersion()); // 版本号 + hs.setThreadId(id); + hs.setSeed(rand1); + hs.setServerCapabilities(getServerCapabilities()); + hs.setServerCharsetIndex((byte) (charsetIndex & 0xff)); + hs.setServerStatus(2); + hs.setRestOfScrambleBuff(rand2); + hs.write(this); // asynread response this.asynRead(); @@ -510,10 +495,7 @@ protected int getServerCapabilities() { flag |= Capabilities.CLIENT_SECURE_CONNECTION; flag |= Capabilities.CLIENT_MULTI_STATEMENTS; flag |= Capabilities.CLIENT_MULTI_RESULTS; - boolean useHandshakeV10 = DbleServer.getInstance().getConfig().getSystem().getUseHandshakeV10() == 1; - if (useHandshakeV10) { - flag |= Capabilities.CLIENT_PLUGIN_AUTH; - } + flag |= Capabilities.CLIENT_PLUGIN_AUTH; return flag; } diff --git a/src/main/java/com/actiontech/dble/net/handler/FrontendAuthenticator.java b/src/main/java/com/actiontech/dble/net/handler/FrontendAuthenticator.java index 25e1a70d57..6446d434c2 100644 --- a/src/main/java/com/actiontech/dble/net/handler/FrontendAuthenticator.java +++ b/src/main/java/com/actiontech/dble/net/handler/FrontendAuthenticator.java @@ -67,6 +67,12 @@ public void handle(byte[] data) { AuthPacket auth = new AuthPacket(); auth.read(data); + //check mysql_native_password + if (!"mysql_native_password".equals(auth.getAuthPlugin())) { + failure(ErrorCode.ER_ACCESS_DENIED_ERROR, "only mysql_native_password auth check is supported"); + return; + } + // check user if (!checkUser(auth.getUser(), source.getHost())) { failure(ErrorCode.ER_ACCESS_DENIED_ERROR, "Access denied for user '" + auth.getUser() + "' with host '" + source.getHost() + "'"); diff --git a/src/main/java/com/actiontech/dble/net/mysql/AuthPacket.java b/src/main/java/com/actiontech/dble/net/mysql/AuthPacket.java index 9ab04f1cef..a18ca6d4aa 100644 --- a/src/main/java/com/actiontech/dble/net/mysql/AuthPacket.java +++ b/src/main/java/com/actiontech/dble/net/mysql/AuthPacket.java @@ -34,6 +34,9 @@ import java.io.OutputStream; import java.nio.ByteBuffer; +import static com.actiontech.dble.config.Capabilities.CLIENT_PLUGIN_AUTH; + + /** * From client to server during initial handshake. *

@@ -63,24 +66,25 @@ public class AuthPacket extends MySQLPacket { private String user; private byte[] password; private String database; + private String authPlugin; public void read(byte[] data) { MySQLMessage mm = new MySQLMessage(data); packetLength = mm.readUB3(); packetId = mm.read(); - clientFlags = mm.readUB4(); - maxPacketSize = mm.readUB4(); - charsetIndex = (mm.read() & 0xff); + clientFlags = mm.readUB4(); // capability flags + maxPacketSize = mm.readUB4(); //maxoacketSize + charsetIndex = (mm.read() & 0xff); // character set // read extra int current = mm.position(); int len = (int) mm.readLength(); - if (len > 0 && len < FILLER.length) { + if (len > 0 && len < FILLER.length) { //reserved byte[] ab = new byte[len]; System.arraycopy(mm.bytes(), mm.position(), ab, 0, len); this.extra = ab; } mm.position(current + FILLER.length); - user = mm.readStringWithNull(); + user = mm.readStringWithNull(); //user name end by a [00] password = mm.readBytesWithLength(); if (((clientFlags & Capabilities.CLIENT_CONNECT_WITH_DB) != 0) && mm.hasRemaining()) { database = mm.readStringWithNull(); @@ -88,6 +92,10 @@ public void read(byte[] data) { database = database.toLowerCase(); } } + + if ((clientFlags & CLIENT_PLUGIN_AUTH) != 0) { + authPlugin = mm.readStringWithNull(); + } } public void write(OutputStream out) throws IOException { @@ -119,10 +127,10 @@ public void write(BackendAIOConnection c) { ByteBuffer buffer = c.allocate(); BufferUtil.writeUB3(buffer, calcPacketSize()); buffer.put(packetId); - BufferUtil.writeUB4(buffer, clientFlags); - BufferUtil.writeUB4(buffer, maxPacketSize); - buffer.put((byte) charsetIndex); - buffer = c.writeToBuffer(FILLER, buffer); + BufferUtil.writeUB4(buffer, clientFlags); // capability flags + BufferUtil.writeUB4(buffer, maxPacketSize); // max-packet size + buffer.put((byte) charsetIndex); //character set + buffer = c.writeToBuffer(FILLER, buffer); // reserved (all [0]) if (user == null) { buffer = c.checkWriteBuffer(buffer, 1, true); buffer.put((byte) 0); @@ -146,6 +154,11 @@ public void write(BackendAIOConnection c) { buffer = c.checkWriteBuffer(buffer, databaseData.length + 1, true); BufferUtil.writeWithNull(buffer, databaseData); } + if ((clientFlags & CLIENT_PLUGIN_AUTH) != 0) { + //if use the mysql_native_password is used for auth this need be replay + BufferUtil.writeWithNull(buffer, "mysql_native_password".getBytes()); + } + c.write(buffer); } @@ -218,4 +231,8 @@ public String getDatabase() { public void setDatabase(String database) { this.database = database; } + + public String getAuthPlugin() { + return authPlugin; + } } diff --git a/src/main/java/com/actiontech/dble/net/mysql/HandshakePacket.java b/src/main/java/com/actiontech/dble/net/mysql/HandshakePacket.java deleted file mode 100644 index 397fffdedb..0000000000 --- a/src/main/java/com/actiontech/dble/net/mysql/HandshakePacket.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software;Designed and Developed mainly by many Chinese - * opensource volunteers. you can redistribute it and/or modify it under the - * terms of the GNU General Public License version 2 only, as published by the - * Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Any questions about this component can be directed to it's project Web address - * https://code.google.com/p/opencloudb/. - * - */ -package com.actiontech.dble.net.mysql; - -import com.actiontech.dble.backend.mysql.BufferUtil; -import com.actiontech.dble.backend.mysql.MySQLMessage; -import com.actiontech.dble.net.FrontendConnection; - -import java.nio.ByteBuffer; - -/** - * From server to client during initial handshake. - *

- *

- * Bytes                        Name
- * -----                        ----
- * 1                            protocol_version
- * n (Null-Terminated String)   server_version
- * 4                            thread_id
- * 8                            scramble_buff
- * 1                            (filler) always 0x00
- * 2                            server_capabilities
- * 1                            server_language
- * 2                            server_status
- * 13                           (filler) always 0x00 ...
- * 13                           rest of scramble_buff (4.1)
- *
- * @see http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#Handshake_Initialization_Packet
- * 
- * - * @author mycat - */ -public class HandshakePacket extends MySQLPacket { - private static final byte[] FILLER_13 = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - - private byte protocolVersion; - private byte[] serverVersion; - private long threadId; - private byte[] seed; - private int serverCapabilities; - private byte serverCharsetIndex; - private int serverStatus; - private byte[] restOfScrambleBuff; - - public void read(BinaryPacket bin) { - packetLength = bin.packetLength; - packetId = bin.packetId; - MySQLMessage mm = new MySQLMessage(bin.getData()); - protocolVersion = mm.read(); - serverVersion = mm.readBytesWithNull(); - threadId = mm.readUB4(); - seed = mm.readBytesWithNull(); - serverCapabilities = mm.readUB2(); - serverCharsetIndex = mm.read(); - serverStatus = mm.readUB2(); - mm.move(13); - restOfScrambleBuff = mm.readBytesWithNull(); - } - - public void read(byte[] data) { - MySQLMessage mm = new MySQLMessage(data); - packetLength = mm.readUB3(); - packetId = mm.read(); - protocolVersion = mm.read(); - serverVersion = mm.readBytesWithNull(); - threadId = mm.readUB4(); - seed = mm.readBytesWithNull(); - serverCapabilities = mm.readUB2(); - serverCharsetIndex = mm.read(); - serverStatus = mm.readUB2(); - mm.move(13); - restOfScrambleBuff = mm.readBytesWithNull(); - } - - public void write(FrontendConnection c) { - ByteBuffer buffer = c.allocate(); - BufferUtil.writeUB3(buffer, calcPacketSize()); - buffer.put(packetId); - buffer.put(protocolVersion); - BufferUtil.writeWithNull(buffer, serverVersion); - BufferUtil.writeUB4(buffer, threadId); - BufferUtil.writeWithNull(buffer, seed); - BufferUtil.writeUB2(buffer, serverCapabilities); - buffer.put(serverCharsetIndex); - BufferUtil.writeUB2(buffer, serverStatus); - buffer.put(FILLER_13); - // buffer.position(buffer.position() + 13); - BufferUtil.writeWithNull(buffer, restOfScrambleBuff); - c.write(buffer); - } - - @Override - public int calcPacketSize() { - int size = 1; - size += serverVersion.length; // n - size += 5; // 1+4 - size += seed.length; // 8 - size += 19; // 1+2+1+2+13 - size += restOfScrambleBuff.length; // 12 - size += 1; // 1 - return size; - } - - @Override - protected String getPacketInfo() { - return "MySQL Handshake Packet"; - } - - public byte getProtocolVersion() { - return protocolVersion; - } - - public void setProtocolVersion(byte protocolVersion) { - this.protocolVersion = protocolVersion; - } - - public byte[] getServerVersion() { - return serverVersion; - } - - public void setServerVersion(byte[] serverVersion) { - this.serverVersion = serverVersion; - } - - public long getThreadId() { - return threadId; - } - - public void setThreadId(long threadId) { - this.threadId = threadId; - } - - public byte[] getSeed() { - return seed; - } - - public void setSeed(byte[] seed) { - this.seed = seed; - } - - public int getServerCapabilities() { - return serverCapabilities; - } - - public void setServerCapabilities(int serverCapabilities) { - this.serverCapabilities = serverCapabilities; - } - - public byte getServerCharsetIndex() { - return serverCharsetIndex; - } - - public void setServerCharsetIndex(byte serverCharsetIndex) { - this.serverCharsetIndex = serverCharsetIndex; - } - - public int getServerStatus() { - return serverStatus; - } - - public void setServerStatus(int serverStatus) { - this.serverStatus = serverStatus; - } - - public byte[] getRestOfScrambleBuff() { - return restOfScrambleBuff; - } - - public void setRestOfScrambleBuff(byte[] restOfScrambleBuff) { - this.restOfScrambleBuff = restOfScrambleBuff; - } -} diff --git a/src/main/java/com/actiontech/dble/net/mysql/HandshakeV10Packet.java b/src/main/java/com/actiontech/dble/net/mysql/HandshakeV10Packet.java index 19586ac3b4..ef2101bd94 100644 --- a/src/main/java/com/actiontech/dble/net/mysql/HandshakeV10Packet.java +++ b/src/main/java/com/actiontech/dble/net/mysql/HandshakeV10Packet.java @@ -23,14 +23,16 @@ */ package com.actiontech.dble.net.mysql; + import com.actiontech.dble.backend.mysql.BufferUtil; +import com.actiontech.dble.backend.mysql.MySQLMessage; import com.actiontech.dble.config.Capabilities; import com.actiontech.dble.net.FrontendConnection; import java.nio.ByteBuffer; /** - * From server to client during initial handshake. + * From mycat server to client during initial handshake. *

*

  * Bytes                        Name
@@ -58,7 +60,6 @@
  * string[NUL]    auth-plugin name
  * }
  *
- * @see http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#Protocol::HandshakeV10
  * 
* * @author CrazyPig @@ -90,28 +91,14 @@ public void write(FrontendConnection c) { buffer.put(serverCharsetIndex); BufferUtil.writeUB2(buffer, serverStatus); BufferUtil.writeUB2(buffer, (serverCapabilities >> 16)); // capability flags (upper 2 bytes) - if ((serverCapabilities & Capabilities.CLIENT_PLUGIN_AUTH) != 0) { - if (restOfScrambleBuff.length <= 13) { - buffer.put((byte) (seed.length + 13)); - } else { - buffer.put((byte) (seed.length + restOfScrambleBuff.length)); - } - } else { - buffer.put((byte) 0); - } + buffer.put((byte) (seed.length + 13)); buffer.put(FILLER_10); - if ((serverCapabilities & Capabilities.CLIENT_SECURE_CONNECTION) != 0) { - buffer.put(restOfScrambleBuff); - // restOfScrambleBuff.length always to be 12 - if (restOfScrambleBuff.length < 13) { - for (int i = 13 - restOfScrambleBuff.length; i > 0; i--) { - buffer.put((byte) 0); - } - } - } - if ((serverCapabilities & Capabilities.CLIENT_PLUGIN_AUTH) != 0) { - BufferUtil.writeWithNull(buffer, authPluginName); + buffer.put(restOfScrambleBuff); //auth-plugin-data-part-2 + // restOfScrambleBuff.length always to be 12 + for (int i = 13 - restOfScrambleBuff.length; i > 0; i--) { + buffer.put((byte) 0); } + BufferUtil.writeWithNull(buffer, authPluginName); c.write(buffer); } @@ -128,20 +115,73 @@ public int calcPacketSize() { size += 2; // capability flags (upper 2 bytes) size += 1; size += 10; // reserved (all [00]) - if ((serverCapabilities & Capabilities.CLIENT_SECURE_CONNECTION) != 0) { - // restOfScrambleBuff.length always to be 12 - if (restOfScrambleBuff.length <= 13) { - size += 13; - } else { - size += restOfScrambleBuff.length; - } + // restOfScrambleBuff.length always to be 12 + size += 13; + size += (authPluginName.length + 1); // auth-plugin name + return size; + } + + + /** + * 这里假设两个方法读取的都是同一个中协议的结果 + * @param bin + */ + public void read(BinaryPacket bin) { + packetLength = bin.packetLength; + packetId = bin.packetId; + MySQLMessage mm = new MySQLMessage(bin.getData()); + protocolVersion = mm.read(); + serverVersion = mm.readBytesWithNull(); + threadId = mm.readUB4(); + seed = mm.readBytesWithNull(); + serverCapabilities = mm.readUB2(); + serverCharsetIndex = mm.read(); + serverStatus = mm.readUB2(); + //get the complete serverCapabilities + serverCapabilities = serverCapabilities | (mm.readUB2() << 16); + //length of auth-plugin-data for 1 byte + int authPluginData = mm.read(); + mm.move(10); + restOfScrambleBuff = mm.readBytesWithInputLength(authPluginData - 9 > 12 ? 12 : authPluginData - 9); + mm.move(1); + if ((serverCapabilities & Capabilities.CLIENT_PLUGIN_AUTH) != 0) { + authPluginName = mm.readBytesWithNull(); } + } + + public void read(byte[] data) { + MySQLMessage mm = new MySQLMessage(data); + packetLength = mm.readUB3(); + packetId = mm.read(); + protocolVersion = mm.read(); + serverVersion = mm.readBytesWithNull(); + threadId = mm.readUB4(); + seed = mm.readBytesWithNull(); + serverCapabilities = mm.readUB2(); + serverCharsetIndex = mm.read(); + serverStatus = mm.readUB2(); + //get the complete serverCapabilities + serverCapabilities = serverCapabilities | (mm.readUB2() << 16); + //length of auth-plugin-data for 1 byte + int authPluginData = mm.read(); + mm.move(10); + restOfScrambleBuff = mm.readBytesWithInputLength(authPluginData - 9 > 12 ? 12 : authPluginData - 9); + mm.move(1); if ((serverCapabilities & Capabilities.CLIENT_PLUGIN_AUTH) != 0) { - size += (authPluginName.length + 1); // auth-plugin name + authPluginName = mm.readBytesWithNull(); } - return size; } + + + + + + + + + + @Override protected String getPacketInfo() { return "MySQL HandshakeV10 Packet";