Skip to content

Commit 059cc68

Browse files
committed
fix #84
1 parent 67e7889 commit 059cc68

File tree

7 files changed

+2296
-52
lines changed

7 files changed

+2296
-52
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x, 12.x, 14.x, 16.x]
19+
node-version: [22.x]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2121

2222
steps:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

22
yarn.lock
3-
package-lock.json
43

54
node_modules

client/udp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const { debuglog } = require('util');
66
const debug = debuglog('dns2');
77

88
module.exports = ({ dns = '8.8.8.8', port = 53, socketType = 'udp4' } = {}) => {
9-
return (name, type = 'A', cls = Packet.CLASS.IN, { clientIp, recursive = true } = {}) => {
9+
return (name, type = 'A', cls = Packet.CLASS.IN, options = {}) => {
10+
const { clientIp, recursive = true } = options;
1011
const query = new Packet();
1112
query.header.id = (Math.random() * 1e4) | 0;
12-
1313
// see https://github.com/song940/node-dns/issues/29
1414
if (recursive) {
1515
query.header.rd = 1;

index.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,19 @@ class DNS extends EventEmitter {
3434
}, options);
3535
}
3636

37-
/**
38-
* query
39-
* @param {*} questions
40-
*/
41-
query(name, type, cls, clientIp) {
42-
const { port, nameServers, recursive, resolverProtocol = 'UDP' } = this;
43-
const createResolver = DNS[resolverProtocol + 'Client'];
44-
return Promise.race(nameServers.map(address => {
45-
const resolve = createResolver({ dns: address, port, recursive });
46-
return resolve(name, type, cls, clientIp);
47-
}));
48-
}
49-
5037
/**
5138
* resolve
5239
* @param {*} domain
5340
* @param {*} type
5441
* @param {*} cls
5542
*/
56-
resolve(domain, type = 'ANY', cls = DNS.Packet.CLASS.IN, clientIp = undefined) {
57-
return this.query(domain, type, cls, clientIp);
43+
resolve(domain, type = 'ANY', cls = DNS.Packet.CLASS.IN, options = {}) {
44+
const { port, nameServers, resolverProtocol = 'UDP' } = this;
45+
const createResolver = DNS[resolverProtocol + 'Client'];
46+
return Promise.race(nameServers.map(address => {
47+
const resolve = createResolver({ dns: address, port });
48+
return resolve(domain, type, cls, options);
49+
}));
5850
}
5951

6052
resolveA(domain, clientIp) {

0 commit comments

Comments
 (0)