Pergunta

Recently I switch from using LWP::UserAgent to LWPx::ParanoidAgent to fetch URLs provided by 3rd parties.

Its all very well, except sometimes a lookup in /etc/hosts is needed to resolve a domain. LWP::UserAgent did that automatically, but LWPx::ParanoidAgent only queries real DNS servers.

How can I configure LWPx::ParanoidAgent to search /etc/hosts, too ?

Update: The module lets me set a DNS resolver (Net::DNS::Resolver). Is there a way to have a DNS resolver that looks into /etc/hosts, too ?

Foi útil?

Solução

I looked at the module's source. It can't be configured to do so.

By the way, it's not using the normal name resolution system since it wants to know if the host resolves to another host name (i.e. when it's a CNAME) so it can check that host name against the host black and white lists too.

If you wanted to add this functionality, I suggest wrapping LWPx::ParanoidAgent::_resolve with something that checks /etc/hosts directly (when !$depth) before falling back to the original _resolve. Providing a Net::DNS::Resolver look-alike would be significantly more work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top