Merge remote-tracking branch 'ms/next-dns-ng' into next

This commit is contained in:
Arne Fitzenreiter
2020-01-13 21:42:49 +00:00
45 changed files with 1688 additions and 1117 deletions

976
html/cgi-bin/dns.cgi Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -124,7 +124,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'add'})
}
}
# Restart unbound
system('/usr/local/bin/unboundctrl restart >/dev/null');
system('/usr/local/bin/unboundctrl reload >/dev/null');
}
###
@@ -142,7 +142,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'remove'})
}
close(FILE);
# Restart unbound.
system('/usr/local/bin/unboundctrl restart >/dev/null');
system('/usr/local/bin/unboundctrl reload >/dev/null');
}
###
@@ -169,7 +169,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'toggle enable disable'})
}
close(FILE);
# Restart unbound.
system('/usr/local/bin/unboundctrl restart >/dev/null');
system('/usr/local/bin/unboundctrl reload >/dev/null');
}
###

View File

@@ -280,15 +280,9 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
# File declarations.
my $gatewayfile = "${General::swroot}/red/remote-ipaddress";
my $dns1file = "${General::swroot}/red/dns1";
my $dns2file = "${General::swroot}/red/dns2";
# Get gateway address.
my $gateway = &_get_address_from_file($gatewayfile);
# Get addresses from the used dns servers.
my $dns1 = &_get_address_from_file($dns1file);
my $dns2 = &_get_address_from_file($dns2file);
my $gateway = &General::grab_address_from_file($gatewayfile);
# Check if any input has been performed.
if ($input eq '') {
@@ -306,7 +300,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
}
# Check if the given input is one of the interface addresses or our gateway.
elsif ($input eq "$green" || $input eq "$blue" || $input eq "$orange" || $input eq "$red" || $input eq "$gateway" || $input eq "$dns1" || $input eq "$dns2") {
elsif ($input eq "$green" || $input eq "$blue" || $input eq "$orange" || $input eq "$red" || $input eq "$gateway") {
$errormessage = "$Lang::tr{'guardian blocking of this address is not allowed'}";
}
@@ -989,8 +983,6 @@ sub GenerateIgnoreFile() {
# File declarations.
my $public_address_file = "${General::swroot}/red/local-ipaddress";
my $gatewayfile = "${General::swroot}/red/remote-ipaddress";
my $dns1file = "${General::swroot}/red/dns1";
my $dns2file = "${General::swroot}/red/dns2";
# Write the obtained addresses to the ignore file.
print FILE "# IPFire local interfaces.\n";
@@ -1012,8 +1004,6 @@ sub GenerateIgnoreFile() {
print FILE "# Include the corresponding files to obtain the addresses.\n";
print FILE "Include_File = $public_address_file\n";
print FILE "Include_File = $gatewayfile\n";
print FILE "Include_File = $dns1file\n";
print FILE "Include_File = $dns2file\n";
# Add all user defined hosts and networks to the ignore file.
#
@@ -1045,33 +1035,3 @@ sub GenerateIgnoreFile() {
close(FILE);
}
# Private subfunction to obtain IP-addresses from given file names.
#
sub _get_address_from_file ($) {
my $file = shift;
# Check if the file exists.
if (-e $file) {
# Open the given file.
open(FILE, "$file") or die "Could not open $file.";
# Obtain the address from the first line of the file.
my $address = <FILE>;
# Close filehandle
close(FILE);
# Remove newlines.
chomp $address;
# Check if the grabbed address is valid.
if (&General::validip($address)) {
# Return the address.
return $address;
}
}
# Return nothing.
return;
}

View File

@@ -488,5 +488,5 @@ sub SortDataFile
#
sub BuildConfiguration {
system '/usr/local/bin/rebuildhosts';
system '/usr/local/bin/unboundctrl restart &>/dev/null';
system '/usr/local/bin/unboundctrl reload &>/dev/null';
}

View File

@@ -200,25 +200,6 @@ END
END
}
my $dns_servers;
if ( -e "${General::swroot}/red/dns" ) {
open (TMP, "<${General::swroot}/red/dns");
$dns_servers = <TMP>;
chomp($dns_servers);
close TMP;
}
print <<END;
<tr>
<td>
<b><a href="netexternal.cgi">$Lang::tr{'dns servers'}</a>:</b>
</td>
<td style='text-align:center;'>
$dns_servers
</td>
<td></td>
</tr>
END
if (&General::RedIsWireless()) {
my $iface = $netsettings{"RED_DEV"} || "red0";

View File

@@ -80,108 +80,6 @@ if ( $querry[0] ne~ ""){
&Header::closebox();
}
## DNSSEC
my @nameservers = ();
foreach my $f ("${General::swroot}/red/dns1", "${General::swroot}/red/dns2") {
open(DNS, "<$f");
my $nameserver = <DNS>;
close(DNS);
chomp($nameserver);
if ($nameserver) {
push(@nameservers, $nameserver);
}
}
&Header::openbox('100%', 'center', $Lang::tr{'dnssec information'});
print <<END;
<table class="tbl" width='66%'>
<thead>
<tr>
<th align="center">
<strong>$Lang::tr{'nameserver'}</strong>
</th>
<th align="center">
<strong>$Lang::tr{'country'}</strong>
</th>
<th align="center">
<strong>$Lang::tr{'rdns'}</strong>
</th>
<th align="center">
<strong>$Lang::tr{'status'}</strong>
</th>
</tr>
</thead>
<tbody>
END
my $id = 0;
for my $nameserver (@nameservers) {
my $status = &check_dnssec($nameserver, "ping.ipfire.org");
my $colour = "";
my $bgcolour = "";
my $message = "";
# DNSSEC Not supported
if ($status == 0) {
$message = $Lang::tr{'dnssec not supported'};
$colour = "white";
$bgcolour = ${Header::colourred};
# DNSSEC Aware
} elsif ($status == 1) {
$message = $Lang::tr{'dnssec aware'};
$colour = "black";
$bgcolour = ${Header::colouryellow};
# DNSSEC Validating
} elsif ($status == 2) {
$message = $Lang::tr{'dnssec validating'};
$colour = "white";
$bgcolour = ${Header::colourgreen};
# Error
} else {
$colour = ${Header::colourred};
}
my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
# collect more information about name server (rDNS, GeoIP country code)
my $ccode = &GeoIP::lookup($nameserver);
my $flag_icon = &GeoIP::get_flag_icon($ccode);
my $iaddr = inet_aton($nameserver);
my $rdns = gethostbyaddr($iaddr, AF_INET);
if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; }
print <<END;
<tr bgcolor="$table_colour">
<td>
$nameserver
</td>
<td align="center">
<a href='country.cgi#$ccode'><img src="$flag_icon" border="0" alt="$ccode" title="$ccode" /></a>
</td>
<td align="center">
$rdns
</td>
<td bgcolor="$bgcolour" align="center">
<font color="$colour"><strong>$message</strong></font>
</td>
</tr>
END
}
print <<END;
</tbody>
</table>
END
&Header::closebox();
if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP"){
&Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
@@ -268,32 +166,3 @@ END
&Header::closebigbox();
&Header::closepage();
}
sub check_dnssec($$) {
my $nameserver = shift;
my $record = shift;
my @command = ("dig", "+dnssec", $record, "\@$nameserver");
my @output = qx(@command);
my $output = join("", @output);
my $status = 0;
if ($output =~ m/status: (\w+)/) {
$status = ($1 eq "NOERROR");
if (!$status) {
return -1;
}
}
my @flags = ();
if ($output =~ m/flags: (.*);/) {
@flags = split(/ /, $1);
}
my $aware = ($output =~ m/RRSIG/);
my $validating = ("ad" ~~ @flags);
return $aware + $validating;
}

View File

@@ -116,19 +116,6 @@ elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'})
$errormessage = $Lang::tr{'bad characters in script field'};
goto ERROR; }
if ($pppsettings{'DNS1'})
{
if (!(&General::validip($pppsettings{'DNS1'}))) {
$errormessage = $Lang::tr{'invalid primary dns'};
goto ERROR; }
}
if ($pppsettings{'DNS2'})
{
if (!(&General::validip($pppsettings{'DNS2'}))) {
$errormessage = $Lang::tr{'invalid secondary dns'};
goto ERROR; }
}
if ($pppsettings{'MAXRETRIES'} eq '') {
$errormessage = $Lang::tr{'max retries not set'};
goto ERROR; }
@@ -948,22 +935,6 @@ print <<END
<td width='25%'>$Lang::tr{'script name'}</td>
<td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
</tr>
<tr><td colspan='4' width='100%'><br></br></td></tr>
<tr>
<td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>DNS:</b></td>
</tr>
<tr>
<td colspan='4' width='100%'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td>
</tr>
<tr>
<td colspan='4' width='100%'><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td>
</tr>
<tr>
<td width='25%'>$Lang::tr{'primary dns'}</td>
<td width='25%'><input type='text' name='DNS1' value='$pppsettings{'DNS1'}'></td>
<td width='25%'>$Lang::tr{'secondary dns'}</td>
<td width='25%'><input type='text' name='DNS2' value='$pppsettings{'DNS2'}'></td>
</tr>
<tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr>
<tr>
<td width='25%'>$Lang::tr{'profile name'}&nbsp;<img src='/blob.gif' alt='*' /></td>