szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

Can you obtain the local hosts first and then use resolve4 or resolve6 #66

Closed ITzhangxi closed 2 years ago

ITzhangxi commented 2 years ago

Hello, I have a requirement that the local hosts should be used first and then the IP resolved by DNS service should be used. I see in the code you wrote, queryAndCache should use _resolve4 or _resolve6 first and then Lookup. Controls which parsing mode is preferred

szmarczak commented 2 years ago

What's the use case? Why not set up your own DNS server then?

ITzhangxi commented 2 years ago

Hi, I'm glad you can reply to me, thank you. I have built a local DNS service here, which is mainly used for the development of mobile H5 projects on the computer side, and the mobile terminal accesses the project through the domain name in the local area network. The DNS service I built locally uses the lookup function in the dns module, so I want to use your cacheable-lookup to do a layer of performance optimization, but I found that your cacheable-lookup first obtains the remote IP and then obtains the IP from the local hosts. I want to get the IP from the local hosts first, and then get the IP from the remote

szmarczak commented 2 years ago

The DNS service I built locally uses the lookup function in the dns module,

Why lookup and not actual DNS queries?

so I want to use your cacheable-lookup to do a layer of performance optimization

If you're explicitly relying on lookup in the OS, then I don't think using cacheable-lookup is a good idea. This was written with TTL in mind.

ITzhangxi commented 2 years ago

That's a good idea. Thank you

ITzhangxi commented 2 years ago

Thank you for your patience. Thank you