From: Sebastien GISLAIN <sebastien.gislain@free.fr>
To: development@lists.ipfire.org
Subject: [PATCH 1/2] Add column with resolved hostname by IP address
Date: Sat, 11 Nov 2023 10:32:03 +0100 [thread overview]
Message-ID: <20231111093203.17013-1-sebastien.gislain@free.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]
From: Sebastien GISLAIN <sebastien.gislain(a)gmail.com>
---
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
reply other threads:[~2023-11-11 9:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231111093203.17013-1-sebastien.gislain@free.fr \
--to=sebastien.gislain@free.fr \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox