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}) {
-

Operation Status Report - success

- %= $c->l($dhcp_data->{success});

@@ -29,7 +27,6 @@ %} elsif ($dhcp_data->{error}) {
-

Operation Status Report - error

%= $c->l($dhcp_data->{error}); @@ -38,7 +35,6 @@ %} elsif ($dhcp_data->{error}) {

-

Operation Status Report - warning

%= $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"
@@ -179,41 +167,5 @@ %}

- -%= javascript begin - if (document.getElementById("load")){document.getElementById("load").style.display="none";} - if (document.getElementById("loadingNetwork")){document.getElementById("loadingNetwork").style.display="none";} - - function showSpinnerLeases(){ - document.getElementById("scanLeases").style.display="none"; - document.getElementById("load").style.display="inline"; - } - - function showSpinnerNetwork(){ - document.getElementById("scanNetwork").style.display="none"; - document.getElementById("loadingNetwork").style.display="inline"; - } %end - -%= stylesheet begin -.spinnerButtonOverlay, -.spinnerButtonOverlay:hover, -.spinnerButtonOverlay:any-link , -.spinnerButtonOverlay:focus , -.spinnerButtonOverlay:active { - appearance: auto; - user-select: none; - align-items: flex-start; - cursor: default; - box-sizing: border-box; - background-color: #efefef; - color: black; - padding: 1px 6px; - border-width: 2px; - border-style: outset; - border-color: darkgrey; - border-image: initial; -} -%end -%end -1; +1; \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep index c9b44ae..294000c 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep @@ -1,11 +1,6 @@
@@ -77,37 +72,4 @@
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd' - %= javascript begin - 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;} - } - - %end - - - + \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep index b496ea0..a712f20 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep @@ -1,11 +1,6 @@
- %= 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'
@@ -37,27 +32,4 @@ %= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd' - - %= javascript begin - 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;} - } - - - %end - - - -%= javascript begin - document.getElementById("loadingNetwork1").style.display="none"; - - function showSpinnerNetwork1(){ - document.getElementById("scanNetwork1").style.display="none"; - document.getElementById("loadingNetwork1").style.display="inline"; - } - -%end + \ No newline at end of file diff --git a/smeserver-dhcpmanager.spec b/smeserver-dhcpmanager.spec index 2f992e7..311941b 100644 --- a/smeserver-dhcpmanager.spec +++ b/smeserver-dhcpmanager.spec @@ -1,6 +1,6 @@ %define name smeserver-dhcpmanager %define version 2.0.4 -%define release 23 +%define release 24 Summary: provide a dhcp panel in the server-manager for The SME Server Name: %{name} @@ -25,6 +25,10 @@ AutoReqProv: no Implementation of some feature arround dhcp clients like : wol, cleaning dhcpd.leases, Scan of your network etc// %changelog +* Sat Sep 27 2025 Brian Read 2.0.4-24.sme +- Fix crash in network scan [SME: 13180] +- Remove spinners as no longer necessary [SME: 13189] + * Wed Sep 24 2025 Brian Read 2.0.4-23.sme - Sort out archive on git stopping local archive update [SME: 13171]
- %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1" - - + %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', id=>"scanNetwork1"