|
List Info
Thread: Net::DNS objects
|
|
| Net::DNS objects |

|
2006-03-29 08:53:49 |
Hello, I'm using Net: NS to do
a dns lookup against a specific server,
following on the instructions in the Net: NS man
page, I have created a
lookup object:-
my $lookup = Net: NS::Reso
lver->new(
nameservers => [$nameserver],
recurse => 0,
debug => 0,
);
and I can do a lookup with :-
my $packet = $lookup->send($query);
Taking $packet apart with Data: umper
reveals the structure but I cannot
get the syntax correct to extract the lookup result from
$packet. I am
assuming that $packet is an object so:-
my $reply = $packet-> ; (amongst other tries)
Clearly this is not correct but I cannot see why. The first
part of the
structure of $packet is:-
DataDumper of $packet is
$VAR1 = bless( {
'answer' => [
bless( {
'rdlength' =>
4,
'ttl' => 10800,
'name' =>
'ns0.brm.pri',
'address' =>
'10.79.0.100',
'class' =>
'IN',
'type' =>
'A',
'rdata' => '
Od'
}, 'Net: NS::RR::
A' )
],
Can anyone put me on the right track?
Regards,
Andrew
"If the SOFTWARE is not accompanied by HARDWARE, you
may not use the
SOFTWARE."
Win eXPerimantal EULA. Really....?
|
|
| DNS objects |

|
2006-03-29 09:31:40 |
$packet->answer should return a list of Net: NS::RR
objects. In your case,
one Net: NS::RR::
A object so you should be able to access the object by
using : (Though the data dump suggests it is not a list)
$packet->answer->[0]->address;
If it is not a list then $packet->answer->address
should work.
Cheers
Ben
-----Original Message-----
From: birmingham-pm-bounces+bellis=i2q.co.uk pm.org
[mailto:birmingham-pm-bounces+bellis=i2q.co.uk pm.org]
On Behalf Of Andrew
Stringer
Sent: 29 March 2006 09:54
To: birmingham-pm pm.org
Subject: Net: NS
objects
Hello, I'm using Net: NS to do
a dns lookup against a specific server,
following on the instructions in the Net: NS man
page, I have created a
lookup object:-
my $lookup = Net: NS::Reso
lver->new(
nameservers => [$nameserver],
recurse => 0,
debug => 0,
);
and I can do a lookup with :-
my $packet = $lookup->send($query);
Taking $packet apart with Data: umper
reveals the structure but I cannot
get the syntax correct to extract the lookup result from
$packet. I am
assuming that $packet is an object so:-
my $reply = $packet-> ; (amongst other tries)
Clearly this is not correct but I cannot see why. The first
part of the
structure of $packet is:-
DataDumper of $packet is
$VAR1 = bless( {
'answer' => [
bless( {
'rdlength' =>
4,
'ttl' => 10800,
'name' =>
'ns0.brm.pri',
'address' =>
'10.79.0.100',
'class' =>
'IN',
'type' =>
'A',
'rdata' => '
Od'
}, 'Net: NS::RR::
A' )
],
Can anyone put me on the right track?
Regards,
Andrew
"If the SOFTWARE is not accompanied by HARDWARE, you
may not use the
SOFTWARE."
Win eXPerimantal EULA. Really....?
|
|
| Net::DNS objects |

|
2006-03-29 09:24:59 |
Hello.
On Wed, 2006-03-29 at 09:53 +0100, Andrew Stringer wrote:
> Hello, I'm using Net: NS to do
a dns lookup against a specific server,
> following on the instructions in the Net: NS man
page, I have created a
> lookup object:-
> my $lookup = Net: NS::Reso
lver->new(
> nameservers => [$nameserver],
> recurse => 0,
> debug => 0,
> );
>
> and I can do a lookup with :-
> my $packet = $lookup->send($query);
>
> Taking $packet apart with Data: umper
reveals the structure but I cannot
> get the syntax correct to extract the lookup result
from $packet. I am
> assuming that $packet is an object so:-
> my $reply = $packet-> ; (amongst other
tries)
[snip]
Not used this module, but from "perldoc Net: NS::Reso
lver":
"Returns a "Net: NS::Pack
et" object whether there were any answers or
not. Use "$packet->header->ancount" or
"$packet->answer" to find out if
there were any records in the answer section. Returns
"undef" if there
was an error."
"perldoc Net: NS::Pack
et" shows:
"answer, pre, prerequisite
answer = $packet->answer;
Returns a list of "Net: NS::RR&
quot; objects representing the answer sec-
tion of the packet."
I guess you want something like this:
my $answer;
if (defined($packet->answer) &&
defined($packet->answer->[0]))
{
$answer = $packet->answer->[0]->;
}
...assuming you want only the first A record.
(Completely untested code. May be broken!)
Bye, Rich
--
Richard Dawe
Senior Software Engineer
MessageLabs - Be Certain
____________________________________________________________
__________
This email has been scanned by the MessageLabs Email
Security System.
For more information please visit http://www.messagela
bs.com/email
____________________________________________________________
__________
|
|
| Net::DNS objects |

|
2006-03-30 10:06:55 |
Thanks to Ben & Richard, but I'm still confused.
If I do:-
my answer=$packet->answer ;
I get:-
$answer[0] is Net: NS::RR::
A=HASH(0x8410f5c)
This suggests to me that $packet->answer->[0] contains
a hash reference,
and I should be able to use -> as the key to get
the value.
But the result from:-
print $packet->answer->[0]->,
"\n\n";
is:-
Use of uninitialized value in print at ./test.pl line 29
Is uninitialized the same as undef?
If it is, I think I am asking for the value from a non
existant key, but I
cannot see how to craft the correct question to a key value
which exists.
Regards,
Andrew
"If the SOFTWARE is not accompanied by HARDWARE, you
may not use the
SOFTWARE."
Win eXPerimental EULA. Really....?
|
|
| Net::DNS objects |

|
2006-03-30 14:16:14 |
Andrew,
So am I. Have you tried $packet->answer->?.
Alternatively break it down :
$answer = =$packet->answer;
$address = $answer->;
And see if that helps.
Cheers
Ben
-----Original Message-----
From: birmingham-pm-bounces+bellis=i2q.co.uk pm.org
[mailto:birmingham-pm-bounces+bellis=i2q.co.uk pm.org]
On Behalf Of Andrew
Stringer
Sent: 30 March 2006 11:07
To: birmingham-pm pm.org
Subject: Re: Net: NS
objects
Thanks to Ben & Richard, but I'm still confused.
If I do:-
my answer=$packet->answer ;
I get:-
$answer[0] is Net: NS::RR::
A=HASH(0x8410f5c)
This suggests to me that $packet->answer->[0] contains
a hash reference,
and I should be able to use -> as the key to get
the value.
But the result from:-
print $packet->answer->[0]->,
"\n\n";
is:-
Use of uninitialized value in print at ./test.pl line 29
Is uninitialized the same as undef?
If it is, I think I am asking for the value from a non
existant key, but I
cannot see how to craft the correct question to a key value
which exists.
Regards,
Andrew
"If the SOFTWARE is not accompanied by HARDWARE, you
may not use the
SOFTWARE."
Win eXPerimental EULA. Really....?
|
|
[1-5]
|
|