Comparing version 0.10.2 to 0.10.3
@@ -1,6 +0,11 @@ | ||
// top version is work in progres | ||
0.10.3 | ||
Backlog: | ||
- Multiple results support in binary protocol #27 | ||
- Apply timezone from config to DATETIME values with no tz #15 | ||
- custom typeCast handlers in generated parser #39 | ||
0.10.3 | ||
- various ssl fixes and refactoring (ssl was broken for some time) 213d375f7263cb6f5e724fdac3ea156ccee4bbd4 | ||
- Server protocol: handle null values serialisation | ||
(Michael Muturi Njonge) #36 831b2a100795f36649f0c3d79b7839a95f771a05 | ||
0.10.2 | ||
@@ -7,0 +12,0 @@ - return DECIMAL and NEWDECIMAL as string in binary prot #40 969fba6ff1dbf14d53d3efc9f94083b8306cf0b5 |
@@ -10,4 +10,5 @@ var fs = require('fs'); | ||
ssl: { | ||
key: fs.readFileSync('./certs/client-key.pem'), | ||
cert: fs.readFileSync('./certs/client-cert.pem') | ||
//key: fs.readFileSync('./certs/client-key.pem'), | ||
//cert: fs.readFileSync('./certs/client-cert.pem') | ||
ca: fs.readFileSync('./certs/ca-cert.pem') | ||
} | ||
@@ -14,0 +15,0 @@ }); |
@@ -19,7 +19,4 @@ var Command = require('./command'); | ||
ClientHandshake.prototype.sendSSLRequest = function(connection) { | ||
// TODO: I don't like the fact that ssl flags packet to be shorter AND set flag bit | ||
// should be something like { ssl: true, sslRequest: true } for sslRequest packet | ||
// and { ..., ssl: true } for handshakeReply packet | ||
var sslRequest = new Packets.HandshakeResponse({ ssl: true, flags: this.clientFlags }); | ||
connection.writePacket(sslRequest.toPacket(1)); | ||
var sslRequest = new Packets.SSLRequest(this.clientFlags); | ||
connection.writePacket(sslRequest.toPacket()); | ||
}; | ||
@@ -29,2 +26,3 @@ | ||
var handshakeResponse = new Packets.HandshakeResponse({ | ||
flags : this.clientFlags, | ||
password: connection.config.password, | ||
@@ -35,5 +33,5 @@ user : connection.config.user, | ||
authPluginData2: this.handshake.authPluginData2, | ||
compress: connection.config.compress | ||
compress: connection.config.compressi | ||
}); | ||
connection.writePacket(handshakeResponse.toPacket(packetIndex, this.clientFlags)); | ||
connection.writePacket(handshakeResponse.toPacket()); | ||
}; | ||
@@ -62,2 +60,3 @@ | ||
// send ssl upgrade request and immediately upgrade connection to secure | ||
this.clientFlags |= ClientConstants.SSL; | ||
this.sendSSLRequest(connection); | ||
@@ -64,0 +63,0 @@ connection.startTLS(function() { |
@@ -41,6 +41,2 @@ var ClientConstants = require('../constants/client'); | ||
{ | ||
if (handshake.ssl) { | ||
this.ssl = true; | ||
return; | ||
} | ||
this.ssl = false; | ||
@@ -53,11 +49,10 @@ this.user = handshake.user || ''; | ||
this.compress = handshake.compress; | ||
this.clientFlags = handshake.flags; | ||
this.authToken = token(this.password, this.authPluginData1, this.authPluginData2); | ||
} | ||
HandshakeResponse.prototype.toPacket = function(packetIndex, flags) | ||
HandshakeResponse.prototype.toPacket = function() | ||
{ | ||
var characterSet = Charsets.UTF8_GENERAL_CI; | ||
// there is global "root" variable in node which is a reference to global object | ||
// this hit me once when I accidently used { user: root } instead of intended {user: "root"} | ||
if (typeof this.user != 'string') | ||
@@ -68,30 +63,17 @@ throw new Error('"user" connection config prperty must be a string'); | ||
var length = 36; | ||
// TODO replace it with sslRequest parameter, make ssl to flag just clientFlags, not packet length | ||
if (!this.ssl) | ||
length += 23 + this.user.length + this.database.length; | ||
var length = 36 + 23 + this.user.length + this.database.length; | ||
if (isNaN(length)) | ||
throw new Error('Unknown error. Packet length is NaN'); | ||
var buffer = new Buffer(length); | ||
var packet = new Packet(packetIndex, buffer); | ||
var packet = new Packet(0, buffer); | ||
buffer.fill(0); | ||
packet.offset = 4; | ||
if (this.ssl) | ||
this.clientFlags |= ClientConstants.SSL; | ||
if (this.compress) | ||
this.clientFlags |= ClientConstants.COMPRESS; | ||
packet.writeInt32(flags); | ||
packet.writeInt32(this.clientFlags); | ||
packet.writeInt32(0); // max packet size. todo: move to config | ||
packet.writeInt8(characterSet); | ||
packet.skip(23); | ||
if (!this.ssl) { | ||
packet.writeNullTerminatedString(this.user); | ||
packet.writeInt8(this.authToken.length); | ||
packet.writeBuffer(this.authToken); | ||
packet.writeNullTerminatedString(this.database); | ||
} | ||
packet.writeNullTerminatedString(this.user); | ||
packet.writeInt8(this.authToken.length); | ||
packet.writeBuffer(this.authToken); | ||
packet.writeNullTerminatedString(this.database); | ||
return packet; | ||
@@ -98,0 +80,0 @@ }; |
@@ -1,2 +0,5 @@ | ||
"handshake handshake_response query resultset_header column_definition text_row binary_row prepare_statement prepared_statement_header execute".split(' ').forEach(function(name) { | ||
var packetTypes = "handshake handshake_response query resultset_header column_definition"; | ||
packetTypes += " text_row binary_row prepare_statement prepared_statement_header execute ssl_request"; | ||
packetTypes.split(' ').forEach(function(name) { | ||
var ctor = require('./' + name); | ||
@@ -3,0 +6,0 @@ module.exports[ctor.name] = ctor; |
{ | ||
"name": "mysql2", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220154
107
5195