1 |
diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm |
diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm |
2 |
--- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2023-12-19 09:44:56.678590486 +0000 |
--- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2023-12-19 09:44:56.678590486 +0000 |
3 |
+++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-21 16:53:00.000000000 +0000 |
+++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-23 10:14:00.000000000 +0000 |
4 |
@@ -140,12 +140,12 @@ |
@@ -140,12 +140,12 @@ |
5 |
my $c = shift; |
my $c = shift; |
6 |
my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE"); |
my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE"); |
31 |
return ; |
return ; |
32 |
} |
} |
33 |
|
|
34 |
@@ -352,17 +352,17 @@ |
@@ -350,19 +350,19 @@ |
35 |
|
# delete it |
36 |
|
# If deletion not ok return message |
37 |
# else return "ok" |
# else return "ok" |
38 |
my $ret = delete_lease($c); |
- my $ret = delete_lease($c); |
39 |
|
+ my $ret = delete_one_lease($c); |
40 |
if ($ret == 'ok') { |
if ($ret == 'ok') { |
41 |
- dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS"; |
- dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS"; |
42 |
+ $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS"; |
+ $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS"; |
71 |
return "ok"; |
return "ok"; |
72 |
} |
} |
73 |
|
|
74 |
@@ -391,6 +391,167 @@ |
@@ -391,6 +391,171 @@ |
75 |
return @leases; |
return @leases; |
76 |
} |
} |
77 |
|
|
96 |
+ ###Pull CGI object from parameters array |
+ ###Pull CGI object from parameters array |
97 |
+ my $c = shift; |
+ my $c = shift; |
98 |
+ |
+ |
99 |
|
+#my $fred = 1/0; |
100 |
|
+ |
101 |
+ ###Pull entry to delete |
+ ###Pull entry to delete |
102 |
+ my $ip = $c->param('host'); |
+ my $ip = $c->param('ip'); |
103 |
+ my $name = $c->param('name'); |
+ my $name = $c->param('name'); |
104 |
+ my $name_in_file = '/var/lib/dhcpd/dhcpd.leases' ; |
+ my $name_in_file = '/var/lib/dhcpd/dhcpd.leases' ; |
105 |
+ my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp' ; |
+ my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp' ; |
190 |
+ my ($ip) = trim(@_); |
+ my ($ip) = trim(@_); |
191 |
+ # Ping the IP to ensure it's in the ARP table |
+ # Ping the IP to ensure it's in the ARP table |
192 |
+ my $ping_result = `ping -c 1 -W 1 $ip`; |
+ my $ping_result = `ping -c 1 -W 1 $ip`; |
193 |
+ if($ping_result =~ /1 packets transmitted, 1 received/) { |
+ #return $ping_result; |
194 |
|
+ if($ping_result =~ m/1 packets transmitted, 1 received/) { |
195 |
+ # Fetch the ARP table and find the line with the IP address |
+ # Fetch the ARP table and find the line with the IP address |
196 |
+ my $arp_result = `arp -an | grep "\($ip)"`; |
+ my $mac_result = `nmap -PR -sn $ip`; |
197 |
|
+ #return "*$arp_result *$ip*"; |
198 |
+ # If found, return the MAC address |
+ # If found, return the MAC address |
199 |
+ return $arp_result; |
+ #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { |
200 |
+ if ($arp_result =~ /.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { |
+ if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) { |
201 |
+ return $1; |
+ return $1; |
202 |
+ } else { return "not in arp table"} |
+ } else { return "mac not in nmap result";} |
203 |
+ } else { return "no ping"} |
+ } else { return "no ping";} |
204 |
+ return undef; |
+ return undef; |
205 |
+} |
+} |
206 |
+ |
+ |
230 |
+ if (!$mac){ |
+ if (!$mac){ |
231 |
+ $mac = get_mac_address_by_ping($ip); |
+ $mac = get_mac_address_by_ping($ip); |
232 |
+ } |
+ } |
233 |
+ if (!$mac) {$mac = "unknown";} |
+# if (!$mac) {$mac = "unknown";} |
234 |
+ my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address |
+ my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address |
235 |
+ push @extracted_output, \%pair; |
+ push @extracted_output, \%pair; |
236 |
+ } |
+ } |
243 |
#========================================================================= |
#========================================================================= |
244 |
# Procedure qui charge le dhcpd.conf |
# Procedure qui charge le dhcpd.conf |
245 |
# retourne un tableau contenant les informations |
# retourne un tableau contenant les informations |
246 |
@@ -536,4 +697,4 @@ |
@@ -536,4 +701,4 @@ |
247 |
|
|
248 |
1; |
1; |
249 |
|
|
437 |
+1; |
+1; |
438 |
diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep |
diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep |
439 |
--- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2023-12-19 09:44:56.681590497 +0000 |
--- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2023-12-19 09:44:56.681590497 +0000 |
440 |
+++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2024-01-20 11:29:00.000000000 +0000 |
+++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2024-01-23 10:12:00.000000000 +0000 |
441 |
@@ -1,17 +1,17 @@ |
@@ -1,17 +1,17 @@ |
442 |
<div id='dhcpd-leases'> |
<div id='dhcpd-leases'> |
443 |
<table><tr><td> |
<table><tr><td> |
485 |
% foreach my $ip (@$leases) { |
% foreach my $ip (@$leases) { |
486 |
<tr> |
<tr> |
487 |
%= t td => (class => 'sme-border') => $ip->{ip} |
%= t td => (class => 'sme-border') => $ip->{ip} |
488 |
@@ -66,9 +68,12 @@ |
@@ -65,9 +67,7 @@ |
489 |
|
%= t td => (class => 'sme-border') => $ip->{end} |
490 |
%= t td => (class => 'sme-border') => $ip->{mac} |
%= t td => (class => 'sme-border') => $ip->{mac} |
491 |
<td class = 'sme-border'> |
<td class = 'sme-border'> |
492 |
<a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a> |
- <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a> |
493 |
- </td><td class = 'sme-border'> |
- </td><td class = 'sme-border'> |
494 |
+ </td> |
- <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a> |
495 |
+ <!-- |
+ <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>&name=<%= $ip->{name}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a> |
|
+ <td class = 'sme-border'> |
|
|
<a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a> |
|
496 |
</td> |
</td> |
|
+ --> |
|
497 |
</tr> |
</tr> |
498 |
%} |
%} |
499 |
</tbody> |
@@ -102,7 +102,7 @@ |
500 |
@@ -110,4 +115,4 @@ |
function Remove_lease_confirm(event,msg,current){ |
501 |
|
const getIP = /.*ip\=(.*)/; |
502 |
|
var IP = current.href.match(getIP)[1]; |
503 |
|
- if (prompt(msg+" IP: "+IP)) |
504 |
|
+ if (confirm(msg+" IP: "+IP)) |
505 |
|
{ return true;} |
506 |
|
else {event.preventDefault();return false;} |
507 |
|
} |
508 |
|
@@ -110,4 +110,4 @@ |
509 |
%end |
%end |
510 |
|
|
511 |
|
|