2016-11-22 17:13:44 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasCrypto)
|
2016-11-22 17:13:44 +01:00
|
|
|
common.skip('missing crypto');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasIPv6)
|
2016-11-22 17:13:44 +01:00
|
|
|
common.skip('IPv6 support required');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
const initHooks = require('./init-hooks');
|
|
|
|
const verifyGraph = require('./verify-graph');
|
2016-11-22 17:13:44 +01:00
|
|
|
const tls = require('tls');
|
2017-08-09 19:29:40 +02:00
|
|
|
const fixtures = require('../common/fixtures');
|
2017-07-01 01:29:09 +02:00
|
|
|
|
2016-11-22 17:13:44 +01:00
|
|
|
const hooks = initHooks();
|
|
|
|
hooks.enable();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Creating server and listening on port
|
|
|
|
//
|
|
|
|
const server = tls
|
|
|
|
.createServer({
|
2017-08-09 19:29:40 +02:00
|
|
|
cert: fixtures.readSync('test_cert.pem'),
|
|
|
|
key: fixtures.readSync('test_key.pem')
|
2016-11-22 17:13:44 +01:00
|
|
|
})
|
|
|
|
.on('listening', common.mustCall(onlistening))
|
|
|
|
.on('secureConnection', common.mustCall(onsecureConnection))
|
|
|
|
.listen(common.PORT);
|
|
|
|
|
|
|
|
function onlistening() {
|
|
|
|
//
|
|
|
|
// Creating client and connecting it to server
|
|
|
|
//
|
|
|
|
tls
|
|
|
|
.connect(common.PORT, { rejectUnauthorized: false })
|
|
|
|
.on('secureConnect', common.mustCall(onsecureConnect));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onsecureConnection() {}
|
|
|
|
|
|
|
|
function onsecureConnect() {
|
|
|
|
// Destroying client socket
|
|
|
|
this.destroy();
|
|
|
|
|
|
|
|
// Closing server
|
|
|
|
server.close(common.mustCall(onserverClosed));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onserverClosed() {}
|
|
|
|
|
|
|
|
process.on('exit', onexit);
|
|
|
|
|
|
|
|
function onexit() {
|
|
|
|
hooks.disable();
|
|
|
|
|
|
|
|
verifyGraph(
|
|
|
|
hooks,
|
2017-06-14 12:39:53 +02:00
|
|
|
[ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: null },
|
|
|
|
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcp:1' },
|
|
|
|
{ type: 'TLSWRAP', id: 'tls:1', triggerAsyncId: 'tcp:1' },
|
2016-11-22 17:13:44 +01:00
|
|
|
{ type: 'GETADDRINFOREQWRAP',
|
2017-06-14 12:39:53 +02:00
|
|
|
id: 'getaddrinforeq:1', triggerAsyncId: 'tls:1' },
|
2016-11-22 17:13:44 +01:00
|
|
|
{ type: 'TCPCONNECTWRAP',
|
2017-06-14 12:39:53 +02:00
|
|
|
id: 'tcpconnect:1', triggerAsyncId: 'tcp:2' },
|
|
|
|
{ type: 'WRITEWRAP', id: 'write:1', triggerAsyncId: 'tcpconnect:1' },
|
|
|
|
{ type: 'TCPWRAP', id: 'tcp:3', triggerAsyncId: 'tcp:1' },
|
|
|
|
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcp:1' },
|
|
|
|
{ type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: 'tcp:1' },
|
|
|
|
{ type: 'WRITEWRAP', id: 'write:2', triggerAsyncId: null },
|
|
|
|
{ type: 'WRITEWRAP', id: 'write:3', triggerAsyncId: null },
|
|
|
|
{ type: 'WRITEWRAP', id: 'write:4', triggerAsyncId: null },
|
|
|
|
{ type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' },
|
|
|
|
{ type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:3' } ]
|
2016-11-22 17:13:44 +01:00
|
|
|
);
|
|
|
|
}
|