jesusprubio / up

📶 Troubleshoot problems with your Internet connection
MIT License
449 stars 20 forks source link

Custom DNS resolver #31

Closed jesusprubio closed 1 week ago

mohitsethia commented 4 months ago

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.

jesusprubio commented 4 months ago

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).

mohitsethia commented 4 months ago

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 commented 4 months ago

@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.

jesusprubio commented 4 months ago

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

mohitsethia commented 4 months ago

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?