]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/dns.cgi
dns.cgi: Move grab_address_from_file function to general-functions.pl
[ipfire-2.x.git] / html / cgi-bin / dns.cgi
index 1279c69ba31fce8e103dd7c8aa10e7dccc6baeb2..450d5c4840d74334c5d1800fcbb985d9f6f85770 100755 (executable)
@@ -216,6 +216,9 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L
 
                # Write the changed hash back to the config file.
                &General::writehasharray($servers_file, \%dns_servers);
+
+               # Call function to handle unbound restart, etc.
+               &_handle_unbound_and_more();
        }
 
 ## Remove entry from DNS servers list.
@@ -235,6 +238,9 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L
        # Write the changed hash to the config file.
        &General::writehasharray($servers_file, \%dns_servers);
 
+       # Call function to handle unbound restart, etc.
+       &_handle_unbound_and_more();
+
 ## Handle request to check the servers.
 #
 } elsif ($cgiparams{'SERVERS'} eq $Lang::tr{'dns check servers'}) {
@@ -474,7 +480,7 @@ END
                # Loop through the array which stores the files.
                foreach my $file (@ISP_nameserver_files) {
                        # Grab the address of the nameserver.
-                       my $address = &grab_address_from_file($file);
+                       my $address = &General::grab_address_from_file($file);
 
                        # Check if we got an address.
                        if ($address) {
@@ -809,37 +815,6 @@ sub red_is_active () {
        }
 }
 
-# Tiny function to grab an IP-address of a given file.
-sub grab_address_from_file($) {
-       my ($file) = @_;
-
-       my $address;
-
-       # Check if the given file exists.
-       if(-f $file) {
-               # Open the file for reading.
-               open(FILE, $file) or die "Could not read from $file. $!\n";
-
-               # Read the address from the file.
-               $address = <FILE>;
-
-               # Close filehandle.
-               close(FILE);
-
-               # Remove newlines.
-               chomp($address);
-
-               # Check if the obtained address is valid.
-               if (&General::validip($address)) {
-                       # Return the address.
-                       return $address;
-               }
-       }
-
-       # Return nothing.
-       return;
-}
-
 # Function to check a given nameserver against propper work.
 sub check_nameserver($$$$) {
        my ($nameserver, $record, $proto, $tls_hostname) = @_;