@@ -293,20 +293,21 @@ async function createHttp(httpConfig, log) {
293
293
return await createMultiple ( createHttp , httpConfig , log ) ;
294
294
}
295
295
296
- return await new Promise ( ( resolve , reject ) => {
297
- var server = require ( 'http' ) . createServer ( httpConfig . handler ) ,
298
- timeout = httpConfig . timeout ,
299
- port = httpConfig . port ,
300
- args ;
296
+ const
297
+ server = require ( 'http' ) . createServer ( httpConfig . handler ) ,
298
+ timeout = httpConfig . timeout ,
299
+ port = httpConfig . port ;
301
300
302
- if ( typeof timeout === 'number' ) server . setTimeout ( timeout ) ;
301
+ if ( typeof timeout === 'number' ) server . setTimeout ( timeout ) ;
303
302
304
- args = [ server , port ] ;
305
- if ( httpConfig . host ) {
306
- args . push ( httpConfig . host ) ;
307
- }
303
+ const args = [ server , port ] ;
304
+ if ( httpConfig . host ) {
305
+ args . push ( httpConfig . host ) ;
306
+ }
308
307
309
- log ( 'http | try listen ' + port ) ;
308
+ log ( 'http | try listen ' + port ) ;
309
+
310
+ return new Promise ( ( resolve , reject ) => {
310
311
args . push ( function listener ( err ) {
311
312
err ? reject ( err ) : resolve ( server ) ;
312
313
} ) ;
@@ -328,54 +329,48 @@ async function createHttps(ssl, log, h2) {
328
329
return await createMultiple ( createHttps , ssl , log , h2 ) ;
329
330
}
330
331
331
- let
332
- port = ssl . port ,
333
- timeout = ssl . timeout ,
334
- server ,
335
- args ;
336
-
337
332
const [ key , cert , ca ] = await Promise . all ( [
338
333
normalizePEMContent ( ssl . root , ssl . key ) ,
339
334
normalizeCertContent ( ssl . root , ssl . cert , ssl . key ) ,
340
335
normalizeCA ( ssl . root , ssl . ca )
341
336
] ) ;
342
337
343
- return await new Promise ( async ( resolve , reject ) => {
344
- const finalHttpsOptions = assign ( { } , ssl , {
345
- key,
346
- cert,
347
- ca,
348
- //
349
- // Properly expose ciphers for an A+ SSL rating:
350
- // https://certsimple.com/blog/a-plus-node-js-ssl
351
- //
352
- ciphers : normalizeCiphers ( ssl . ciphers ) ,
353
- honorCipherOrder : ! ! ssl . honorCipherOrder ,
354
- //
355
- // Protect against the POODLE attack by disabling SSLv3
356
- // @see http://googleonlinesecurity.blogspot.nl/2014/10/this-poodle-bites-exploiting-ssl-30.html
357
- //
358
- secureProtocol : 'SSLv23_method' ,
359
- secureOptions : secureOptions
360
- } ) ;
361
-
362
- if ( ssl . sni && ! finalHttpsOptions . SNICallback ) {
363
- finalHttpsOptions . SNICallback = await getSNIHandler ( ssl ) ;
364
- }
338
+ const finalHttpsOptions = assign ( { } , ssl , {
339
+ key,
340
+ cert,
341
+ ca,
342
+ //
343
+ // Properly expose ciphers for an A+ SSL rating:
344
+ // https://certsimple.com/blog/a-plus-node-js-ssl
345
+ //
346
+ ciphers : normalizeCiphers ( ssl . ciphers ) ,
347
+ honorCipherOrder : ! ! ssl . honorCipherOrder ,
348
+ //
349
+ // Protect against the POODLE attack by disabling SSLv3
350
+ // @see http://googleonlinesecurity.blogspot.nl/2014/10/this-poodle-bites-exploiting-ssl-30.html
351
+ //
352
+ secureProtocol : 'SSLv23_method' ,
353
+ secureOptions : secureOptions
354
+ } ) ;
365
355
366
- log ( 'https | listening on %d' , port ) ;
367
- if ( h2 ) {
368
- server = require ( 'http2' ) . createSecureServer ( finalHttpsOptions , ssl . handler )
369
- } else {
370
- server = require ( 'https' ) . createServer ( finalHttpsOptions , ssl . handler ) ;
371
- }
356
+ if ( ssl . sni && ! finalHttpsOptions . SNICallback ) {
357
+ finalHttpsOptions . SNICallback = await getSNIHandler ( ssl ) ;
358
+ }
372
359
373
- if ( typeof timeout === 'number' ) server . setTimeout ( timeout ) ;
374
- args = [ server , port ] ;
375
- if ( ssl . host ) {
376
- args . push ( ssl . host ) ;
377
- }
360
+ const port = ssl . port ;
361
+ log ( 'https | listening on %d' , port ) ;
362
+ const server = h2
363
+ ? require ( 'http2' ) . createSecureServer ( finalHttpsOptions , ssl . handler )
364
+ : require ( 'https' ) . createServer ( finalHttpsOptions , ssl . handler ) ;
365
+
366
+ const timeout = ssl . timeout ;
367
+ if ( typeof timeout === 'number' ) server . setTimeout ( timeout ) ;
368
+ const args = [ server , port ] ;
369
+ if ( ssl . host ) {
370
+ args . push ( ssl . host ) ;
371
+ }
378
372
373
+ return new Promise ( ( resolve , reject ) => {
379
374
args . push ( function listener ( err ) {
380
375
err ? reject ( err ) : resolve ( server ) ;
381
376
} ) ;
0 commit comments