mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 11:13:24 +02:00
dhcp.cgi: Fix bug#10629 - Highlight fixed IP's in dynamic range in red
- This v2 patch has moved the extraHead variable into header.pl - This patch marks all IP's that are in the Fixed list but are also in the dynamic range that has been defined, in red. - Additional function created to check if an ip address is in a defined range. - Added an additional key item under the Fixed Leases table for Fixed IP in dynamic range - Added line to English Language file for this key item. - ./make lang run before commit. - Tested in vm testbed and confirmed that any ip address in the Fixed Leases table that is in the defined dynamic range is highlighted in red - This uses the css background-color appoach from the first patch in this set. - This patch only highlights those IP's that overlap in red but does nothing more. So a user can still create new ones if they want but they will all show up in red. - This patch flags up if people are doing things that they shouldn't be doing but allows them to continue doing so without changing anything if they don't want to and so will not break existing setups. Fixes: Bug#10629 Tested-by: Adolf Belka <adolf.belka@ipfire.org> Signed-off-by: Adolf Belka <adolf.belka@ipfire.org> Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org> Tested-by: Bernhard Bitsch <bbitsch@ipfire.org>
This commit is contained in:
committed by
Peter Müller
parent
de4dea96aa
commit
b52a84ddc7
@@ -54,6 +54,9 @@ $Header::extraHead = <<END
|
||||
}
|
||||
.cell-orange {
|
||||
background-color: orange;
|
||||
}
|
||||
.cell-red {
|
||||
background-color: red;
|
||||
}
|
||||
</style>
|
||||
END
|
||||
|
||||
@@ -307,6 +307,24 @@ sub ip_address_in_network($$) {
|
||||
return (($address_bin >= $network_bin) && ($address_bin <= $broadcast_bin));
|
||||
}
|
||||
|
||||
# Returns True if $ipaddress is within $ipstart and $ipend range.
|
||||
sub ip_address_in_range($$) {
|
||||
my $ipaddress = shift;
|
||||
my $ipstart = shift;
|
||||
my $ipend = shift;
|
||||
|
||||
my $ipaddress_bin = &ip2bin($ipaddress);
|
||||
return undef unless (defined $ipaddress_bin);
|
||||
|
||||
my $ipstart_bin = &ip2bin($ipstart);
|
||||
return undef unless (defined $ipstart_bin);
|
||||
|
||||
my $ipend_bin = &ip2bin($ipend);
|
||||
return undef unless (defined $ipend_bin);
|
||||
|
||||
return (($ipaddress_bin >= $ipstart_bin) && ($ipaddress_bin <= $ipend_bin));
|
||||
}
|
||||
|
||||
sub setup_upstream_proxy() {
|
||||
my %proxysettings = ();
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
@@ -666,6 +684,12 @@ sub testsuite() {
|
||||
$result = &ip_address_in_network("192.168.30.11", "0.0.0.0/8");
|
||||
assert('ip_address_in_network("192.168.30.11", "0.0.0.0/8")', !$result);
|
||||
|
||||
$result = &ip_address_in_range("192.168.30.11", "192.168.30.10", "192.168.30.20");
|
||||
assert('ip_address_in_range("192.168.30.11", "192.168.30.10", "192.168.30.20")', $result);
|
||||
|
||||
$result = &ip_address_in_range("192.168.30.21", "192.168.30.10", "192.168.30.20");
|
||||
assert('ip_address_in_range("192.168.30.21", "192.168.30.10", "192.168.30.20")', !$result);
|
||||
|
||||
print "Testsuite completed successfully!\n";
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user