createResolver broken in master branch
See original GitHub issuecreateResolver is broken in master branch
If i want to resolve a dns attribute using the current master branch, it throw this error :
/code/eviltik/node-dns/index.js:46
const resolve = createResolver({ dns: address, port });
^
TypeError: createResolver is not a function
at /code/eviltik/node-dns/index.js:46:23
at Array.map (<anonymous>)
at DNS.query (/code/eviltik/node-dns/index.js:45:37)
at DNS.resolve (/code/eviltik/node-dns/index.js:57:17)
at DNS.resolveCNAME (/code/eviltik/node-dns/index.js:69:17)
.....
CreateResolver is created here https://github.com/song940/node-dns/blob/182d88e2c68394ea480063dbaf3f1409c50cf625/index.js#L39
Everything was OK before DoH Server implementation (https://github.com/song940/node-dns/pull/26) https://github.com/song940/node-dns/blob/452ab97d94f06d78fa715715e5af953eca547e95/index.js#L76-L79
After DoH Server implementation, no more udp client by default https://github.com/song940/node-dns/blob/182d88e2c68394ea480063dbaf3f1409c50cf625/index.js#L79-L82
Except if i’m missing something, we have no option to choose which Client we want (DOH, TCP, UDP, Google) to use for resolver.
I’d like to suggest a new config option for solve it, but not sure it’s the way to go : a new config option and a code change
const Dns2 = require('dns2');
const dns2 = new Dns2({
resolverProtocol:'UDP' // or TCP, DOH, Google
});
I’d like to purpose a PR, but my coding style does not match with the current one.
In the idea :
class DNS extends EventEmitter {
constructor(options) {
super();
Object.assign(this, {
port: 53,
resolverProtocol:'UDP' // new option
...........................
---------------------------
query(name, type, cls, clientIp) {
const { port, nameServers, resolverProtocol } = this;
// Choose the good Client
if (resolverProtocol === 'TCP') {
const{ ClientUDP: createResolver } = DNS;
} else if (resolverProtocol === 'TCP') {
const{ ClientTCP: createResolver } = DNS;
} .......
@DSorlov, @song940, what do you think ?
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
resolverProtocolassign to instance in constructor, users can passresolverProtocolto options.It means
resolverProtocoluse UDP whenresolverProtocolnot exists. but most cases it not be happen.I would agree that the newer coding style should replace. This was obviously broken in my push and should be remedied by modernizing the code imho.