(ipv6Addr, ipv4Addr, cb)
| 31 | } |
| 32 | |
| 33 | function createDnsServer(ipv6Addr, ipv4Addr, cb) { |
| 34 | // Create a DNS server which replies with a AAAA and a A record for the same host |
| 35 | const socket = dgram.createSocket('udp4'); |
| 36 | |
| 37 | socket.on('message', common.mustCall((msg, { address, port }) => { |
| 38 | const parsed = parseDNSPacket(msg); |
| 39 | const domain = parsed.questions[0].domain; |
| 40 | assert.strictEqual(domain, 'example.org'); |
| 41 | |
| 42 | socket.send(writeDNSPacket({ |
| 43 | id: parsed.id, |
| 44 | questions: parsed.questions, |
| 45 | answers: [ |
| 46 | { type: 'AAAA', address: ipv6Addr, ttl: 123, domain: 'example.org' }, |
| 47 | { type: 'A', address: ipv4Addr, ttl: 123, domain: 'example.org' }, |
| 48 | ] |
| 49 | }), port, address); |
| 50 | })); |
| 51 | |
| 52 | socket.bind(0, () => { |
| 53 | const resolver = new Resolver(); |
| 54 | resolver.setServers([`127.0.0.1:${socket.address().port}`]); |
| 55 | |
| 56 | cb({ dnsServer: socket, lookup: _lookup.bind(null, resolver) }); |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | // Test that IPV4 is reached if IPV6 is not reachable |
| 61 | { |
no test coverage detected