From 737ad2e7008043caf84c785eaffe125d8f4b4e4e Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 23 Apr 2022 14:57:53 +0200 Subject: [PATCH] Management: fix ports in use check --- plugins/dynamix/ManagementAccess.page | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/dynamix/ManagementAccess.page b/plugins/dynamix/ManagementAccess.page index 637c44ac7..732086b59 100644 --- a/plugins/dynamix/ManagementAccess.page +++ b/plugins/dynamix/ManagementAccess.page @@ -38,9 +38,6 @@ function find_tasks() { sort($tasks); return $tasks; } -function plain($ip) { - return str_replace(['[',']'],'',$ip); -} $tasks = find_tasks(); $ethX = 'eth0'; $addr = ipaddr($ethX); @@ -85,13 +82,15 @@ $upgradelabel = _('Upgrade Cert'); $portsInUse = []; exec("lsof -Pni|awk '/LISTEN/ && \$9!~/127.0.0.1/ && \$9!~/\\[::1\\]/{print \$9}'|sort -u", $output); -$bind = $var['BIND_MGT']=='yes'; +$bind = false; //= $var['BIND_MGT']=='yes'; - not used in 6.10 $list = ['*',$addr]; foreach ($output as $line) { - [$ip, $port] = my_explode(':', $line); - if (!in_array($port,$portsInUse) && (!$bind || in_array(plain($ip),$list))) $portsInUse[] = $port; + [$ip, $port] = my_explode($line[0]=='[' ? ']:' : ':',$line); + if ($ip[0]=='[') $ip = substr($ip,1); // ipv6 address + if (!in_array($port,$portsInUse) && (!$bind || in_array($ip,$list))) $portsInUse[] = $port; } +sort($portsInUse,SORT_NUMERIC); ?>