Hello Sebastien,
Thank you very much for submitting this patch. However, I do have some concerns about this being merged.
If you only have a couple of leases, everything is fine, but there are people who have hundreds of DHCP clients on their network, and it has been reported before that this page is loading extremely slow. Adding a DNS request to this will probably make loading the page many times slower than it already is.
And to consider the performance hit, I do not quite know what the benefit is of showing this. Should we not rather parse the DHCP leases file and show the hostname that the client has submitted? That would show the same result, but it would be a lot faster.
-Michael
On 9 Nov 2023, at 21:36, Sebastien GISLAIN <sebastien.gislain@free.fr> wrote:
---
html/cgi-bin/dhcp.cgi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi
index f45703f0b..aabf565d7 100755
--- a/html/cgi-bin/dhcp.cgi
+++ b/html/cgi-bin/dhcp.cgi
@@ -21,6 +21,7 @@
use strict;
use experimental 'smartmatch';
+use IO::Socket;
# enable only the following on debugging purpose
#use warnings;
@@ -1009,6 +1010,7 @@ print <<END
<tr>
<th width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FETHER'><b>$Lang::tr{'mac address'}</b></a></th>
<th width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FIPADDR'><b>$Lang::tr{'ip address'}</b></a></th>
+ <th width='20%' align='center'><b>$Lang::tr{'hostname'}</b></a></th>
<th width='15%' align='center'><b>$Lang::tr{'remark'}</b></th>
<th width='15%' class='boldbase' align='center'><b>next-server</b></th>
<th width='15%' class='boldbase' align='center'><b>filename</b></th>
@@ -1106,9 +1108,14 @@ foreach my $line (@current2) {
$TAG4 = "class='red'" if ($dhcpsettings{'KEY2'} ne $key);
}
+ # resolved name (if exists)
+ my $iaddr = inet_aton($temp[1]);
+ my $rname = gethostbyaddr($iaddr, AF_INET);
+ if (!$rname || $rname eq "") { $rname = $Lang::tr{'lookup failed'}; }
print <<END
<td align='center' $col>$TAG2$temp[0]$TAG3</td>
<td align='center' $TAG4 $col>$TAG0$temp[1]$TAG1</td>
+<td align='center' $col>$rname </td>
<td align='center' $col>$temp[6] </td>
<td align='center' $col>$temp[3] </td>
<td align='center' $col>$temp[4] </td>
--
2.39.2