|
|
@ -8,7 +8,7 @@ var assert = require('assert').ok; |
|
|
|
|
|
|
|
var debug; |
|
|
|
if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_DEBUG)) { |
|
|
|
debug = function(a) { console.error("TLS: ", a); }; |
|
|
|
debug = function(a) { console.error('TLS:', a); }; |
|
|
|
} else { |
|
|
|
debug = function() { }; |
|
|
|
} |
|
|
@ -38,7 +38,12 @@ util.inherits(CryptoStream, stream.Stream); |
|
|
|
|
|
|
|
|
|
|
|
CryptoStream.prototype.write = function(data /* , encoding, cb */) { |
|
|
|
debug('CryptoStream.prototype.write called with <<<<' + data.toString() + '>>>'); |
|
|
|
if (this == this.pair.cleartext) { |
|
|
|
debug('cleartext.write called with (((' + data.toString() + ')))'); |
|
|
|
} else { |
|
|
|
debug('encrypted.write called with ' + data.length + ' bytes'); |
|
|
|
} |
|
|
|
|
|
|
|
if (!this.writable) { |
|
|
|
throw new Error('CryptoStream is not writable'); |
|
|
|
} |
|
|
@ -241,7 +246,11 @@ CryptoStream.prototype._push = function() { |
|
|
|
|
|
|
|
var chunk = pool.slice(0, bytesRead); |
|
|
|
|
|
|
|
debug('emit "data" called with <<<<' + chunk.toString() + '>>>'); |
|
|
|
if (this === this.pair.cleartext) { |
|
|
|
debug('cleartext emit "data" called with (((' + chunk.toString() + ')))'); |
|
|
|
} else { |
|
|
|
debug('encrypted emit "data" with ' + bytesRead + ' bytes'); |
|
|
|
} |
|
|
|
|
|
|
|
if (this._decoder) { |
|
|
|
var string = this._decoder.write(chunk); |
|
|
|