(ipv6Addr, ipv4Addr, cb)
| 45 | } |
| 46 | |
| 47 | function 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 | { |
no test coverage detected
searching dependent graphs…