0

How to configure AnyEvent::DNS resolver by default, I want to change max_outstanding, reuse, timeout. There is an environment variable $ENV{PERL_ANYEVENT_MAX_OUTSTANDING_DNS}, but how to change reuse and timeout ?

Dmitriy
  • 463
  • 1
  • 5
  • 12

1 Answers1

3

$ENV{PERL_ANYEVENT_MAX_OUTSTANDING_DNS} is only used if the default resolver is used, so you must be using the default resolver, so you can just change the default resolver.

use AnyEvent::DNS qw( );

my $resolver = AnyEvent::DNS->new(
   untaint         => 1,
   max_outstanding => $ENV{PERL_ANYEVENT_MAX_OUTSTANDING_DNS}*1 || ...,
   reuse           => ...,
   timeout         => ...,
);

$ENV{PERL_ANYEVENT_RESOLV_CONF}
   ? $resolver->_load_resolv_conf_file($ENV{PERL_ANYEVENT_RESOLV_CONF})
   : $resolver->os_config;

$AnyEvent::DNS::RESOLVER = $resolver;
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • Once again I say thank you. I do not quite understand what defines reuse in the settings of the AnyEvent::DNS. The description says: "The number of seconds (default: 300) that a query id cannot be re-used after a timeout. If there was no time-out then query ids can be reused immediately." What is a "query id" and why does it wait for 300 seconds? – Dmitriy Apr 17 '17 at 21:54
  • Don't know. . . – ikegami Apr 17 '17 at 22:09