diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm index 1687214..5c9ffb1 100644 --- a/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm @@ -483,19 +483,31 @@ sub get_mac_address { open(my $fh, '<', $file) or die "Could not open file '$file' $!"; my $mac_address = undef; my $lease_block; - while(my $line = <$fh>) { - if($line =~ /lease $ip {/ .. $line =~ /}/) { - $lease_block .= $line; - if($line =~ /}/) { - if($lease_block =~ /hardware ethernet (\S+);/) { - $mac_address = $1; - last; - } else { - $lease_block = ''; - } - } - } - } + my $in_lease; + while (my $line = <$fh>) { + # Start of the lease block for the requested IP + if ($line =~ /^lease\s+\Q$ip\E\s*{/) { + $in_lease = 1; + $lease_block = $line; + next; + } + # If inside the lease block, accumulate lines + if ($in_lease) { + $lease_block .= $line; + + # Look for hardware ethernet line to capture MAC + if ($line =~ /hardware ethernet\s+(\S+);/) { + $mac_address = $1; + } + + # End of lease block + if ($line =~ /^}/) { + $in_lease = 0; + last if $mac_address; # Exit if MAC found + $lease_block = ''; # Reset if MAC not found + } + } + } close $fh; return $mac_address; } @@ -699,6 +711,4 @@ sub Perform_Wake_Up($){ } -1; - - +1; \ No newline at end of file diff --git a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex index bf79f8e..4ff900e 100644 --- a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex +++ b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/dhcpd_en.lex @@ -56,7 +56,7 @@ 'dhcpd_REMOVE' => 'Remove', 'dhcpd_SAVE/RESTART' => 'Save/Restart', 'dhcpd_SAVE_TITLE' => 'After changing settings above, you must save and restart dhcpd.', - 'dhcpd_SCANNING_NETWORK_TITLE' => 'Scanning your network, the time needed depends of your subnet mask', + 'dhcpd_SCANNING_NETWORK_TITLE' => 'Scanning your network, the time needed depends on your subnet mask', 'dhcpd_SCAN_YOUR_NETWORK' => 'Scan your network', 'dhcpd_SCAN_YOUR_NETWORK_TITLE' => 'Scan your network to show active devices :', 'dhcpd_SECONDARY_DNS_ADDRESS' => 'Secondary DNS', @@ -88,4 +88,4 @@ contents of that lease are written to the end of the file. This means that it is entirely possible for there to be two or more declarations of the same lease in the lease file at the same time. In that case, the instance of that particular lease that - appears last in the file is the one that is in effect.', + appears last in the file is the one that is in effect.', \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/public/js/dhcpd.js b/root/usr/share/smanager/themes/default/public/js/dhcpd.js new file mode 100644 index 0000000..ead6aa8 --- /dev/null +++ b/root/usr/share/smanager/themes/default/public/js/dhcpd.js @@ -0,0 +1,28 @@ +function Wol_confirm(event,msg,current){ + const getMAC = /.*MAC\=(.*)\&name.*/; + var MAC = current.href.match(getMAC)[1]; + if (confirm(msg+": MAC: "+MAC)) + { return true;} + else {event.preventDefault();return false;} +} + +function Winpop_confirm(event,msg,current){ + const getIP = /.*ip\=(.*)/; + var IP = ": IP: "+current.href.match(getIP)[1]; + msg = msg.replace("$",IP); + var retVal = prompt(msg); + if (retVal) { + //Write it away in a hidden field + $hidden = document.getElementById("hiddenMsg"); + $hidden.value = retVal; + return true; + } else {event.preventDefault();return false;} +} + +function Remove_lease_confirm(event,msg,current){ + const getIP = /.*ip\=(.*)/; + var IP = current.href.match(getIP)[1]; + if (confirm(msg+" IP: "+IP)) + { return true;} + else {event.preventDefault();return false;} +} \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep b/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep index 0151aab..828f581 100644 --- a/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep +++ b/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep @@ -20,8 +20,6 @@ %} elsif ($dhcp_data->{success}) {
- %= $c->l($dhcp_data->{success});
@@ -29,7 +27,6 @@ %} elsif ($dhcp_data->{error}) {%= $c->l($dhcp_data->{error}); @@ -38,7 +35,6 @@ %} elsif ($dhcp_data->{error}) {
%= $c->l($dhcp_data->{error}); @@ -56,17 +52,9 @@
- %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases" - + %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', id=>"scanLeases" | - %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork" - + %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', id=>"scanNetwork" |
- %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases" - - + %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', id=>"scanLeases" | %= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4' | @@ -77,37 +72,4 @@
- %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1" - - + %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', id=>"scanNetwork1" |