FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix style · tmpvar/node@9c29ac6 · GitHub

Repository navigation

Commit 9c29ac6

Browse files
committed
Fix style
1 parent 952bbb8 commit 9c29ac6

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

‎lib/securepair.js‎

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ var events = require('events');
33
var stream = require('stream');
44
var assert = process.assert;
55

6-
var debugLevel = parseInt(process.env.NODE_DEBUG, 16);
76

7+
var debugLevel = parseInt(process.env.NODE_DEBUG, 16);
88
function debug () {
99
if (debugLevel & 0x2) {
1010
util.error.apply(this, arguments);
1111
}
1212
}
1313

14+
1415
/* Lazy Loaded crypto object */
1516
var SecureStream = null;
1617

@@ -69,24 +70,24 @@ function SecurePair(credentials, isServer) {
6970
this.encrypted = new stream.Stream();
7071
this.encrypted.readable = true;
7172

72-
this.cleartext.write = function(data) {
73+
this.cleartext.write = function (data) {
7374
debug('clearIn data');
7475
self._clearInPending.push(data);
7576
self._cycle();
7677
return self._cleartextWriteState;
7778
};
7879

79-
this.cleartext.pause = function() {
80+
this.cleartext.pause = function () {
8081
debug('paused cleartext');
8182
self._cleartextWriteState = false;
8283
};
8384

84-
this.cleartext.resume = function() {
85+
this.cleartext.resume = function () {
8586
debug('resumed cleartext');
8687
self._cleartextWriteState = true;
8788
};
8889

89-
this.cleartext.end = function(err) {
90+
this.cleartext.end = function (err) {
9091
debug('cleartext end');
9192
if (!self._done) {
9293
self._ssl.shutdown();
@@ -95,24 +96,24 @@ function SecurePair(credentials, isServer) {
9596
self._destroy(err);
9697
};
9798

98-
this.encrypted.write = function(data) {
99+
this.encrypted.write = function (data) {
99100
debug('encIn data');
100101
self._encInPending.push(data);
101102
self._cycle();
102103
return self._encryptedWriteState;
103104
};
104105

105-
this.encrypted.pause = function() {
106+
this.encrypted.pause = function () {
106107
debug('pause encrypted');
107108
self._encryptedWriteState = false;
108109
};
109110

110-
this.encrypted.resume = function() {
111+
this.encrypted.resume = function () {
111112
debug('resume encrypted');
112113
self._encryptedWriteState = true;
113114
};
114115

115-
this.encrypted.end = function(err) {
116+
this.encrypted.end = function (err) {
116117
debug('encrypted end');
117118
if (!self._done) {
118119
self._ssl.shutdown();
@@ -121,7 +122,7 @@ function SecurePair(credentials, isServer) {
121122
self._destroy(err);
122123
};
123124

124-
this.cleartext.on('end', function(err) {
125+
this.cleartext.on('end', function (err) {
125126
debug('clearIn end');
126127
if (!self._done) {
127128
self._ssl.shutdown();
@@ -130,45 +131,46 @@ function SecurePair(credentials, isServer) {
130131
self._destroy(err);
131132
});
132133

133-
this.cleartext.on('close', function() {
134+
this.cleartext.on('close', function () {
134135
debug('source close');
135136
self.emit('close');
136137
self._destroy();
137138
});
138139

139-
this.encrypted.on('end', function() {
140+
this.encrypted.on('end', function () {
140141
if (!self._done) {
141142
self._error(new Error('Encrypted stream ended before secure pair was done'));
142143
}
143144
});
144145

145-
this.encrypted.on('close', function() {
146+
this.encrypted.on('close', function () {
146147
if (!self._done) {
147148
self._error(new Error('Encrypted stream closed before secure pair was done'));
148149
}
149150
});
150151

151-
this.cleartext.on('drain', function() {
152+
this.cleartext.on('drain', function () {
152153
debug('source drain');
153154
self._cycle();
154155
self.encrypted.resume();
155156
});
156157

157-
this.encrypted.on('drain', function() {
158+
this.encrypted.on('drain', function () {
158159
debug('target drain');
159160
self._cycle();
160161
self.cleartext.resume();
161162
});
162163

163-
process.nextTick(function() {
164+
process.nextTick(function () {
164165
self._ssl.start();
165166
self._cycle();
166167
});
167168
}
168169

169170
util.inherits(SecurePair, events.EventEmitter);
170171

171-
exports.createSecurePair = function(credentials, isServer) {
172+
173+
exports.createSecurePair = function (credentials, isServer) {
172174
var pair = new SecurePair(credentials, isServer);
173175
return pair;
174176
};
@@ -183,23 +185,23 @@ exports.createSecurePair = function(credentials, isServer) {
183185
* the ciphers.
184186
*
185187
* The four pipelines, using terminology of the client (server is just reversed):
186-
* 1) Encrypted Output stream (Writing encrypted data to peer)
187-
* 2) Encrypted Input stream (Reading encrypted data from peer)
188-
* 3) Cleartext Output stream (Decrypted content from the peer)
189-
* 4) Cleartext Input stream (Cleartext content to send to the peer)
188+
* (1) Encrypted Output stream (Writing encrypted data to peer)
189+
* (2) Encrypted Input stream (Reading encrypted data from peer)
190+
* (3) Cleartext Output stream (Decrypted content from the peer)
191+
* (4) Cleartext Input stream (Cleartext content to send to the peer)
190192
*
191193
* This function attempts to pull any available data out of the Cleartext
192-
* input stream (#4), and the Encrypted input stream (#2). Then it pushes
193-
* any data available from the cleartext output stream (#3), and finally
194-
* from the Encrypted output stream (#1)
194+
* input stream (4), and the Encrypted input stream (2). Then it pushes
195+
* any data available from the cleartext output stream (3), and finally
196+
* from the Encrypted output stream (1)
195197
*
196198
* It is called whenever we do something with OpenSSL -- post reciving content,
197199
* trying to flush, trying to change ciphers, or shutting down the connection.
198200
*
199201
* Because it is also called everywhere, we also check if the connection
200202
* has completed negotiation and emit 'secure' from here if it has.
201203
*/
202-
SecurePair.prototype._cycle = function() {
204+
SecurePair.prototype._cycle = function () {
203205
if (this._done) {
204206
return;
205207
}
@@ -279,26 +281,26 @@ SecurePair.prototype._cycle = function() {
279281
}
280282

281283
mover(
282-
function(pool, offset, length) {
284+
function (pool, offset, length) {
283285
debug('reading from clearOut');
284286
return self._ssl.clearOut(pool, offset, length);
285287
},
286-
function(chunk) {
288+
function (chunk) {
287289
self.cleartext.emit('data', chunk);
288290
},
289-
function(bytesRead) {
291+
function (bytesRead) {
290292
return bytesRead > 0 && self._cleartextWriteState === true;
291293
});
292294

293295
mover(
294-
function(pool, offset, length) {
296+
function (pool, offset, length) {
295297
debug('reading from encOut');
296298
return self._ssl.encOut(pool, offset, length);
297299
},
298-
function(chunk) {
300+
function (chunk) {
299301
self.encrypted.emit('data', chunk);
300302
},
301-
function(bytesRead) {
303+
function (bytesRead) {
302304
return bytesRead > 0 && self._encryptedWriteState === true;
303305
});
304306

@@ -310,8 +312,8 @@ SecurePair.prototype._cycle = function() {
310312
}
311313
};
312314

313-
SecurePair.prototype._destroy = function(err)
314-
{
315+
316+
SecurePair.prototype._destroy = function (err) {
315317
if (!this._done) {
316318
this._done = true;
317319
this._ssl.close();
@@ -320,17 +322,17 @@ SecurePair.prototype._destroy = function(err)
320322
}
321323
};
322324

323-
SecurePair.prototype._error = function (err)
324-
{
325+
326+
SecurePair.prototype._error = function (err) {
325327
this.emit('error', err);
326328
};
327329

328-
SecurePair.prototype.getPeerCertificate = function (err)
329-
{
330+
331+
SecurePair.prototype.getPeerCertificate = function (err) {
330332
return this._ssl.getPeerCertificate();
331333
};
332334

333-
SecurePair.prototype.getCipher = function (err)
334-
{
335+
336+
SecurePair.prototype.getCipher = function (err) {
335337
return this._ssl.getCurrentCipher();
336338
};

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL