Hmmno thanks. I already have a job, and though it has its ups and downs, I'm not looking for another :).
You're still free to keep asking questions to the monks in general though.
Edit: Cleaned up code and perltidy'd it. There seems to be a bug in Net::DNS::Packet where, if you remove the debug-flag when creating a new packet object from raw data, the answer section doesn't get decoded.
use strict;
use warnings;
use AnyEvent::Handle::UDP;
use Socket;
use Net::DNS::Packet;
use Data::Dump;
my $target_host = shift;
if (!defined $target_host) {
print ("Usage: $0 hostname\n");
exit 1;
}
my $d = Net::DNS::Packet->new($target_host, "PTR");
my $cv_recv = AnyEvent->condvar;
my $t = AnyEvent::Handle::UDP->new(
timeout => 3,
on_timeout => sub {
print STDERR "Nothing happened within the specified timeout ti
+meframe...\n";
},
on_error => sub {
print STDERR "An error has occurred:";
Data::Dump::dd(@_);
},
on_recv => sub {
my ($buf, $handle) = @_;
my ($res, $err) = Net::DNS::Packet->new(\$buf,1);
if ($err) {
print STDERR $err . "\n";
} else {
Data::Dump::dd($res);
}
$cv_recv->send;
},
);
$t->bind_to(['0.0.0.0', 0]);
my $cv_send = $t->push_send($d->data, pack_sockaddr_in(53, Socket::ine
+t_aton('IP_OF_DNS-SERVER_HERE')));
print ("Waiting for data to be sent...");
$cv_send->recv;
print ("[OK]\n");
print ("Waiting for data to arrive...");
$cv_recv->recv;
print ("[OK]\n");
| [reply] [d/l] |