From 192aa0b79102e9fc29d7162d913b04bdda955b2e Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 23 Jun 2020 09:58:16 +0300 Subject: Add support for Unix sockets in service list --- libs/services.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libs/services.php') diff --git a/libs/services.php b/libs/services.php index 61411e4..a3f9e94 100644 --- a/libs/services.php +++ b/libs/services.php @@ -5,7 +5,7 @@ $Config = new Config(); $datas = array(); -$available_protocols = array('tcp', 'udp'); +$available_protocols = array('tcp', 'udp', 'unix'); $show_port = $Config->get('services:show_port'); @@ -18,10 +18,16 @@ if (count($Config->get('services:list')) > 0) $name = $service['name']; $protocol = isset($service['protocol']) && in_array($service['protocol'], $available_protocols) ? $service['protocol'] : 'tcp'; - if (Misc::scanPort($host, $port, $protocol)) - $status = 1; - else - $status = 0; + $socketProtocols = array('tcp', 'udp', 'unix'); + if (in_array($protocol, $socketProtocols)) { + if (Misc::socketAvailable($host, $port, $protocol)) + $status = 1; + else + $status = 0; + } + else { + $status = Misc::systemdServiceActive($host) ? 1 : 0; + } $datas[] = array( 'port' => $show_port === true ? $port : '', -- cgit v1.3