Exemple #1
0
        private void Negotiate(MySqlStream channel)
        {
            var body = channel.ReadPacket();
            HandshakeInitializationPacket handshakePacket = new HandshakeInitializationPacket();

            handshakePacket.FromBytes(body);
            ConnectionId = handshakePacket.ThreadId;

            _logger.LogInformation("Handshake initialization packet received, prepare the client authentication packet to send");

            ClientAuthenticationPacket clientAuth = new ClientAuthenticationPacket();

            clientAuth.CharsetNumber = CharsetNumber;
            clientAuth.UserName      = UserName;
            clientAuth.Password      = Password;
            clientAuth.DatabaseName  = DefaultSchema;
            clientAuth.ScrumbleBuff  = handshakePacket.EncryptionSeed;

            var clientAuthPkgBody = clientAuth.ToBytes();

            channel.SendPacket(clientAuthPkgBody);
            _logger.LogInformation("Client Authentication Packet is sent out.");

            channel.ReadPacket();
        }
Exemple #2
0
        public void Quit()
        {
            QuitCommandPacket quit = new QuitCommandPacket();

            _channel.SendPacket(quit.ToBytes());
        }