1
1
'use strict' ;
2
- var common = require ( '../common' ) ;
3
- var assert = require ( 'assert' ) ;
2
+ const common = require ( '../common' ) ;
4
3
5
4
if ( ! common . hasCrypto ) {
6
5
common . skip ( 'missing crypto' ) ;
7
6
return ;
8
7
}
9
- var tls = require ( 'tls' ) ;
10
8
11
- var fs = require ( 'fs' ) ;
12
- var path = require ( 'path' ) ;
13
- var net = require ( 'net' ) ;
9
+ const assert = require ( 'assert' ) ;
10
+ const tls = require ( 'tls' ) ;
14
11
15
- var options , a , b ;
12
+ const fs = require ( 'fs' ) ;
13
+ const path = require ( 'path' ) ;
14
+ const net = require ( 'net' ) ;
16
15
17
- var body = Buffer . alloc ( 400000 , 'A' ) ;
18
-
19
- options = {
16
+ const options = {
20
17
key : fs . readFileSync ( path . join ( common . fixturesDir , 'test_key.pem' ) ) ,
21
18
cert : fs . readFileSync ( path . join ( common . fixturesDir , 'test_cert.pem' ) )
22
19
} ;
23
20
21
+ const body = 'A' . repeat ( 40000 ) ;
22
+
24
23
// the "proxy" server
25
- a = tls . createServer ( options , function ( socket ) {
26
- var options = {
24
+ const a = tls . createServer ( options , function ( socket ) {
25
+ const myOptions = {
27
26
host : '127.0.0.1' ,
28
27
port : b . address ( ) . port ,
29
28
rejectUnauthorized : false
30
29
} ;
31
- var dest = net . connect ( options ) ;
30
+ const dest = net . connect ( myOptions ) ;
32
31
dest . pipe ( socket ) ;
33
32
socket . pipe ( dest ) ;
34
33
@@ -38,20 +37,19 @@ a = tls.createServer(options, function(socket) {
38
37
} ) ;
39
38
40
39
// the "target" server
41
- b = tls . createServer ( options , function ( socket ) {
40
+ const b = tls . createServer ( options , function ( socket ) {
42
41
socket . end ( body ) ;
43
42
} ) ;
44
43
45
44
a . listen ( 0 , function ( ) {
46
45
b . listen ( 0 , function ( ) {
47
- options = {
46
+ const myOptions = {
48
47
host : '127.0.0.1' ,
49
48
port : a . address ( ) . port ,
50
49
rejectUnauthorized : false
51
50
} ;
52
- var socket = tls . connect ( options ) ;
53
- var ssl ;
54
- ssl = tls . connect ( {
51
+ const socket = tls . connect ( myOptions ) ;
52
+ const ssl = tls . connect ( {
55
53
socket : socket ,
56
54
rejectUnauthorized : false
57
55
} ) ;
@@ -61,7 +59,7 @@ a.listen(0, function() {
61
59
buf += data ;
62
60
} ) ;
63
61
ssl . on ( 'end' , common . mustCall ( function ( ) {
64
- assert . equal ( buf , body ) ;
62
+ assert . strictEqual ( buf , body ) ;
65
63
ssl . end ( ) ;
66
64
a . close ( ) ;
67
65
b . close ( ) ;
0 commit comments