my @nameservers = &General::get_nameservers();
# Format dns servers declaration.
- my $line = "\"\[";
+ my $line = "";
# Check if the system has configured nameservers.
if (@nameservers) {
- # Loop through the array of nameservers.
- foreach my $server (@nameservers) {
- # Add the DNS server to the line.
- $line = "$line" . "$server";
-
- # Check if the current DNS server was the last in the array.
- if ($server ne $nameservers[-1]) {
- # Add "," for the next DNS server.
- $line = "$line" . "\,";
- }
- }
+ $line = join(",", @nameservers);
} else {
# The responsible DNS servers on red are directly used, and because we are not able
# to specify each single DNS server address here, we currently have to thread each
# address which is not part of the HOME_NET as possible DNS server.
- $line = "$line" . "!\$HOME_NET";
-
+ $line = "!\$HOME_NET";
}
- # Close the line...
- $line = "$line" . "\]\"";
-
# Open file to store the used DNS server addresses.
open(FILE, ">$dns_servers_file") or die "Could not open $dns_servers_file. $!\n";
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Print the generated DNS declaration to the file.
- print FILE "DNS_SERVERS:\t$line\n";
+ print FILE "DNS_SERVERS:\t\"[$line]\"\n";
# Close file handle.
close(FILE);