]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/ddns.cgi
ddns.cgi: Fix CGI clearing all settings.
[ipfire-2.x.git] / html / cgi-bin / ddns.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31
32 #workaround to suppress a warning when a variable is used only once
33 my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
34 undef (@dummy);
35
36 my %color = ();
37 my %mainsettings = ();
38 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
39 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
40
41 # Config file for basic configuration.
42 my $settingsfile = "${General::swroot}/ddns/settings";
43
44 # Config file to store the configured ddns providers.
45 my $datafile = "${General::swroot}/ddns/config";
46
47 # Dynamic ddns programm call.
48 my @ddnsprog = ("/usr/bin/ddns", "--config",
49 "/var/ipfire/ddns/ddns.conf",
50 "update-all");
51
52 my %settings=();
53 my $errormessage = '';
54
55 # DDNS General settings.
56 $settings{'BEHINDROUTER'} = 'RED_IP';
57
58 # Account settings.
59 $settings{'HOSTNAME'} = '';
60 $settings{'DOMAIN'} = '';
61 $settings{'LOGIN'} = '';
62 $settings{'PASSWORD'} = '';
63 $settings{'ENABLED'} = '';
64 $settings{'PROXY'} = '';
65 $settings{'SERVICE'} = '';
66
67 $settings{'ACTION'} = '';
68
69 # Get supported ddns providers.
70 my @providers = &GetProviders();
71
72 # Hook to regenerate the configuration files, if cgi got called from command line.
73 if ($ENV{"REMOTE_ADDR"} eq "") {
74 &GenerateDDNSConfigFile();
75 exit(0);
76 }
77
78 &Header::showhttpheaders();
79
80 #Get GUI values
81 &Header::getcgihash(\%settings);
82
83 # Read configuration file.
84 open(FILE, "$datafile") or die "Unable to open $datafile.";
85 my @current = <FILE>;
86 close (FILE);
87
88 #
89 # Save General Settings.
90 #
91 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
92 # Open /var/ipfire/ddns/settings for writing.
93 open(FILE, ">$settingsfile") or die "Unable to open $settingsfile.";
94
95 # Lock file for writing.
96 flock FILE, 2;
97
98 # Check if BEHINDROUTER has been configured.
99 if ($settings{'BEHINDROUTER'} ne '') {
100 print FILE "BEHINDROUTER=$settings{'BEHINDROUTER'}\n";
101 }
102
103 # Close file after writing.
104 close(FILE);
105
106 # Update ddns config file.
107 &GenerateDDNSConfigFile();
108 }
109
110 #
111 # Toggle enable/disable field. Field is in second position
112 #
113 if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
114 # Open /var/ipfire/ddns/config for writing.
115 open(FILE, ">$datafile") or die "Unable to open $datafile.";
116
117 # Lock file for writing.
118 flock FILE, 2;
119
120 my @temp;
121 my $id = 0;
122
123 # Read file line by line.
124 foreach my $line (@current) {
125 # Remove newlines.
126 chomp($line);
127
128 if ($settings{'ID'} eq $id) {
129 # Splitt lines (splitting element is a single ",") and save values into temp array.
130 @temp = split(/\,/,$line);
131
132 # Check if we want to toggle ENABLED or WILDCARDS.
133 if ($settings{'ENABLED'} ne '') {
134 # Update ENABLED.
135 print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$settings{'ENABLED'}\n";
136 }
137 } else {
138 # Print unmodified line.
139 print FILE "$line\n";
140 }
141
142 # Increase $id.
143 $id++;
144 }
145 undef $settings{'ID'};
146
147 # Close file after writing.
148 close(FILE);
149
150 # Write out logging notice.
151 &General::log($Lang::tr{'ddns hostname modified'});
152
153 # Update ddns config file.
154 &GenerateDDNSConfigFile();
155 }
156
157 #
158 # Add new accounts, or edit existing ones.
159 #
160 if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::tr{'update'})) {
161 # Check if a hostname has been given.
162 if ($settings{'HOSTNAME'} eq '') {
163 $errormessage = $Lang::tr{'hostname not set'};
164 }
165
166 # Check if a valid domainname has been provided.
167 if (!&General::validdomainname($settings{'HOSTNAME'})) {
168 $errormessage = $Lang::tr{'invalid domain name'};
169 }
170
171 # Check if a username has been sent.
172 if ($settings{'LOGIN'} eq '') {
173 $errormessage = $Lang::tr{'username not set'};
174 }
175
176 # Check if a password has been typed in.
177 # freedns.afraid.org does not require this field.
178 if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
179 $errormessage = $Lang::tr{'password not set'};
180 }
181
182 # Go furter if there was no error.
183 if (!$errormessage) {
184 # Splitt hostname field into 2 parts for storrage.
185 my($hostname, $domain) = split(/\./, $settings{'HOSTNAME'}, 2);
186
187 # Handle enabled checkbox. When the checkbox is selected a "on" will be returned,
188 # if the checkbox is not checked nothing is returned in this case we set the value to "off".
189 if ($settings{'ENABLED'} ne 'on') {
190 $settings{'ENABLED'} = 'off';
191 }
192
193 # Handle adding new accounts.
194 if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
195 # Open /var/ipfire/ddns/config for writing.
196 open(FILE, ">>$datafile") or die "Unable to open $datafile.";
197
198 # Lock file for writing.
199 flock FILE, 2;
200
201 # Add account data to the file.
202 print FILE "$settings{'SERVICE'},$hostname,$domain,$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n";
203
204 # Close file after writing.
205 close(FILE);
206
207 # Write out notice to logfile.
208 &General::log($Lang::tr{'ddns hostname added'});
209
210 # Handle account edditing.
211 } elsif ($settings{'ACTION'} eq $Lang::tr{'update'}) {
212 # Open /var/ipfire/ddns/config for writing.
213 open(FILE, ">$datafile") or die "Unable to open $datafile.";
214
215 # Lock file for writing.
216 flock FILE, 2;
217
218 my $id = 0;
219
220 # Read file line by line.
221 foreach my $line (@current) {
222 if ($settings{'ID'} eq $id) {
223 print FILE "$settings{'SERVICE'},$hostname,$domain,$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n";
224 } else {
225 print FILE "$line";
226 }
227
228 # Increase $id.
229 $id++;
230 }
231
232 # Close file after writing.
233 close(FILE);
234
235 # Write out notice to logfile.
236 &General::log($Lang::tr{'ddns hostname modified'});
237 }
238 undef $settings{'ID'};
239
240 # Update ddns config file.
241 &GenerateDDNSConfigFile();
242 }
243 }
244
245 #
246 # Remove existing accounts.
247 #
248 if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
249 # Open /var/ipfire/ddns/config for writing.
250 open(FILE, ">$datafile") or die "Unable to open $datafile.";
251
252 # Lock file for writing.
253 flock FILE, 2;
254
255 my $id = 0;
256
257 # Read file line by line.
258 foreach my $line (@current) {
259 # Write back every line, except the one we want to drop
260 # (identified by the ID)
261 unless ($settings{'ID'} eq $id) {
262 print FILE "$line";
263 }
264
265 # Increase id.
266 $id++;
267 }
268 undef $settings{'ID'};
269
270 # Close file after writing.
271 close(FILE);
272
273 # Write out notice to logfile.
274 &General::log($Lang::tr{'ddns hostname removed'});
275
276 # Update ddns config file.
277 &GenerateDDNSConfigFile();
278 }
279
280 #
281 # Read items for editing.
282 #
283 if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
284 my $id = 0;
285 my @temp;
286
287 # Read file line by line.
288 foreach my $line (@current) {
289 if ($settings{'ID'} eq $id) {
290 # Remove newlines.
291 chomp($line);
292
293 # Splitt lines (splitting element is a single ",") and save values into temp array.
294 @temp = split(/\,/,$line);
295
296 $settings{'SERVICE'} = $temp[0];
297 $settings{'HOSTNAME'} = "$temp[1].$temp[2]";
298 $settings{'PROXY'} = $temp[3];
299 $settings{'WILDCARDS'} = $temp[4];
300 $settings{'LOGIN'} = $temp[5];
301 $settings{'PASSWORD'} = $temp[6];
302 $settings{'ENABLED'} = $temp[7];
303 }
304
305 # Increase $id.
306 $id++;
307 }
308
309 &GenerateDDNSConfigFile();
310 }
311
312 #
313 # Handle forced updates.
314 #
315 if ($settings{'ACTION'} eq $Lang::tr{'instant update'}) {
316 system(@ddnsprog) == 0 or die "@ddnsprog failed: $?\n";
317 }
318
319 #
320 # Set default values.
321 #
322 if (!$settings{'ACTION'}) {
323 $settings{'SERVICE'} = 'dyndns.org';
324 $settings{'ENABLED'} = 'on';
325 $settings{'ID'} = '';
326 }
327
328 &Header::openpage($Lang::tr{'dynamic dns'}, 1, '');
329 &Header::openbigbox('100%', 'left', '', $errormessage);
330
331 # Read file for general ddns settings.
332 &General::readhash($settingsfile, \%settings);
333
334 my %checked =();
335 $checked{'BEHINDROUTER'}{'RED_IP'} = '';
336 $checked{'BEHINDROUTER'}{'FETCH_IP'} = '';
337 $checked{'BEHINDROUTER'}{$settings{'BEHINDROUTER'}} = "checked='checked'";
338
339 $checked{'ENABLED'}{'on'} = '';
340 $checked{'ENABLED'}{'off'} = '';
341 $checked{'ENABLED'}{$settings{'ENABLED'}} = "checked='checked'";
342
343 # Show box for errormessages..
344 if ($errormessage) {
345 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
346 print "<font class='base'>$errormessage&nbsp;</font>";
347 &Header::closebox();
348 }
349
350 &Header::openbox('100%', 'left', $Lang::tr{'settings'});
351
352 ##
353 # Section for general ddns setup.
354 print <<END
355 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
356 <table width='100%'>
357 <tr>
358 <td class='base'>$Lang::tr{'dyn dns source choice'}</td>
359 </tr>
360 <tr>
361 <td class='base'><input type='radio' name='BEHINDROUTER' value='RED_IP' $checked{'BEHINDROUTER'}{'RED_IP'} />
362 $Lang::tr{'use ipfire red ip'}</td>
363 </tr>
364 <tr>
365 <td class='base'><input type='radio' name='BEHINDROUTER' value='FETCH_IP' $checked{'BEHINDROUTER'}{'FETCH_IP'} />
366 $Lang::tr{'fetch ip from'}</td>
367 </tr>
368 </table>
369 <br />
370 <hr />
371
372 <table width='100%'>
373 <tr>
374 <td align='right' valign='top' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
375 </tr>
376 </table>
377 </form>
378 END
379 ;
380
381 &Header::closebox();
382
383 ##
384 # Section to add or edit an existing entry.
385
386 # Default is add.
387 my $buttontext = $Lang::tr{'add'};
388
389 # Change buttontext and headline if we edit an account.
390 if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
391 # Rename button and print headline for updating.
392 $buttontext = $Lang::tr{'update'};
393 &Header::openbox('100%', 'left', $Lang::tr{'edit an existing host'});
394 } else {
395 # Otherwise use default button text and show headline for adding a new account.
396 &Header::openbox('100%', 'left', $Lang::tr{'add a host'});
397 }
398
399 print <<END
400 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
401 <input type='hidden' name='ID' value='$settings{'ID'}' />
402 <table width='100%'>
403 <tr>
404 <td width='25%' class='base'>$Lang::tr{'service'}:</td>
405 <td width='25%'>
406 END
407 ;
408 # Generate dropdown menu for service selection.
409 print"<select size='1' name='SERVICE'>\n";
410
411 my $selected;
412
413 # Loop to print the providerlist.
414 foreach my $provider (@providers) {
415 # Check if the current provider needs to be selected.
416 if ($provider eq $settings{'SERVICE'}) {
417 $selected = 'selected';
418 } else {
419 $selected = "";
420 }
421
422 # Print out the HTML option field.
423 print "<option value=\"$provider\" $selected>$provider</option>\n";
424 }
425
426 print"</select></td>\n";
427 print <<END
428 <td width='20%' class='base'>$Lang::tr{'hostname'}:</td>
429 <td width='30%'><input type='text' name='HOSTNAME' value='$settings{'HOSTNAME'}' /></td>
430 </tr>
431
432 <tr>
433 <td class='base'>$Lang::tr{'enabled'}</td>
434 <td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
435 <td class='base'>$Lang::tr{'username'}</td>
436 <td><input type='text' name='LOGIN' value='$settings{'LOGIN'}' /></td>
437 </tr>
438
439 <tr>
440 <td class='base'></td>
441 <td></td>
442 <td class='base'>$Lang::tr{'password'}</td>
443 <td><input type='password' name='PASSWORD' value='$settings{'PASSWORD'}' /></td>
444 </tr>
445 </table>
446 <br>
447 <hr>
448
449 <table width='100%'>
450 <tr>
451 <td width='30%' align='right' class='base'>
452 <input type='hidden' name='ACTION' value='$buttontext'>
453 <input type='submit' name='SUBMIT' value='$buttontext'></td>
454 </tr>
455 </table>
456 </form>
457 END
458 ;
459 &Header::closebox();
460
461 ##
462 # Third section, display all created ddns hosts.
463 # Re-open file to get changes.
464 open(FILE, $datafile) or die "Unable to open $datafile.";
465 @current = <FILE>;
466 close(FILE);
467
468 # Get IP address of the red interface.
469 my $ip = &General::GetDyndnsRedIP();
470 my $id = 0;
471 my $toggle_enabled;
472
473 if (@current) {
474 &Header::openbox('100%', 'left', $Lang::tr{'current hosts'});
475
476 print <<END;
477 <table width='100%' class='tbl'>
478 <tr>
479 <th width='30%' align='center' class='boldbase'><b>$Lang::tr{'service'}</b></th>
480 <th width='50%' align='center' class='boldbase'><b>$Lang::tr{'hostname'}</b></th>
481 <th width='20%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></th>
482 </tr>
483 END
484
485 foreach my $line (@current) {
486 # Remove newlines.
487 chomp(@current);
488 my @temp = split(/\,/,$line);
489
490 # Handle hostname details. Only connect the values with a dott if both are available.
491 my $hostname="";
492
493 if (($temp[1]) && ($temp[2])) {
494 $hostname="$temp[1].$temp[2]";
495 } else {
496 $hostname="$temp[1]";
497 }
498
499 # Generate value for enable/disable checkbox.
500 my $sync = '';
501 my $gif = '';
502 my $gdesc = '';
503
504 if ($temp[7] eq "on") {
505 $gif = 'on.gif';
506 $gdesc = $Lang::tr{'click to disable'};
507
508 # Check if the given hostname is a FQDN before doing a nslookup.
509 if (&General::validfqdn($hostname)) {
510 $sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "<font color='green'>": "<font color='red'>") ;
511 }
512
513 $toggle_enabled = 'off';
514 } else {
515 $sync = "<font color='blue'>";
516 $gif = 'off.gif';
517 $gdesc = $Lang::tr{'click to enable'};
518 $toggle_enabled = 'on';
519 }
520
521 # Background color.
522 my $col="";
523
524 if ($settings{'ID'} eq $id) {
525 $col="bgcolor='${Header::colouryellow}'";
526 } elsif (!($temp[0] ~~ @providers)) {
527 $col="bgcolor='#FF4D4D'";
528 } elsif ($id % 2) {
529 $col="bgcolor='$color{'color20'}'";
530 } else {
531 $col="bgcolor='$color{'color22'}'";
532 }
533
534 # The following HTML Code still is part of the loop.
535 print <<END;
536 <tr>
537 <td align='center' $col><a href='http://$temp[0]'>$temp[0]</a></td>
538 <td align='center' $col>$sync$temp[1].$sync$temp[2]</td>
539
540 <td align='center' $col><form method='post' action='$ENV{'SCRIPT_NAME'}'>
541 <input type='hidden' name='ID' value='$id'>
542 <input type='hidden' name='ENABLED' value='$toggle_enabled'>
543 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
544 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
545 </form></td>
546
547 <td align='center' $col><form method='post' action='$ENV{'SCRIPT_NAME'}'>
548 <input type='hidden' name='ID' value='$id'>
549 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
550 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
551 </form></td>
552
553 <td align='center' $col><form method='post' action='$ENV{'SCRIPT_NAME'}'>
554 <input type='hidden' name='ID' value='$id'>
555 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
556 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
557 </form></td>
558 </tr>
559 END
560 $id++;
561 }
562
563 print <<END;
564 </table>
565 <table width='100%'>
566 <tr>
567 <td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
568 <td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
569 <td class='base'>$Lang::tr{'click to disable'}</td>
570 <td>&nbsp;&nbsp;</td>
571 <td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
572 <td class='base'>$Lang::tr{'click to enable'}</td>
573 <td>&nbsp;&nbsp;</td>
574 <td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
575 <td class='base'>$Lang::tr{'edit'}</td>
576 <td>&nbsp;&nbsp;</td>
577 <td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
578 <td class='base'>$Lang::tr{'remove'}</td>
579 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
580 <td align='right' width='30%'><input type='submit' name='ACTION' value='$Lang::tr{'instant update'}' /></td>
581 </form>
582 </tr>
583 </table>
584 END
585
586 &Header::closebox();
587 }
588
589 &Header::closebigbox();
590 &Header::closepage();
591
592 # Function to generate the required configuration file for the DDNS tool.
593 sub GenerateDDNSConfigFile {
594 # Open datafile file
595 open(SETTINGS, "<$datafile") or die "Could not open $datafile.";
596
597 open(FILE, ">${General::swroot}/ddns/ddns.conf");
598
599 # Global configuration options.
600 print FILE "[config]\n";
601
602 # Check if we guess our IP address by an extranal server.
603 if ($settings{'BEHINDROUTER'} eq "FETCH_IP") {
604 print FILE "guess_external_ip = true\n";
605 } else {
606 print FILE "guess_external_ip = false\n";
607 }
608
609 # Use an upstream proxy and generate proxy url.
610 my %proxysettings;
611 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
612 if ($proxysettings{'UPSTREAM_PROXY'}) {
613 my $proxy_string = "http://";
614
615 if ($proxysettings{'UPSTREAM_USER'} && $proxysettings{'UPSTREAM_PASSWORD'}) {
616 $proxy_string .= "$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@";
617 }
618
619 $proxy_string .= $proxysettings{'UPSTREAM_PROXY'};
620
621 print FILE "proxy = $proxy_string\n";
622 }
623
624 print FILE "\n";
625
626 while (<SETTINGS>) {
627 my $line = $_;
628 chomp($line);
629
630 # Generate array based on the line content (seperator is a single or multiple space's)
631 my @settings = split(/,/, $line);
632 my ($provider, $hostname, $domain, $proxy, $wildcards, $username, $password, $enabled) = @settings;
633
634 # Skip entries if they are not (longer) supported.
635 next unless ($provider ~~ @providers);
636
637 # Skip disabled entries.
638 next unless ($enabled eq "on");
639
640 print FILE "[$hostname.$domain]\n";
641 print FILE "provider = $provider\n";
642
643 my $use_token = 0;
644
645 # Handle token based auth for various providers.
646 if ($provider ~~ ["dns.lightningwirelabs.com", "entrydns.net", "regfish.com"] && $username eq "token") {
647 $use_token = 1;
648
649 # Handle token auth for freedns.afraid.org and regfish.com.
650 } elsif ($provider ~~ ["freedns.afraid.org", "regfish.com"] && $password eq "") {
651 $use_token = 1;
652 $password = $username;
653
654 # Handle keys for nsupdate
655 } elsif (($provider eq "nsupdate") && $username && $password) {
656 print FILE "key = $username\n";
657 print FILE "secret = $password\n";
658
659 $username = "";
660 $password = "";
661
662 # Handle keys for nsupdate.info
663 } elsif (($provider eq "nsupdate.info") && $password) {
664 print FILE "secret = $password\n";
665
666 $username = "";
667 $password = "";
668 }
669
670 # Write auth details.
671 if ($use_token) {
672 print FILE "token = $password\n";
673 } elsif ($username && $password) {
674 print FILE "username = $username\n";
675 print FILE "password = $password\n";
676 }
677
678 # These providers need to be set to only use IPv4.
679 if ($provider ~~ ["freedns.afraid.org", "nsupdate.info", "opendns.com", "variomedia.de", "zoneedit.com"]) {
680 print FILE "proto = ipv4\n";
681 }
682
683 print FILE "\n";
684 }
685
686 close(SETTINGS);
687 close(FILE);
688 }
689
690 # Function which generates an array (@providers) which contains the supported providers.
691 sub GetProviders {
692 # Get supported providers.
693 open(PROVIDERS, "/usr/bin/ddns list-providers |");
694
695 # Create new array to store the providers.
696 my @providers = ();
697
698 while (<PROVIDERS>) {
699 my $provider = $_;
700
701 # Remove following newlines.
702 chomp($provider);
703
704 # Add provider to the array.
705 push(@providers, $provider);
706 }
707
708 close(PROVIDERS);
709
710 # Return our array.
711 return @providers;
712 }