| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DNS::DurableDNS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20941
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
1900
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require SOAP::Lite; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::DNS::DurableDNS - Wrapper for the DurableDNS API at http://durabledns.com |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Net::DNS::DurableDNS; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $durable = Net::DNS::DurableDNS->new({ apiuser => $user, |
|
27
|
|
|
|
|
|
|
apikey => $key }); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $zones = $durable->listZones(); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
new( { apiuser => $user, apikey => $key } ) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
returns a new object for accessing the DurableDNS API. The API user and key are from your |
|
38
|
|
|
|
|
|
|
DurableDNS.com account. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
|
43
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
44
|
0
|
|
|
|
|
|
bless { |
|
45
|
|
|
|
|
|
|
apiuser => $att->{apiuser}, |
|
46
|
|
|
|
|
|
|
apikey => $att->{apikey}, |
|
47
|
|
|
|
|
|
|
}, $S; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 listZones |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub listZones { |
|
55
|
|
|
|
|
|
|
# Returns a reference to an array |
|
56
|
0
|
|
|
0
|
|
|
my ($S) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
59
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/listZones.php?wsdl') |
|
60
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/listZones.php'); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $result = $service->listZones($S->{apiuser},$S->{apikey}); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$S->{status} = {}; |
|
65
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
66
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'OK'}; |
|
67
|
0
|
|
|
|
|
|
my @results = $result->valueof('//origin'); |
|
68
|
0
|
|
|
|
|
|
return \@results; |
|
69
|
|
|
|
|
|
|
} else { |
|
70
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
71
|
|
|
|
|
|
|
message=> join ', ', |
|
72
|
|
|
|
|
|
|
$result->faultcode, |
|
73
|
|
|
|
|
|
|
$result->faultstring}; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 getZone |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub getZone { |
|
83
|
|
|
|
|
|
|
# Returns a reference to an array |
|
84
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
87
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/getZone.php?wsdl') |
|
88
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/getZone.php'); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
91
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $result = $service->getZone($S->{apiuser}, |
|
94
|
|
|
|
|
|
|
$S->{apikey}, |
|
95
|
|
|
|
|
|
|
$att->{zonename}, |
|
96
|
|
|
|
|
|
|
); |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$S->{status} = {}; |
|
99
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
100
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'OK'}; |
|
101
|
0
|
|
|
|
|
|
my @results = $result->valueof('//getZoneResponse'); |
|
102
|
0
|
|
|
|
|
|
return \@results; |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
105
|
|
|
|
|
|
|
message=> join ', ', |
|
106
|
|
|
|
|
|
|
$result->faultcode, |
|
107
|
|
|
|
|
|
|
$result->faultstring}; |
|
108
|
0
|
|
|
|
|
|
return ''; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 deleteRecordById |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub deleteRecordById { |
|
118
|
|
|
|
|
|
|
# Returns a reference to an array |
|
119
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
122
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/deleteRecord.php?wsdl') |
|
123
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/deleteRecord.php'); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
126
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $result = $service->deleteRecord($S->{apiuser}, |
|
129
|
|
|
|
|
|
|
$S->{apikey}, |
|
130
|
|
|
|
|
|
|
$att->{zonename}, |
|
131
|
|
|
|
|
|
|
$att->{recordid}, |
|
132
|
|
|
|
|
|
|
); |
|
133
|
0
|
|
|
|
|
|
$S->{status} = {}; |
|
134
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
135
|
0
|
|
|
|
|
|
my $response = $result->valueof('//deleteRecordResponse')->{return}; |
|
136
|
0
|
0
|
|
|
|
|
if ($response eq 'Success') { |
|
137
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'deleteRecordById:OK'}; |
|
138
|
|
|
|
|
|
|
} else { |
|
139
|
0
|
|
|
|
|
|
$S->{result} = {status=>0,message=>$response}; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
0
|
|
|
|
|
|
return $result->valueof('//deleteRecordResponse')->{return}; |
|
142
|
|
|
|
|
|
|
} else { |
|
143
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
144
|
|
|
|
|
|
|
message=> join ', ', |
|
145
|
|
|
|
|
|
|
$result->faultcode, |
|
146
|
|
|
|
|
|
|
$result->faultstring}; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 deleteRecordByName |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub deleteRecordByName { |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Returns a reference to an array |
|
158
|
|
|
|
|
|
|
# expects zonename and name |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
161
|
0
|
|
|
|
|
|
my $success = 0; |
|
162
|
|
|
|
|
|
|
# get the list of records for the zone |
|
163
|
0
|
|
|
|
|
|
my $records = listRecords($S,$att); |
|
164
|
0
|
|
|
|
|
|
my $return = 0; |
|
165
|
0
|
0
|
|
|
|
|
if ($records) { |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# loop through records until we find one; |
|
168
|
0
|
|
|
|
|
|
foreach my $record (@$records) { |
|
169
|
0
|
0
|
|
|
|
|
if ($record->{name} eq $att->{name}) { |
|
170
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
171
|
|
|
|
|
|
|
message=> join ', ', 'deleteRecordByName:OK'}; |
|
172
|
0
|
|
|
|
|
|
deleteRecordById($S,{recordid=>$record->{id},zonename=>$att->{zonename}}); |
|
173
|
0
|
|
|
|
|
|
$return = 1; |
|
174
|
0
|
|
|
|
|
|
last; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
return $return; |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} else { |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
my $previous_message = ($S->{result}->{message}) ? $S->{result}->{message} . ';' : ''; |
|
183
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
184
|
|
|
|
|
|
|
message=> join ', ', |
|
185
|
|
|
|
|
|
|
$previous_message , |
|
186
|
|
|
|
|
|
|
'DurableDNS.pm', |
|
187
|
|
|
|
|
|
|
'No record named ' . $att->{name} . '.'}; |
|
188
|
0
|
|
|
|
|
|
return $return; |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 getRecordById |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub getRecordById { |
|
199
|
|
|
|
|
|
|
# Returns a reference to an array |
|
200
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
203
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/getRecord.php?wsdl') |
|
204
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/getRecord.php'); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
207
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
my $result = $service->getRecord($S->{apiuser}, |
|
211
|
|
|
|
|
|
|
$S->{apikey}, |
|
212
|
|
|
|
|
|
|
$att->{zonename}, |
|
213
|
|
|
|
|
|
|
$att->{recordid}, |
|
214
|
|
|
|
|
|
|
); |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$S->{status} = {}; |
|
217
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
218
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'OK'}; |
|
219
|
0
|
|
|
|
|
|
my @results = $result->valueof('//origin'); |
|
220
|
0
|
|
|
|
|
|
return \@results; |
|
221
|
|
|
|
|
|
|
} else { |
|
222
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
223
|
|
|
|
|
|
|
message=> join ', ', |
|
224
|
|
|
|
|
|
|
$result->faultcode, |
|
225
|
|
|
|
|
|
|
$result->faultstring}; |
|
226
|
0
|
|
|
|
|
|
return ''; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 getRecordByName |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=cut |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub getRecordByName { |
|
236
|
|
|
|
|
|
|
# Returns a reference to an array |
|
237
|
|
|
|
|
|
|
# expects zonename, name and type |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
240
|
0
|
|
|
|
|
|
my $success = 0; |
|
241
|
|
|
|
|
|
|
# get the list of records for the zone |
|
242
|
0
|
|
|
|
|
|
my $records = listRecords($S,$att); |
|
243
|
|
|
|
|
|
|
|
|
244
|
0
|
0
|
|
|
|
|
if ($records) { |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# loop through records until we find one; |
|
247
|
0
|
|
|
|
|
|
foreach my $record (@$records) { |
|
248
|
0
|
0
|
0
|
|
|
|
if ( ($record->{name} eq $att->{name}) && ($record->{type} eq $att->{type}) ){ |
|
249
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
250
|
|
|
|
|
|
|
message=> join ', ', 'getRecordByName:OK'}; |
|
251
|
0
|
|
|
|
|
|
return $record; |
|
252
|
0
|
|
|
|
|
|
exit; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} else { |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
0
|
|
|
|
|
my $previous_message = ($S->{result}->{message}) ? $S->{result}->{message} . ';' : ''; |
|
259
|
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
261
|
|
|
|
|
|
|
message=> join ', ', |
|
262
|
|
|
|
|
|
|
$previous_message , |
|
263
|
|
|
|
|
|
|
'DurableDNS.pm', |
|
264
|
|
|
|
|
|
|
'No record named ' . $att->{name} . '.'}; |
|
265
|
0
|
|
|
|
|
|
return ''; |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 listRecords |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=cut |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub listRecords { |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# Returns a reference to an array of hash references |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# Each Record Can Contain |
|
281
|
|
|
|
|
|
|
# id Unique numeric ID of record |
|
282
|
|
|
|
|
|
|
# name Name of record |
|
283
|
|
|
|
|
|
|
# type DNS record type |
|
284
|
|
|
|
|
|
|
# data Data for record |
|
285
|
|
|
|
|
|
|
# ttl Time-to-live for record in seconds |
|
286
|
|
|
|
|
|
|
# aux |
|
287
|
|
|
|
|
|
|
|
|
288
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
289
|
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
291
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/listRecords.php?wsdl') |
|
292
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/listRecords.php'); |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
295
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
296
|
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
my $result = $service->listRecords($S->{apiuser},$S->{apikey},$att->{zonename}); |
|
298
|
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
$S->{result} = {}; |
|
300
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
301
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'listRecords:OK'}; |
|
302
|
0
|
|
|
|
|
|
return $result->valueof('//listRecordsResponse')->{return}; |
|
303
|
|
|
|
|
|
|
} else { |
|
304
|
0
|
|
|
|
|
|
warn Dumper($result); |
|
305
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
306
|
|
|
|
|
|
|
message=> join ', ', |
|
307
|
|
|
|
|
|
|
$result->faultcode, |
|
308
|
|
|
|
|
|
|
$result->faultstring}; |
|
309
|
|
|
|
|
|
|
} |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head2 createRecord |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=cut |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub createRecord { |
|
318
|
|
|
|
|
|
|
|
|
319
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
# apiuser Value for authentication |
|
322
|
|
|
|
|
|
|
# apikey Value for authentication |
|
323
|
|
|
|
|
|
|
# zonename Name of zone to add record to, followed by a dot (.). |
|
324
|
|
|
|
|
|
|
# name Name of record to create. Example: ÒwwwÓ or |
|
325
|
|
|
|
|
|
|
# type DNS record type Ð A, AAAA, CNAME, HINFO, MX, NS, PTR, RP, SRV, or TXT |
|
326
|
|
|
|
|
|
|
# aux Preference, priority, or weight of record (optional) |
|
327
|
|
|
|
|
|
|
# ttl Time-to-live for record in seconds |
|
328
|
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
330
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/createRecords.php?wsdl') |
|
331
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/createRecord.php'); |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
334
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# first we have to make sure the record does not exist |
|
337
|
|
|
|
|
|
|
# look up by name |
|
338
|
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
|
my $record = getRecordByName($S,$att); |
|
340
|
|
|
|
|
|
|
|
|
341
|
0
|
0
|
0
|
|
|
|
if ($record && $att->{type} ne 'MX' && $record && $att->{type} ne 'NS') { |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
|
343
|
0
|
0
|
|
|
|
|
my $previous_message = ($S->{result}->{message}) ? $S->{result}->{message} . ';' : ''; |
|
344
|
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
346
|
|
|
|
|
|
|
message=> join ', ', |
|
347
|
|
|
|
|
|
|
$previous_message , |
|
348
|
|
|
|
|
|
|
'DurableDNS.pm', |
|
349
|
|
|
|
|
|
|
'Record named ' . $att->{name} . ' of type ' . $att->{type} . ' already exists'}; |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
} else { |
|
352
|
|
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
my $result = $service->createRecord($S->{apiuser}, |
|
354
|
|
|
|
|
|
|
$S->{apikey}, |
|
355
|
|
|
|
|
|
|
$att->{zonename}, |
|
356
|
|
|
|
|
|
|
$att->{name}, |
|
357
|
|
|
|
|
|
|
$att->{type}, |
|
358
|
|
|
|
|
|
|
$att->{data}, |
|
359
|
|
|
|
|
|
|
$att->{aux}, |
|
360
|
|
|
|
|
|
|
$att->{ttl}, |
|
361
|
|
|
|
|
|
|
); |
|
362
|
|
|
|
|
|
|
|
|
363
|
0
|
|
|
|
|
|
$S->{result} = {}; |
|
364
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
365
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'createRecord:OK'}; |
|
366
|
0
|
|
|
|
|
|
my $response = $result->valueof('//createRecordResponse')->{return}; |
|
367
|
0
|
|
|
|
|
|
return $result->valueof('//createRecordResponse')->{return}; |
|
368
|
|
|
|
|
|
|
} else { |
|
369
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
370
|
|
|
|
|
|
|
message=> join ', ', |
|
371
|
|
|
|
|
|
|
$result->faultcode, |
|
372
|
|
|
|
|
|
|
$result->faultstring}; |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head2 updateRecord |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
updateRecord( $hostnames, $ip_address, $params ) |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
# if a recordid is provided, we use it |
|
386
|
|
|
|
|
|
|
# if recordid is not provide and oldname is provided we use oldname to look up the recordid |
|
387
|
|
|
|
|
|
|
# if neither oldname nor recordid is provided, we look it up based on name |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
# if orcreate is passed in, if no record exists, a new one will be created |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# |
|
392
|
|
|
|
|
|
|
# |
|
393
|
|
|
|
|
|
|
# |
|
394
|
|
|
|
|
|
|
# |
|
395
|
|
|
|
|
|
|
# |
|
396
|
|
|
|
|
|
|
# |
|
397
|
|
|
|
|
|
|
# |
|
398
|
|
|
|
|
|
|
# |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
Parameter Default Values |
|
401
|
|
|
|
|
|
|
system dyndns dyndns | statdns | custom |
|
402
|
|
|
|
|
|
|
wildcard none ON | OFF | NOCHG |
|
403
|
|
|
|
|
|
|
mx none any valid fully qualified hostname |
|
404
|
|
|
|
|
|
|
backmx none YES | NO |
|
405
|
|
|
|
|
|
|
offline none YES | NO |
|
406
|
|
|
|
|
|
|
protocol https http | https |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
Further information about each of these parameters is available at |
|
409
|
|
|
|
|
|
|
http://www.dyndns.org/developers/specs/syntax.html |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=cut |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub updateRecord { |
|
414
|
|
|
|
|
|
|
|
|
415
|
0
|
|
|
0
|
|
|
my ($S,$att) = @_; |
|
416
|
|
|
|
|
|
|
|
|
417
|
0
|
|
|
|
|
|
my $service = SOAP::Lite |
|
418
|
|
|
|
|
|
|
-> uri('https://durabledns.com/services/dns/updateRecord.php?wsdl') |
|
419
|
|
|
|
|
|
|
-> proxy('https://durabledns.com/services/dns/updateRecord.php'); |
|
420
|
|
|
|
|
|
|
|
|
421
|
0
|
|
|
|
|
|
my $error_message; |
|
422
|
|
|
|
|
|
|
my $record; |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
# durable wants a trailing '.' |
|
425
|
0
|
0
|
|
|
|
|
$att->{zonename} = ($att->{zonename} =~ /\.$/) ? $att->{zonename} : $att->{zonename} . "."; |
|
426
|
|
|
|
|
|
|
|
|
427
|
0
|
0
|
|
|
|
|
if (!$att->{recordid}) { |
|
428
|
|
|
|
|
|
|
|
|
429
|
0
|
|
|
|
|
|
my $name = $att->{name}; |
|
430
|
|
|
|
|
|
|
|
|
431
|
0
|
0
|
|
|
|
|
$att->{name} = ($att->{oldname}) ? $att->{oldname} : $att->{name}; |
|
432
|
0
|
|
|
|
|
|
$error_message = 'Record named ' . $att->{name} . ' does not exist'; |
|
433
|
0
|
|
|
|
|
|
$record = getRecordByName($S,$att); |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
# restore the $att->{name} |
|
436
|
0
|
|
|
|
|
|
$att->{name} = $name; |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
} else { |
|
439
|
|
|
|
|
|
|
|
|
440
|
0
|
|
|
|
|
|
$record = getRecordByID($S,$att); |
|
441
|
0
|
|
|
|
|
|
$error_message = 'Record id ' . $att->{name} . ' does not exist'; |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
} |
|
444
|
|
|
|
|
|
|
|
|
445
|
0
|
0
|
|
|
|
|
if ($record) { |
|
|
|
0
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
|
|
447
|
0
|
|
0
|
|
|
|
my $result = $service->updateRecord($S->{apiuser}, |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
448
|
|
|
|
|
|
|
$S->{apikey}, |
|
449
|
|
|
|
|
|
|
$att->{zonename}, |
|
450
|
|
|
|
|
|
|
$record->{id}, |
|
451
|
|
|
|
|
|
|
$att->{name}, |
|
452
|
|
|
|
|
|
|
$att->{aux} || $record->{aux} || 0, |
|
453
|
|
|
|
|
|
|
$att->{data} || $record->{data}, |
|
454
|
|
|
|
|
|
|
$att->{ttl} || $record->{ttl}, |
|
455
|
|
|
|
|
|
|
); |
|
456
|
|
|
|
|
|
|
|
|
457
|
0
|
|
|
|
|
|
$S->{result} = {}; |
|
458
|
0
|
0
|
|
|
|
|
unless ($result->fault) { |
|
459
|
0
|
|
|
|
|
|
$S->{result} = {status=>1,message=>'updateRecord:OK'}; |
|
460
|
0
|
|
|
|
|
|
my $response = $result->valueof('//updateRecordResponse')->{return}; |
|
461
|
0
|
|
|
|
|
|
return $result->valueof('//updateRecordResponse')->{return}; |
|
462
|
|
|
|
|
|
|
} else { |
|
463
|
0
|
|
|
|
|
|
$S->{result} = {status=>1, |
|
464
|
|
|
|
|
|
|
message=> join ', ', |
|
465
|
|
|
|
|
|
|
$result->faultcode, |
|
466
|
|
|
|
|
|
|
$result->faultstring}; |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
} elsif ($att->{orcreate}) { |
|
471
|
|
|
|
|
|
|
|
|
472
|
0
|
|
|
|
|
|
return createRecord($S,$att); |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
} else { |
|
475
|
|
|
|
|
|
|
|
|
476
|
0
|
0
|
|
|
|
|
my $previous_message = ($S->{result}->{message}) ? $S->{result}->{message} . ';' : ''; |
|
477
|
|
|
|
|
|
|
|
|
478
|
0
|
|
|
|
|
|
$S->{result} = {status=>0, |
|
479
|
|
|
|
|
|
|
message=> join ', ', |
|
480
|
|
|
|
|
|
|
$previous_message , |
|
481
|
|
|
|
|
|
|
'DurableDNS.pm', |
|
482
|
|
|
|
|
|
|
$error_message}; |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
} |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=head2 info |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=cut |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
sub info { |
|
494
|
0
|
|
|
0
|
|
|
my ($S) = @_; |
|
495
|
0
|
|
|
|
|
|
return $S->{result}; |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head1 AUTHOR |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
Richard K Bush, C<< >> |
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head1 BUGS |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
505
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
506
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=head1 SUPPORT |
|
510
|
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
512
|
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
perldoc Net::DNS::DurableDNS |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
You can also look for information at: |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=over 4 |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
L |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
L |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
L |
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=item * Search CPAN |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
L |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=back |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
Copyright 2012 Richard K Bush. |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
547
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
548
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
551
|
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=cut |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
1; # End of Net::DNS::DurableDNS |