1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00
This commit is contained in:
Yoshiya Hinosawa 2025-01-20 23:53:18 +09:00 committed by GitHub
commit 35137568bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 126 additions and 1 deletions

View file

@ -646,7 +646,7 @@ where
cancel_rid,
} = args;
let (config, opts) = if let Some(name_server) =
let (config, mut opts) = if let Some(name_server) =
options.as_ref().and_then(|o| o.name_server.as_ref())
{
let group = NameServerConfigGroup::from_ips_clear(
@ -662,6 +662,8 @@ where
system_conf::read_system_conf()?
};
opts.edns0 = true;
{
let mut s = state.borrow_mut();
let perm = s.borrow_mut::<NP>();

Binary file not shown.

View file

@ -0,0 +1,72 @@
{
"name": "dns2",
"description": "A DNS Server and Client Implementation in Pure JavaScript with no dependencies.",
"dist-tags": {
"latest": "2.1.0"
},
"versions": {
"2.1.0": {
"name": "dns2",
"version": "2.1.0",
"description": "A DNS Server and Client Implementation in Pure JavaScript with no dependencies.",
"main": "index.js",
"scripts": {
"test": "node test",
"lint": "eslint .",
"example-server-udp": "node example/server/udp.js",
"example-server-tcp": "node example/server/tcp.js",
"example-server-doh": "node example/server/doh.js",
"example-client-doh": "node example/client/doh.js",
"example-client-udp": "node example/client/udp.js",
"example-client-tcp": "node example/client/tcp.js",
"example-client-google": "node example/client/google.js",
"example-client-udp-subnet": "node example/client/udp-subnet.js"
},
"author": {
"name": "Liu Song",
"email": "song940@gmail.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/song940/node-dns.git"
},
"bugs": {
"url": "https://github.com/song940/node-dns/issues"
},
"devDependencies": {
"eslint": "^7.28.0",
"eslint-config-semistandard": "^15.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1"
},
"gitHead": "28fd77405b98081ac1efb41d0c800e827c1cf6ff",
"_id": "dns2@2.1.0",
"_nodeVersion": "19.3.0",
"_npmVersion": "9.2.0",
"dist": {
"integrity": "sha512-m27K11aQalRbmUs7RLaz6aPyceLjAoqjPRNTdE7qUouQpl+PC8Bi67O+i9SuJUPbQC8dxFrczAxfmTPuTKHNkw==",
"shasum": "15b07567befb2b914aedbb55a9ea0862c63c3d73",
"tarball": "http://localhost:4260/dns2/dns2-2.1.0.tgz",
"fileCount": 37,
"unpackedSize": 75538
},
"directories": {},
"_hasShrinkwrap": false
}
},
"homepage": "https://github.com/song940/node-dns#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/song940/node-dns.git"
},
"author": {
"name": "Liu Song",
"email": "song940@gmail.com"
},
"bugs": {
"url": "https://github.com/song940/node-dns/issues"
},
"license": "MIT",
"readmeFilename": "README.md"
}

View file

@ -0,0 +1,9 @@
{
"tests": {
"resolve_dns": {
"args": "test --allow-net=127.0.0.1 test.ts",
"output": "test.out",
"exitCode": 0
}
}
}

View file

@ -0,0 +1,6 @@
[WILDCARD]
running 1 test from ./test.ts
EDNS0 enabled ... ok ([WILDCARD]s)
ok | 1 passed | 0 failed ([WILDCARD]s)

View file

@ -0,0 +1,36 @@
// Copyright 2018-2025 the Deno authors. MIT license.
import dns2 from "npm:dns2@2.1.0";
Deno.test("EDNS0 enabled", async () => {
// 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 },
});
if (addr.length !== NUM_RECORD) {
throw new Error(`Expected ${NUM_RECORD} records, got ${addr.length}`);
}
await server.close();
});