-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ext/net): enable EDNS0 for Deno.resolveDns #27735
Draft
kt3k
wants to merge
7
commits into
denoland:main
Choose a base branch
from
kt3k:fix-net-enable-edns0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−1
Draft
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f619b1d
fix(ext/net): enable EDNS0 for Deno.resolveDns
kt3k a4e4600
add test
kt3k e36fa4b
fix lint error
kt3k 69bab03
add dns2 dep
kt3k 7d3c4ac
move test case to tests/specs as NPM_CONFIG_REGISTRY is not set in js…
kt3k 563e07d
fix registry entry
kt3k 5505271
Merge branch 'main' into fix-net-enable-edns0
kt3k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "[email protected]" | ||
}, | ||
"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": "[email protected]", | ||
"_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": "[email protected]" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/song940/node-dns/issues" | ||
}, | ||
"license": "MIT", | ||
"readmeFilename": "README.md" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"tests": { | ||
"resolve_dns": { | ||
"args": "test --allow-net=127.0.0.1 test.ts", | ||
"output": "test.out", | ||
"exitCode": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[WILDCARD] | ||
running 1 test from ./test.ts | ||
EDNS0 enabled ... ok ([WILDCARD]s) | ||
|
||
ok | 1 passed | 0 failed ([WILDCARD]s) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2018-2025 the Deno authors. MIT license. | ||
import dns2 from "npm:[email protected]"; | ||
|
||
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(); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits: Please add a comment here 🙇