better debug messages in net and tls
This commit is contained in:
parent
56ab929c55
commit
a48a075535
@ -8,7 +8,7 @@ var kPoolSize = 40 * 1024;
|
|||||||
|
|
||||||
var debug;
|
var debug;
|
||||||
if (process.env.NODE_DEBUG && /net/.test(process.env.NODE_DEBUG)) {
|
if (process.env.NODE_DEBUG && /net/.test(process.env.NODE_DEBUG)) {
|
||||||
debug = function(x) { util.error.apply(this, arguments); };
|
debug = function(x) { console.error('NET:', x); };
|
||||||
} else {
|
} else {
|
||||||
debug = function() { };
|
debug = function() { };
|
||||||
}
|
}
|
||||||
@ -431,8 +431,8 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('wrote ' + bytesWritten + ' to socket. [fd, off, len] = ' +
|
debug('wrote ' + bytesWritten + ' bytes to socket.')
|
||||||
JSON.stringify([this.fd, off, len]) + '\n');
|
debug('[fd, off, len] = ' + JSON.stringify([this.fd, off, len]));
|
||||||
|
|
||||||
timers.active(this);
|
timers.active(this);
|
||||||
|
|
||||||
@ -635,6 +635,8 @@ Socket.prototype._onReadable = function() {
|
|||||||
var end = pool.used + bytesRead;
|
var end = pool.used + bytesRead;
|
||||||
pool.used += bytesRead;
|
pool.used += bytesRead;
|
||||||
|
|
||||||
|
debug('socket ' + self.fd + ' received ' + bytesRead + ' bytes');
|
||||||
|
|
||||||
if (self._decoder) {
|
if (self._decoder) {
|
||||||
// emit String
|
// emit String
|
||||||
var string = self._decoder.write(pool.slice(start, end));
|
var string = self._decoder.write(pool.slice(start, end));
|
||||||
|
15
lib/tls.js
15
lib/tls.js
@ -8,7 +8,7 @@ var assert = require('assert').ok;
|
|||||||
|
|
||||||
var debug;
|
var debug;
|
||||||
if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_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 {
|
} else {
|
||||||
debug = function() { };
|
debug = function() { };
|
||||||
}
|
}
|
||||||
@ -38,7 +38,12 @@ util.inherits(CryptoStream, stream.Stream);
|
|||||||
|
|
||||||
|
|
||||||
CryptoStream.prototype.write = function(data /* , encoding, cb */) {
|
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) {
|
if (!this.writable) {
|
||||||
throw new Error('CryptoStream is not writable');
|
throw new Error('CryptoStream is not writable');
|
||||||
}
|
}
|
||||||
@ -241,7 +246,11 @@ CryptoStream.prototype._push = function() {
|
|||||||
|
|
||||||
var chunk = pool.slice(0, bytesRead);
|
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) {
|
if (this._decoder) {
|
||||||
var string = this._decoder.write(chunk);
|
var string = this._decoder.write(chunk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user