Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
test: add regression test for 14814
Browse files Browse the repository at this point in the history
Ref: nodejs/node#14814

PR-URL: nodejs/node#15023
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
addaleax authored and Olivia Hugger committed Aug 30, 2017
1 parent b8823b5 commit 00823bc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/parallel/test-dns-cancel-reverse-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
const common = require('../common');
const dnstools = require('../common/dns');
const { Resolver } = require('dns');
const assert = require('assert');
const dgram = require('dgram');

const server = dgram.createSocket('udp4');
const resolver = new Resolver();

server.bind(0, common.mustCall(() => {
resolver.setServers([`127.0.0.1:${server.address().port}`]);
resolver.reverse('123.45.67.89', common.mustCall((err, res) => {
assert.strictEqual(err.code, 'ECANCELLED');
assert.strictEqual(err.errno, 'ECANCELLED');
assert.strictEqual(err.syscall, 'getHostByAddr');
assert.strictEqual(err.hostname, '123.45.67.89');
server.close();
}));
}));

server.on('message', common.mustCall((msg, { address, port }) => {
const parsed = dnstools.parseDNSPacket(msg);
const domain = parsed.questions[0].domain;
assert.strictEqual(domain, '89.67.45.123.in-addr.arpa');

// Do not send a reply.
resolver.cancel();
}));

0 comments on commit 00823bc

Please sign in to comment.