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");
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.