MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/tls/secure-pair.js:17–97  ·  view source on GitHub ↗
({ dur, size, securing })

Source from the content-addressed store, hash-verified

15const REDIRECT_PORT = 28347;
16
17function main({ dur, size, securing }) {
18 const chunk = Buffer.alloc(size, 'b');
19
20 const options = {
21 key: fixtures.readKey('rsa_private.pem'),
22 cert: fixtures.readKey('rsa_cert.crt'),
23 ca: fixtures.readKey('rsa_ca.crt'),
24 ciphers: 'AES256-GCM-SHA384',
25 isServer: true,
26 requestCert: true,
27 rejectUnauthorized: true,
28 maxVersion: 'TLSv1.2',
29 };
30
31 const server = net.createServer(onRedirectConnection);
32 server.listen(REDIRECT_PORT, () => {
33 const proxy = net.createServer(onProxyConnection);
34 proxy.listen(common.PORT, () => {
35 const clientOptions = {
36 port: common.PORT,
37 ca: options.ca,
38 key: options.key,
39 cert: options.cert,
40 isServer: false,
41 rejectUnauthorized: false,
42 maxVersion: options.maxVersion,
43 };
44 const network = securing === 'clear' ? net : tls;
45 const conn = network.connect(clientOptions, () => {
46 setTimeout(() => {
47 const mbits = (received * 8) / (1024 * 1024);
48 bench.end(mbits);
49 if (conn)
50 conn.destroy();
51 server.close();
52 proxy.close();
53 }, dur * 1000);
54 bench.start();
55 conn.on('drain', write);
56 write();
57 });
58 conn.on('error', (e) => {
59 throw new Error(`Client error: ${e}`);
60 });
61
62 function write() {
63 while (false !== conn.write(chunk));
64 }
65 });
66 });
67
68 function onProxyConnection(conn) {
69 const client = net.connect(REDIRECT_PORT, () => {
70 switch (securing) {
71 case 'TLSSocket':
72 secureTLSSocket(conn, client);
73 break;
74 case 'clear':

Callers

nothing calls this directly

Calls 10

allocMethod · 0.80
listenMethod · 0.80
writeFunction · 0.70
connectMethod · 0.65
closeMethod · 0.65
setTimeoutFunction · 0.50
endMethod · 0.45
destroyMethod · 0.45
startMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…