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