ssl_request.js 633 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const ClientConstants = require('../constants/client');
  3. const Packet = require('../packets/packet');
  4. class SSLRequest {
  5. constructor(flags, charset) {
  6. this.clientFlags = flags | ClientConstants.SSL;
  7. this.charset = charset;
  8. }
  9. toPacket() {
  10. const length = 36;
  11. const buffer = Buffer.allocUnsafe(length);
  12. const 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(this.charset);
  18. return packet;
  19. }
  20. }
  21. module.exports = SSLRequest;