fix jshint errors in lib/connection.js

This commit is contained in:
Philipp Borgers 2013-01-24 01:08:32 +01:00
parent 5df417e589
commit d8255c6f85

View File

@ -37,7 +37,7 @@ p.connect = function(port, host) {
this.stream.on('connect', function() {
self.emit('connect');
});
this.stream.on('error', function(error) {
self.emit('error', error);
});
@ -53,9 +53,9 @@ p.connect = function(port, host) {
if (msg.text == 0x53) {
var tls = require('tls');
self.stream.removeAllListeners();
self.stream = tls.connect({
socket: self.stream,
servername: host,
self.stream = tls.connect({
socket: self.stream,
servername: host,
rejectUnauthorized: self.ssl.rejectUnauthorized,
ca: self.ssl.ca,
pfx: self.ssl.pfx,
@ -67,9 +67,12 @@ p.connect = function(port, host) {
self.attachListeners(self.stream);
self.emit('sslconnect');
} else {
self.emit('error', new Error("The server doesn't support SSL/TLS connections."));
self.emit(
'error',
new Error("The server doesn't support SSL/TLS connections.")
);
}
});
});
} else {
this.attachListeners(this.stream);
@ -91,13 +94,13 @@ p.attachListeners = function(stream) {
p.requestSsl = function(config) {
this.checkSslResponse = true;
var bodyBuffer = this.writer
.addInt16(0x04D2)
.addInt16(0x162F).flush();
var length = bodyBuffer.length + 4;
var buffer = new Writer()
.addInt32(length)
.add(bodyBuffer)
@ -247,7 +250,7 @@ p.flush = function() {
p.sync = function() {
//clear out any pending data in the writer
this.writer.flush(0);
this.writer.add(emptyBuffer);
this._send(0x53);
};
@ -391,7 +394,7 @@ p.parseMessage = function() {
case 0x48: //H
msg.name = 'copyOutResponse';
return this.parseGH(msg);
return this.parseGH(msg);
case 0x63: //c
msg.name = 'copyDone';
return msg;
@ -540,7 +543,7 @@ p.parseGH = function (msg) {
return msg;
};
p.parseInt8 = function () {
var value = Number(this.buffer[this.offset]);
var value = Number(this.buffer[this.offset]);
this.offset++;
return value;
};
@ -570,7 +573,8 @@ p.parseInt16 = function() {
};
p.readString = function(length) {
return this.buffer.toString(this.encoding, this.offset, (this.offset += length));
return this.buffer.toString(this.encoding, this.offset,
(this.offset += length));
};
p.readBytes = function(length) {
@ -585,7 +589,7 @@ p.parseCString = function() {
p.parsed = function (msg) {
//exclude length field
msg.chunk = this.readBytes(msg.length - 4);
return msg;
return msg;
};
//end parsing methods
module.exports = Connection;