From patchwork Wed Oct 21 11:48:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3593 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4CGS032tdRz3wgF for ; Wed, 21 Oct 2020 10:48:35 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4CGS024v6Vz18G; Wed, 21 Oct 2020 10:48:34 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4CGS024Gn2z2xxj; Wed, 21 Oct 2020 10:48:34 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4CGS0131VPz2xbW for ; Wed, 21 Oct 2020 10:48:33 +0000 (UTC) Received: from mirfac.uberspace.de (mirfac.uberspace.de [185.26.156.40]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4CGS011pB4z11D for ; Wed, 21 Oct 2020 10:48:33 +0000 (UTC) Received: (qmail 23768 invoked from network); 21 Oct 2020 10:48:33 -0000 Received: from localhost (HELO suhail.uberspace.de) (127.0.0.1) by mirfac.uberspace.de with SMTP; 21 Oct 2020 10:48:33 -0000 Received: (qmail 22622 invoked from network); 21 Oct 2020 10:48:30 -0000 Received: from localhost (HELO Leo-Laptop.local) (127.0.0.1) by suhail.uberspace.de with SMTP; 21 Oct 2020 10:48:30 -0000 Date: Wen, 21 Oct 2020 12:48:33 +0100 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH 2/2] Improve DHCP dynamic leases list usability. Active and expired leases are now grouped and the list is divided by a horizontal line. Sorting and creating static leases remains unchanged. Message-ID: <2d983761-437b-4b08-9638-06f57f560fb5@Leo-Laptop.local> X-Mailer: TortoiseGit MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1603277313; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g+Vcsu9GCrVKO9MH5TbgW7H702WUTVI1DdAdP3eYElg=; b=llCnxRb7VGE1Y1abDX+/8A5NCFwo4+dlgXYpDQByf82rEbZxPkabtT2OnXEO6QeDOeBr1S 16iUOWtV342Jryf8WXVePDDjQU9jw5WnrNzjrx52k3CfNGznllDLwKmdgnHfjOHpuwMcdV DudWhzSKjKJ8ymqadk5j8HdwBCH0PvdBQNjFcsQu378t/62/YFMhouxiKf9UJkOTWjS6ii R7MlVPDd4fbU+EeSycOAffkdP0VvP96eubPO5yTKjmfYuCR3eYuCK3eedQ85F5+cDmw2A8 Vl6W+L6HGvPt8Vv2wTIF/nc3YBTNw6D/7Ol/X9N+zvkHRwMGgi6G7gfdwRYc4Q== ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1603277313; a=rsa-sha256; cv=none; b=ClB+yB5wGOouQ+ddhWCX4NnKdtixMuQNuem0qeBkhlRpJh7A8kJgqJTEMv9oL+gwPrybWg gOl3rlh29NM3ixZJ3ipA4B8iiyNOBTveOqxmiOKSB19AiMAz7lcP1r9N0NDBPGEfqQtODe oWSlVQYAZY7inHqhczx33MmomNgZ4uD08aeecN6fqKWTDsEAIdA9eBvR4ENn5Lg3pfiro5 C9wnA5cBlYltsLpMTwy+dudGKO7kf+IIYedwcaMceDzxABGRNWl2FM0DEZ9lfY10SxJihN 3Z9527GwTtK3J1T5atfHxfXIp5HrKzuZZ2n9FLkjCJ5j43hLW2c/X0acFg/XsA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=softfail (mail01.ipfire.org: 185.26.156.40 is neither permitted nor denied by domain of hofmann@leo-andres.de) smtp.mailfrom=hofmann@leo-andres.de X-Rspamd-Queue-Id: 4CGS011pB4z11D X-Spamd-Result: default: False [-0.60 / 11.00]; ARC_NA(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[leo-andres.de]; IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.00), ip: 185.26.156.40(0.00)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_TLS_LAST(0.00)[]; BAYES_HAM(-3.00)[99.99%] Authentication-Results: mail01.ipfire.org; dkim=none; dmarc=none; spf=softfail (mail01.ipfire.org: 185.26.156.40 is neither permitted nor denied by domain of hofmann@leo-andres.de) smtp.mailfrom=hofmann@leo-andres.de X-Rspamd-Server: mail01.haj.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Leo-Andres Hofmann --- config/cfgroot/header.pl | 66 +++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index 6322cfebe..e2e6fd689 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -418,6 +418,8 @@ END $ip = $temp[1]; #All field are not necessarily read. Clear everything $endtime = 0; + $endtime_print = ""; + $expired = 0; $ether = ""; $hostname = ""; } @@ -425,6 +427,9 @@ END if ($line =~ /^\s*ends/) { $line =~ /(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/; $endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900); + ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime($endtime); + $endtime_print = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); + $expired = $endtime < time(); } if ($line =~ /^\s*hardware ethernet/) { @@ -434,12 +439,11 @@ END if ($line =~ /^\s*client-hostname/) { $hostname = "$temp[1] $temp[2] $temp[3]"; - $hostname =~ s/;//g; - $hostname =~ s/\"//g; + $hostname =~ s/\"|[;\s]+?$//g; # remove quotes, trim semicolon and white space } if ($line eq "}") { - @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname); + @record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname,'endtime_print',$endtime_print,'expired',$expired); $record = {}; # create a reference to empty hash %{$record} = @record; # populate that hash with @record $entries{$record->{'IPADDR'}} = $record; # add this to a hash of hashes @@ -449,37 +453,53 @@ END my $id = 0; my $col = ""; + my $divider_printed = 0; foreach my $key (sort leasesort keys %entries) { - print "
\n"; my $hostname = &cleanhtml($entries{$key}->{HOSTNAME},"y"); - + my $hostname_print = $hostname; + if($hostname_print eq "") { #print blank space if no hostname is found + $hostname_print = "   "; + } + + # separate active and expired leases with a horizontal line + if(($entries{$key}->{expired}) && ($divider_printed == 0)) { + $divider_printed = 1; + if ($id % 2) { + print "
\n"; + } else { + print "
\n"; + } + $id++; + } + + print "\n"; if ($id % 2) { - print ""; $col="bgcolor='$table1colour'"; } else { - print ""; $col="bgcolor='$table2colour'"; } - - print <{expired}) { + print <$entries{$key}->{IPADDR} +$entries{$key}->{ETHER} +$hostname_print +$entries{$key}->{endtime_print} +END +; + } else { + print <$entries{$key}->{IPADDR} $entries{$key}->{ETHER} - $hostname - +$hostname_print +$entries{$key}->{endtime_print} END ; - - ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime ($entries{$key}->{ENDTIME}); - $enddate = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); - - if ($entries{$key}->{ENDTIME} < time() ){ - print "$enddate"; - } else { - print "$enddate"; } + print < - + + END ; $id++; @@ -498,11 +518,13 @@ sub leasesort { if ($qs eq 'IPADDR') { @a = split(/\./,$entries{$a}->{$qs}); @b = split(/\./,$entries{$b}->{$qs}); + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || # always sort by expiration first ($b[0]<=>$a[0]) || ($b[1]<=>$a[1]) || ($b[2]<=>$a[2]) || ($b[3]<=>$a[3]); } else { + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || $entries{$b}->{$qs} cmp $entries{$a}->{$qs}; } } @@ -512,11 +534,13 @@ sub leasesort { if ($qs eq 'IPADDR') { @a = split(/\./,$entries{$a}->{$qs}); @b = split(/\./,$entries{$b}->{$qs}); + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || ($a[0]<=>$b[0]) || ($a[1]<=>$b[1]) || ($a[2]<=>$b[2]) || ($a[3]<=>$b[3]); } else { + $entries{$a}->{'expired'} <=> $entries{$b}->{'expired'} || $entries{$a}->{$qs} cmp $entries{$b}->{$qs}; } }