|
@ -91,7 +91,7 @@ var timeout = new (function () { |
|
|
remove(socket); |
|
|
remove(socket); |
|
|
socket._idleNext = list._idleNext; |
|
|
socket._idleNext = list._idleNext; |
|
|
socket._idleNext._idlePrev = socket; |
|
|
socket._idleNext._idlePrev = socket; |
|
|
socket._idlePrev = list |
|
|
socket._idlePrev = list; |
|
|
list._idleNext = socket; |
|
|
list._idleNext = socket; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -200,7 +200,7 @@ var timeout = new (function () { |
|
|
socket._idlePrev._idleNext = socket._idleNext; |
|
|
socket._idlePrev._idleNext = socket._idleNext; |
|
|
socket._idleNext = list._idleNext; |
|
|
socket._idleNext = list._idleNext; |
|
|
socket._idleNext._idlePrev = socket; |
|
|
socket._idleNext._idlePrev = socket; |
|
|
socket._idlePrev = list |
|
|
socket._idlePrev = list; |
|
|
list._idleNext = socket; |
|
|
list._idleNext = socket; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -313,7 +313,7 @@ function setImplmentationMethods (self) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
self._shutdownImpl = function () { |
|
|
self._shutdownImpl = function () { |
|
|
shutdown(self.fd, 'write') |
|
|
shutdown(self.fd, 'write'); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (self.secure) { |
|
|
if (self.secure) { |
|
@ -525,7 +525,7 @@ function Stream (fd, type) { |
|
|
this.type = null; |
|
|
this.type = null; |
|
|
this.secure = false; |
|
|
this.secure = false; |
|
|
|
|
|
|
|
|
if (parseInt(fd) >= 0) { |
|
|
if (parseInt(fd, 10) >= 0) { |
|
|
this.open(fd, type); |
|
|
this.open(fd, type); |
|
|
} else { |
|
|
} else { |
|
|
setImplmentationMethods(this); |
|
|
setImplmentationMethods(this); |
|
@ -567,7 +567,7 @@ Stream.prototype.setSecure = function (credentials) { |
|
|
// If client, trigger handshake
|
|
|
// If client, trigger handshake
|
|
|
this._checkForSecureHandshake(); |
|
|
this._checkForSecureHandshake(); |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream.prototype.verifyPeer = function () { |
|
|
Stream.prototype.verifyPeer = function () { |
|
@ -575,7 +575,7 @@ Stream.prototype.verifyPeer = function () { |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
} |
|
|
} |
|
|
return this.secureStream.verifyPeer(this.credentials.context); |
|
|
return this.secureStream.verifyPeer(this.credentials.context); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream.prototype._checkForSecureHandshake = function () { |
|
|
Stream.prototype._checkForSecureHandshake = function () { |
|
@ -586,7 +586,7 @@ Stream.prototype._checkForSecureHandshake = function () { |
|
|
// Do an empty write to see if we need to write out as part of handshake
|
|
|
// Do an empty write to see if we need to write out as part of handshake
|
|
|
if (!emptyBuffer) allocEmptyBuffer(); |
|
|
if (!emptyBuffer) allocEmptyBuffer(); |
|
|
this.write(emptyBuffer); |
|
|
this.write(emptyBuffer); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream.prototype.getPeerCertificate = function (credentials) { |
|
|
Stream.prototype.getPeerCertificate = function (credentials) { |
|
@ -594,7 +594,7 @@ Stream.prototype.getPeerCertificate = function (credentials) { |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
} |
|
|
} |
|
|
return this.secureStream.getPeerCertificate(); |
|
|
return this.secureStream.getPeerCertificate(); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream.prototype.getCipher = function () { |
|
|
Stream.prototype.getCipher = function () { |
|
@ -602,7 +602,7 @@ Stream.prototype.getCipher = function () { |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
throw new Error('Stream is not a secure stream.'); |
|
|
} |
|
|
} |
|
|
return this.secureStream.getCurrentCipher(); |
|
|
return this.secureStream.getCurrentCipher(); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream.prototype.open = function (fd, type) { |
|
|
Stream.prototype.open = function (fd, type) { |
|
@ -616,7 +616,7 @@ Stream.prototype.open = function (fd, type) { |
|
|
|
|
|
|
|
|
this._writeWatcher.set(this.fd, false, true); |
|
|
this._writeWatcher.set(this.fd, false, true); |
|
|
this.writable = true; |
|
|
this.writable = true; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.createConnection = function (port, host) { |
|
|
exports.createConnection = function (port, host) { |
|
@ -703,7 +703,7 @@ Stream.prototype._writeOut = function (data, encoding, fd) { |
|
|
len = data.length; |
|
|
len = data.length; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
assert(typeof data == 'string') |
|
|
assert(typeof data == 'string'); |
|
|
|
|
|
|
|
|
if (!pool || pool.length - pool.used < kMinPoolSpace) { |
|
|
if (!pool || pool.length - pool.used < kMinPoolSpace) { |
|
|
pool = null; |
|
|
pool = null; |
|
@ -788,7 +788,7 @@ Stream.prototype._writeOut = function (data, encoding, fd) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Flushes the write buffer out.
|
|
|
// Flushes the write buffer out.
|
|
@ -869,7 +869,7 @@ function doConnect (socket, port, host) { |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function toPort (x) { return (x = Number(x)) >= 0 ? x : false } |
|
|
function toPort (x) { return (x = Number(x)) >= 0 ? x : false; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var stream = new Stream();
|
|
|
// var stream = new Stream();
|
|
@ -886,7 +886,7 @@ Stream.prototype.connect = function () { |
|
|
|
|
|
|
|
|
self._connecting = true; // set false in doConnect
|
|
|
self._connecting = true; // set false in doConnect
|
|
|
|
|
|
|
|
|
var port = toPort(arguments[0]) |
|
|
var port = toPort(arguments[0]); |
|
|
if (port === false) { |
|
|
if (port === false) { |
|
|
// UNIX
|
|
|
// UNIX
|
|
|
self.fd = socket('unix'); |
|
|
self.fd = socket('unix'); |
|
@ -1102,7 +1102,7 @@ Server.prototype.listen = function () { |
|
|
self.addListener('listening', lastArg); |
|
|
self.addListener('listening', lastArg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var port = toPort(arguments[0]) |
|
|
var port = toPort(arguments[0]); |
|
|
if (port === false) { |
|
|
if (port === false) { |
|
|
// the first argument specifies a path
|
|
|
// the first argument specifies a path
|
|
|
self.fd = socket('unix'); |
|
|
self.fd = socket('unix'); |
|
@ -1176,7 +1176,7 @@ Server.prototype._startWatcher = function () { |
|
|
Server.prototype._doListen = function () { |
|
|
Server.prototype._doListen = function () { |
|
|
listen(this.fd, 128); |
|
|
listen(this.fd, 128); |
|
|
this._startWatcher(); |
|
|
this._startWatcher(); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|