ssl-request.js 848 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Capabilities = require('../../const/capabilities');
  3. /**
  4. * Send SSL Request packet.
  5. * see : https://mariadb.com/kb/en/library/1-connecting-connecting/#sslrequest-packet
  6. *
  7. * @param cmd current command
  8. * @param out output writer
  9. * @param info client information
  10. * @param opts connection options
  11. */
  12. module.exports.send = function sendSSLRequest(cmd, out, info, opts) {
  13. out.startPacket(cmd);
  14. out.writeInt32(Number(info.clientCapabilities & BigInt(0xffffffff)));
  15. out.writeInt32(1024 * 1024 * 1024); // max packet size
  16. out.writeInt8(opts.collation.index);
  17. for (let i = 0; i < 19; i++) {
  18. out.writeInt8(0);
  19. }
  20. if (info.serverCapabilities & Capabilities.MYSQL) {
  21. out.writeInt32(0);
  22. } else {
  23. out.writeInt32(Number(info.clientCapabilities >> BigInt(32)));
  24. }
  25. out.flushBuffer(true);
  26. };