← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:20 2017

Filename/usr/local/lib/perl5/site_perl/Net/DNS/Update.pm
StatementsExecuted 14 statements in 1.28ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11146µs57µsNet::DNS::Update::::BEGIN@32Net::DNS::Update::BEGIN@32
11130µs271µsNet::DNS::Update::::BEGIN@37Net::DNS::Update::BEGIN@37
11128µs35µsNet::DNS::Update::::BEGIN@34Net::DNS::Update::BEGIN@34
11126µs64µsNet::DNS::Update::::BEGIN@33Net::DNS::Update::BEGIN@33
11124µs237µsNet::DNS::Update::::BEGIN@35Net::DNS::Update::BEGIN@35
11120µs20µsNet::DNS::Update::::BEGIN@39Net::DNS::Update::BEGIN@39
0000s0sNet::DNS::Update::::newNet::DNS::Update::new
0000s0sNet::DNS::Update::::pushNet::DNS::Update::push
0000s0sNet::DNS::Update::::unique_pushNet::DNS::Update::unique_push
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Net::DNS::Update;
2
3#
4# $Id: Update.pm 1571 2017-06-03 20:14:15Z willem $
5#
617µsour $VERSION = (qw$LastChangedRevision: 1571 $)[1];
7
8
9=head1 NAME
10
11Net::DNS::Update - DNS dynamic update packet
12
13=head1 SYNOPSIS
14
15 use Net::DNS;
16
17 $update = new Net::DNS::Update( 'example.com', 'IN' );
18
19 $update->push( prereq => nxrrset('foo.example.com. A') );
20 $update->push( update => rr_add('foo.example.com. 86400 A 192.168.1.2') );
21
22=head1 DESCRIPTION
23
24Net::DNS::Update is a subclass of Net::DNS::Packet, to be used for
25making DNS dynamic updates.
26
27Programmers should refer to RFC2136 for dynamic update semantics.
28
29=cut
30
31
32275µs269µs
# spent 57µs (46+12) within Net::DNS::Update::BEGIN@32 which was called: # once (46µs+12µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 32
use strict;
# spent 57µs making 1 call to Net::DNS::Update::BEGIN@32 # spent 12µs making 1 call to strict::import
33276µs2101µs
# spent 64µs (26+38) within Net::DNS::Update::BEGIN@33 which was called: # once (26µs+38µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 33
use warnings;
# spent 64µs making 1 call to Net::DNS::Update::BEGIN@33 # spent 38µs making 1 call to warnings::import
34276µs241µs
# spent 35µs (28+6) within Net::DNS::Update::BEGIN@34 which was called: # once (28µs+6µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 34
use integer;
# spent 35µs making 1 call to Net::DNS::Update::BEGIN@34 # spent 6µs making 1 call to integer::import
35274µs2451µs
# spent 237µs (24+214) within Net::DNS::Update::BEGIN@35 which was called: # once (24µs+214µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 35
use Carp;
# spent 237µs making 1 call to Net::DNS::Update::BEGIN@35 # spent 214µs making 1 call to Exporter::import
36
37276µs2512µs
# spent 271µs (30+241) within Net::DNS::Update::BEGIN@37 which was called: # once (30µs+241µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 37
use base qw(Net::DNS::Packet);
# spent 271µs making 1 call to Net::DNS::Update::BEGIN@37 # spent 241µs making 1 call to base::import
38
392879µs120µs
# spent 20µs within Net::DNS::Update::BEGIN@39 which was called: # once (20µs+0s) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 39
use Net::DNS::Resolver;
# spent 20µs making 1 call to Net::DNS::Update::BEGIN@39
40
41
42=head1 METHODS
43
44=head2 new
45
46 $update = new Net::DNS::Update;
47 $update = new Net::DNS::Update( 'example.com' );
48 $update = new Net::DNS::Update( 'example.com', 'HS' );
49
50Returns a Net::DNS::Update object suitable for performing a DNS
51dynamic update. Specifically, it creates a packet with the header
52opcode set to UPDATE and the zone record type to SOA (per RFC 2136,
53Section 2.3).
54
55Programs must use the push() method to add RRs to the prerequisite,
56update, and additional sections before performing the update.
57
58Arguments are the zone name and the class. The zone and class may
59be undefined or omitted and default to the default domain from the
60resolver configuration and IN respectively.
61
62=cut
63
64sub new {
65 shift;
66 my ( $zone, @class ) = @_;
67
68 my ($domain) = grep defined && length, $zone, Net::DNS::Resolver->searchlist;
69
70 eval {
71 local $SIG{__DIE__};
72
73 my $self = __PACKAGE__->SUPER::new( $domain, 'SOA', @class );
74
75 my $header = $self->header;
76 $header->opcode('UPDATE');
77 $header->qr(0);
78 $header->rd(0);
79
80 return $self;
81 } || croak $@;
82}
83
84
85=head2 push
86
87 $ancount = $update->push( prereq => $rr );
88 $nscount = $update->push( update => $rr );
89 $arcount = $update->push( additional => $rr );
90
91 $nscount = $update->push( update => $rr1, $rr2, $rr3 );
92 $nscount = $update->push( update => @rr );
93
94Adds RRs to the specified section of the update packet.
95
96Returns the number of resource records in the specified section.
97
98Section names may be abbreviated to the first three characters.
99
100=cut
101
102sub push {
103 my $self = shift;
104 my $list = $self->_section(shift);
105 my @arg = grep ref($_), @_;
106
107 my ($zone) = $self->zone;
108 my $zclass = $zone->zclass;
109 my @rr = grep $_->class( $_->class =~ /ANY|NONE/ ? () : $zclass ), @arg;
110
111 CORE::push( @$list, @rr );
112}
113
114
115=head2 unique_push
116
117 $ancount = $update->unique_push( prereq => $rr );
118 $nscount = $update->unique_push( update => $rr );
119 $arcount = $update->unique_push( additional => $rr );
120
121 $nscount = $update->unique_push( update => $rr1, $rr2, $rr3 );
122 $nscount = $update->unique_push( update => @rr );
123
124Adds RRs to the specified section of the update packet provided
125that the RRs are not already present in the same section.
126
127Returns the number of resource records in the specified section.
128
129Section names may be abbreviated to the first three characters.
130
131=cut
132
133sub unique_push {
134 my $self = shift;
135 my $list = $self->_section(shift);
136 my @arg = grep ref($_), @_;
137
138 my ($zone) = $self->zone;
139 my $zclass = $zone->zclass;
140 my @rr = grep $_->class( $_->class =~ /ANY|NONE/ ? () : $zclass ), @arg;
141
142 my %unique = map { ( bless( {%$_, ttl => 0}, ref $_ )->canonical => $_ ) } @rr, @$list;
143
144 scalar( @$list = values %unique );
145}
146
147
148114µs1;
149
150__END__