Mojo::IOLoop::DNSNative - Async native DNS lookup
version 0.001
use feature 'say'; use Mojo::IOLoop; use Mojo::IOLoop::DNSNative; my $loop = Mojo::IOLoop->new; my $dns = Mojo::IOLoop::DNSNative->new(reactor => $loop->reactor); $dns->lookup( 'google.com', sub { my ($err, @ips) = @_; die "Could not look up google.com: $err" if $err; say for @ips; } ); $loop->start;
Look up hostnames using Net::DNS::Native in a Mojo::IOLoop without blocking.
Mojo::IOLoop::DNSNative implements the following attributes.
my $ndn = $dns->NDN; $dns = $dns->NDN(Net::DNS::Native->new(pool => 5, extra_thread => 1));
The underlying Net::DNS::Native object used to perform lookups.
my $reactor = $dns->reactor; $dns = $dns->reactor(Mojo::Reactor::Poll->new);
Low-level event reactor, defaults to the reactor attribute of the global Mojo::IOLoop singleton.
reactor
my $timeout = $dns->timeout; $dns = $dns->timeout(10);
Sets the timeout for lookups. Use 0 to disable timeouts.
Mojo::IOLoop::DNSNative implements the following methods.
$dns->lookup( $host, sub { my ($err, @ips) = @_; die "Could not lookup $host: $err" if $err; say "$host resolves to @ips"; } );
Look up a hostname using Net::DNS::Native and get all the IPs it resolves to.
Andreas Guldstrand <andreas.guldstrand@gmail.com>
This software is Copyright (c) 2017 by Andreas Guldstrand.
This is free software, licensed under:
The MIT (X11) License
To install Mojo::IOLoop::DNSNative, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::IOLoop::DNSNative
CPAN shell
perl -MCPAN -e shell install Mojo::IOLoop::DNSNative
For more information on module installation, please visit the detailed CPAN module installation guide.