ssl_request.js 617 B

12345678910111213141516171819202122232425
  1. var ClientConstants = require('../constants/client');
  2. var Packet = require('../packets/packet');
  3. var Charsets = require('../constants/charsets');
  4. function SSLRequest(flags)
  5. {
  6. this.clientFlags = flags | ClientConstants.SSL;
  7. }
  8. SSLRequest.prototype.toPacket = function()
  9. {
  10. var length = 36;
  11. var buffer = new Buffer(length);
  12. var packet = new Packet(0, buffer, 0, length);
  13. buffer.fill(0);
  14. packet.offset = 4;
  15. packet.writeInt32(this.clientFlags);
  16. packet.writeInt32(0); // max packet size. todo: move to config
  17. packet.writeInt8(Charsets.UTF8_GENERAL_CI);
  18. return packet;
  19. };
  20. module.exports = SSLRequest;