← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 03:09:29 2017
Reported on Mon Nov 6 13:20:47 2017

Filename/usr/local/lib/perl5/site_perl/Net/DNS/Update.pm
StatementsExecuted 14 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11144µs54µsNet::DNS::Update::::BEGIN@32Net::DNS::Update::BEGIN@32
11124µs61µsNet::DNS::Update::::BEGIN@33Net::DNS::Update::BEGIN@33
11122µs195µsNet::DNS::Update::::BEGIN@35Net::DNS::Update::BEGIN@35
11121µs226µsNet::DNS::Update::::BEGIN@37Net::DNS::Update::BEGIN@37
11119µs27µsNet::DNS::Update::::BEGIN@34Net::DNS::Update::BEGIN@34
11118µs18µ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#
612µ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
32258µs264µs
# spent 54µs (44+10) within Net::DNS::Update::BEGIN@32 which was called: # once (44µs+10µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 32
use strict;
# spent 54µs making 1 call to Net::DNS::Update::BEGIN@32 # spent 10µs making 1 call to strict::import
33256µs298µs
# spent 61µs (24+37) within Net::DNS::Update::BEGIN@33 which was called: # once (24µs+37µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 33
use warnings;
# spent 61µs making 1 call to Net::DNS::Update::BEGIN@33 # spent 37µs making 1 call to warnings::import
34265µs234µs
# spent 27µs (19+7) within Net::DNS::Update::BEGIN@34 which was called: # once (19µs+7µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 34
use integer;
# spent 27µs making 1 call to Net::DNS::Update::BEGIN@34 # spent 8µs making 1 call to integer::import
35263µs2367µs
# spent 195µs (22+172) within Net::DNS::Update::BEGIN@35 which was called: # once (22µs+172µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 35
use Carp;
# spent 195µs making 1 call to Net::DNS::Update::BEGIN@35 # spent 172µs making 1 call to Exporter::import
36
37268µs2431µs
# spent 226µs (21+205) within Net::DNS::Update::BEGIN@37 which was called: # once (21µs+205µs) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 37
use base qw(Net::DNS::Packet);
# spent 226µs making 1 call to Net::DNS::Update::BEGIN@37 # spent 205µs making 1 call to base::import
38
392756µs118µs
# spent 18µs within Net::DNS::Update::BEGIN@39 which was called: # once (18µs+0s) by Mail::SpamAssassin::PerMsgStatus::BEGIN@74 at line 39
use Net::DNS::Resolver;
# spent 18µ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
14818µs1;
149
150__END__