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

Function createDnsServer

test/parallel/test-https-autoselectfamily.js:47–72  ·  view source on GitHub ↗
(ipv6Addr, ipv4Addr, cb)

Source from the content-addressed store, hash-verified

45}
46
47function createDnsServer(ipv6Addr, ipv4Addr, cb) {
48 // Create a DNS server which replies with a AAAA and a A record for the same host
49 const socket = dgram.createSocket('udp4');
50
51 socket.on('message', common.mustCall((msg, { address, port }) => {
52 const parsed = parseDNSPacket(msg);
53 const domain = parsed.questions[0].domain;
54 assert.strictEqual(domain, 'example.org');
55
56 socket.send(writeDNSPacket({
57 id: parsed.id,
58 questions: parsed.questions,
59 answers: [
60 { type: 'AAAA', address: ipv6Addr, ttl: 123, domain: 'example.org' },
61 { type: 'A', address: ipv4Addr, ttl: 123, domain: 'example.org' },
62 ]
63 }), port, address);
64 }));
65
66 socket.bind(0, () => {
67 const resolver = new Resolver();
68 resolver.setServers([`127.0.0.1:${socket.address().port}`]);
69
70 cb({ dnsServer: socket, lookup: _lookup.bind(null, resolver) });
71 });
72}
73
74// Test that IPV4 is reached if IPV6 is not reachable
75{

Callers 1

Calls 9

parseDNSPacketFunction · 0.85
writeDNSPacketFunction · 0.85
createSocketMethod · 0.80
setServersMethod · 0.80
cbFunction · 0.70
sendMethod · 0.65
addressMethod · 0.65
onMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…