1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00
This commit is contained in:
Yoshiya Hinosawa 2025-01-20 14:33:16 +09:00
parent f619b1d354
commit a4e46000f5
No known key found for this signature in database
GPG key ID: 9017DB4559488785

View file

@ -9,6 +9,7 @@ import {
execCode2,
tmpUnixSocketPath,
} from "./test_util.ts";
import dns2 from "npm:dns2@2.1.0";
// Since these tests may run in parallel, ensure this port is unique to this file
const listenPort = 4503;
@ -1327,3 +1328,34 @@ Deno.test(
// calling [Symbol.dispose] after manual close is a no-op
},
);
Deno.test({ permissions: { net: true } }, async function resolveDnsEdns0() {
// With EDNS0 enabled, Deno.resolveDns can handle 44 A records.
const NUM_RECORD = 44;
const { Packet } = dns2;
const server = dns2.createServer({
udp: true,
// deno-lint-ignore no-explicit-any
handle(request: any, send: any) {
const response = Packet.createResponseFromRequest(request);
const { name } = request.questions[0];
for (const i of [...Array(NUM_RECORD).keys()]) {
response.answers.push({
name,
type: Packet.TYPE.A,
class: Packet.CLASS.IN,
ttl: 300,
address: "1.2.3." + i,
});
}
send(response);
},
});
const { udp: { port } } = await server.listen({
udp: { port: 0, address: "127.0.0.1", type: "udp4" },
});
const addr = await Deno.resolveDns("example.com", "A", {
nameServer: { ipAddr: "127.0.0.1", port },
});
await server.close();
});