|
|
@ -66,9 +66,10 @@ function SecurePair(credentials, is_server) |
|
|
|
|
|
|
|
/* Acts as a r/w stream to the cleartext side of the stream. */ |
|
|
|
this.cleartext = new stream.Stream(); |
|
|
|
|
|
|
|
this.cleartext.readable = true; |
|
|
|
/* Acts as a r/w stream to the encrypted side of the stream. */ |
|
|
|
this.encrypted = new stream.Stream(); |
|
|
|
this.encrypted.readable = true; |
|
|
|
|
|
|
|
this.cleartext.write = function(data) { |
|
|
|
debug('clearIn data'); |
|
|
@ -78,10 +79,12 @@ function SecurePair(credentials, is_server) |
|
|
|
}; |
|
|
|
|
|
|
|
this.cleartext.pause = function() { |
|
|
|
debug('paused cleartext'); |
|
|
|
self._cleartext_write_state = false; |
|
|
|
}; |
|
|
|
|
|
|
|
this.cleartext.resume = function() { |
|
|
|
debug('resumed cleartext'); |
|
|
|
self._cleartext_write_state = true; |
|
|
|
}; |
|
|
|
|
|
|
@ -102,10 +105,12 @@ function SecurePair(credentials, is_server) |
|
|
|
}; |
|
|
|
|
|
|
|
this.encrypted.pause = function() { |
|
|
|
debug('pause encrypted'); |
|
|
|
self._encrypted_write_state = false; |
|
|
|
}; |
|
|
|
|
|
|
|
this.encrypted.resume = function() { |
|
|
|
debug('resume encrypted'); |
|
|
|
self._encrypted_write_state = true; |
|
|
|
}; |
|
|
|
|
|
|
@ -215,6 +220,7 @@ SecurePair.prototype._cycle = function() { |
|
|
|
tmp = this._encIn_pending.shift(); |
|
|
|
|
|
|
|
try { |
|
|
|
debug('writng from encIn'); |
|
|
|
rv = this._ssl.encIn(tmp, 0, tmp.length); |
|
|
|
} catch (e) { |
|
|
|
return this._error(e); |
|
|
@ -231,6 +237,7 @@ SecurePair.prototype._cycle = function() { |
|
|
|
while (this._clearIn_pending.length > 0) { |
|
|
|
tmp = this._clearIn_pending.shift(); |
|
|
|
try { |
|
|
|
debug('writng from clearIn'); |
|
|
|
rv = this._ssl.clearIn(tmp, 0, tmp.length); |
|
|
|
} catch (e) { |
|
|
|
return this._error(e); |
|
|
@ -276,6 +283,7 @@ SecurePair.prototype._cycle = function() { |
|
|
|
|
|
|
|
mover( |
|
|
|
function(pool, offset, length) { |
|
|
|
debug('reading from clearOut'); |
|
|
|
return self._ssl.clearOut(pool, offset, length); |
|
|
|
}, |
|
|
|
function(chunk) { |
|
|
@ -287,6 +295,7 @@ SecurePair.prototype._cycle = function() { |
|
|
|
|
|
|
|
mover( |
|
|
|
function(pool, offset, length) { |
|
|
|
debug('reading from encOut'); |
|
|
|
return self._ssl.encOut(pool, offset, length); |
|
|
|
}, |
|
|
|
function(chunk) { |
|
|
|