question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createResolver broken in master branch

See original GitHub issue

createResolver 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
song940commented, Feb 9, 2021

Mhh. The fix make make the resolver as UDP by default, like before DSorlov DOH implementation. So yes, it’s fixed.

But the users of this library cannot choose another protocol for the resolver, with a config option. Or i’m missing something.

resolverProtocol assign to instance in constructor, users can pass resolverProtocol to options.

 const { port, nameServers, resolverProtocol = 'UDP' } = this;

It means resolverProtocol use UDP when resolverProtocol not exists. but most cases it not be happen.

1reaction
DSorlovcommented, Feb 8, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using GitHub our Master branch is broken with the latest ...
The master branch of our GitHub repository is broken with the latest check-in. Unfortunately, I pulled in the latest master check-in to my ......
Read more >
Basic Branching and Merging - Git SCM
First, let's say you're working on your project and have a couple of commits already on the master branch. A simple commit history....
Read more >
Git corrupt master branch - Super User
The repository exists, but all my commits have disappeared. What exactly do you mean? Is the working tree still there? Does .git/ exist?...
Read more >
Git happens! 6 Common Git mistakes and how to fix them
This creates a new branch, then rolls back the master branch to where it was before you made changes, before finally checking out...
Read more >
How to Git rebase a branch to master by example
In this tutorial, we will take the branch named develop and rebase it onto the tip of master. The develop branch broke off...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found