SSLRequestPacket.js 983 B

123456789101112131415161718192021222324252627
  1. // http://dev.mysql.com/doc/internals/en/ssl.html
  2. // http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
  3. var ClientConstants = require('../constants/client');
  4. module.exports = SSLRequestPacket;
  5. function SSLRequestPacket(options) {
  6. options = options || {};
  7. this.clientFlags = options.clientFlags | ClientConstants.CLIENT_SSL;
  8. this.maxPacketSize = options.maxPacketSize;
  9. this.charsetNumber = options.charsetNumber;
  10. }
  11. SSLRequestPacket.prototype.parse = function(parser) {
  12. // TODO: check SSLRequest packet v41 vs pre v41
  13. this.clientFlags = parser.parseUnsignedNumber(4);
  14. this.maxPacketSize = parser.parseUnsignedNumber(4);
  15. this.charsetNumber = parser.parseUnsignedNumber(1);
  16. };
  17. SSLRequestPacket.prototype.write = function(writer) {
  18. writer.writeUnsignedNumber(4, this.clientFlags);
  19. writer.writeUnsignedNumber(4, this.maxPacketSize);
  20. writer.writeUnsignedNumber(1, this.charsetNumber);
  21. writer.writeFiller(23);
  22. };