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