starttls
Advanced tools
Comparing version 0.1.4 to 0.1.5
29
index.js
@@ -80,16 +80,4 @@ /** | ||
securePair.encrypted.pipe(socket); | ||
socket.pipe(securePair.encrypted); | ||
securePair.fd = socket.fd; | ||
clearText = securePair.cleartext; | ||
clearText.socket = socket; | ||
clearText.encrypted = securePair.encrypted; | ||
clearText.authorized = false; | ||
// Forward event emissions from the socket to the clear text stream | ||
eventsMap = forwardEvents(['timeout', 'end', 'drain'], socket, clearText); | ||
onError = function(err) { | ||
@@ -107,10 +95,21 @@ if (clearText._controlReleased) { | ||
// Forward event emissions from the socket to the cleartext stream | ||
eventsMap = forwardEvents(['timeout', 'end', 'drain'], socket, clearText); | ||
socket.on('error', onError); | ||
socket.on('close', onClose); | ||
// It's possible for a SecurePair to emit an 'error' event (see SecurePair.prototype.error in tls.js in at least node v0.8.21). This happens when a server closes the connection prematurely. | ||
securePair.on('error', onError); | ||
securePair.encrypted.on('error', onError); | ||
securePair.on('error', function(err) { | ||
onError(err); | ||
}); | ||
securePair.encrypted.pipe(socket); | ||
socket.pipe(securePair.encrypted); | ||
securePair.fd = socket.fd; | ||
clearText.socket = socket; | ||
clearText.encrypted = securePair.encrypted; | ||
clearText.authorized = false; | ||
return clearText; | ||
} |
{ | ||
"name": "starttls", | ||
"description": "Upgrade a regular `net.Stream` connection to a secure `tls` connection.", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/mattcg/starttls", |
4855