Browse Source

fix style in net.js

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
d89f8dce28
  1. 34
      lib/net.js

34
lib/net.js

@ -52,9 +52,9 @@ var END_OF_FILE = 42;
try {
var SecureContext = process.binding('crypto').SecureContext;
var SecureStream = process.binding('crypto').SecureStream;
var have_crypto = true;
var haveCrypto = true;
} catch (e) {
var have_crypto = false;
var haveCrypto = false;
}
// IDLE TIMEOUTS
@ -336,9 +336,9 @@ function setImplmentationMethods (self) {
allocNewSecurePool();
}
var secureLen = self.secureStream.writeExtract(
securePool, 0, securePool.length
);
var secureLen = self.secureStream.writeExtract(securePool,
0,
securePool.length);
if (secureLen == -1) {
// Check our read again for secure handshake
@ -376,12 +376,10 @@ function setImplmentationMethods (self) {
var chunkBytes;
do {
chunkBytes = self.secureStream.readExtract(
pool,
chunkBytes =
self.secureStream.readExtract(pool,
pool.used + bytesRead,
pool.length - pool.used - bytesRead
);
pool.length - pool.used - bytesRead);
bytesRead += chunkBytes;
} while ((chunkBytes > 0) && (pool.used + bytesRead < pool.length));
@ -391,8 +389,7 @@ function setImplmentationMethods (self) {
if (self.secureStream.readPending()) {
process.nextTick(function () {
if(self._readWatcher)
self._readWatcher.callback();
if (self._readWatcher) self._readWatcher.callback();
});
}
@ -466,7 +463,10 @@ function initStream (self) {
var bytesRead;
try {
bytesRead = self._readImpl(pool, pool.used, pool.length - pool.used, (arguments.length > 0));
bytesRead = self._readImpl(pool,
pool.used,
pool.length - pool.used,
(arguments.length > 0));
} catch (e) {
self.destroy(e);
return;
@ -545,7 +545,7 @@ sys.inherits(Stream, events.EventEmitter);
exports.Stream = Stream;
Stream.prototype.setSecure = function (credentials) {
if (!have_crypto) {
if (!haveCrypto) {
throw new Error('node.js not compiled with openssl crypto support.');
}
var crypto= require("crypto");
@ -558,10 +558,12 @@ Stream.prototype.setSecure = function(credentials) {
this.credentials = credentials;
}
if (!this.server) {
// For clients, we will always have either a given ca list or the default one;
// For clients, we will always have either a given ca list or the default on
this.credentials.shouldVerify = true;
}
this.secureStream = new SecureStream(this.credentials.context, this.server ? 1 : 0, this.credentials.shouldVerify ? 1 : 0);
this.secureStream = new SecureStream(this.credentials.context,
this.server ? 1 : 0,
this.credentials.shouldVerify ? 1 : 0);
setImplmentationMethods(this);

Loading…
Cancel
Save