online icon indicating copy to clipboard operation
online copied to clipboard

Custom DNS resolver

Open jesusprubio opened this issue 1 year ago • 6 comments

jesusprubio avatar Apr 21 '24 21:04 jesusprubio

Hi @jesusprubio , I would like to contribute to this if you could help me a bit by adding more description to the issue, and what needs to be done.

mohitsethia avatar Jul 10 '24 18:07 mohitsethia

Hi @mohitsethia , I appreciate it.

The idea is to use a custom DNS resolver here. Similar to this example: https://stackoverflow.com/a/59889883.

We also need to add a new option in the CLI here. For example: flag.StringVar(&opts.DNSResolver, "r", "", "DNS resolution server")

By default, the one defined in the operating system should be used (like now).

jesusprubio avatar Jul 11 '24 14:07 jesusprubio

Thanks for sharing. So, there are 2 ways of doing it, adding another protocol with "customDNSProbe" key and use it based on the input received from options DNSResolver flag while getting GetProtocolByIDWithCustomDNSResolver(id, dnsResolver) *pkg.Protocol or ProtocolByID(opts Options) *pkg.Protocol that returns the customDNSProbe(domain, timeout) and implements the custom resolver. Or pass the opts struct to the dnsProbe (have to keep it consistent for all Probe implementations) methods to be able to check if we have custom dns resolver not empty then proceed with the custom dns resolver otherwise the default one. How would you suggest passing this info that we have a custom DNS resolver to the dnsProbe function?

mohitsethia avatar Jul 11 '24 21:07 mohitsethia

@jesusprubio Just an sample of how we can do additionally by adding WithDNSResolver method over Protocol. PR. If this look fine to you, maybe I can add tests too for this.

mohitsethia avatar Jul 12 '24 14:07 mohitsethia

My fault, probably this is not the best good first issue. It implies more changes than I initially thought.

jesusprubio avatar Jul 13 '24 07:07 jesusprubio

Hey @jesusprubio , sorry to bother you. I have added another way of doing this change, this solution is better & more simple. To keep it consistent I have added the other Probes (http & tcp) under receiver method too. How does this look?

mohitsethia avatar Jul 13 '24 12:07 mohitsethia