mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
add test
This commit is contained in:
parent
f619b1d354
commit
a4e46000f5
1 changed files with 32 additions and 0 deletions
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue