diff --git a/.github/workflows/work.yml b/.github/workflows/work.yml new file mode 100644 index 0000000..345021e --- /dev/null +++ b/.github/workflows/work.yml @@ -0,0 +1,15 @@ +on: + # Workflows check plugin Jeedom + push: + branches: + - beta + pull_request: + branches: + - beta + - master + +name : 'Full Workflows Plugin Jeedom' + +jobs: + plugin: + uses: jeedom/workflows/.github/workflows/plugin.yml@main diff --git a/.gitignore b/.gitignore index 612bfeb..acc3b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ test.php core/config/common.config.php plugins sftp-config.json -.vscode/settings.json -.vscode/sftp.json +.vscode diff --git a/3rdparty/networks_ping.class.php b/3rdparty/networks_ping.class.php index fe271fd..615f0ad 100644 --- a/3rdparty/networks_ping.class.php +++ b/3rdparty/networks_ping.class.php @@ -2,15 +2,16 @@ class networks_Ping { private $host; private $ttl; + private $timeout; private $port = 80; - private $data = 'Ping'; - public function __construct($host, $ttl = 255) { + public function __construct($host, $ttl = 255, $timeout = 3) { if (!isset($host)) { throw new \Exception("Error: Host name not supplied."); } $this->host = $host; $this->ttl = $ttl; + $this->timeout = $timeout; } public function setTtl($ttl) { @@ -53,16 +54,17 @@ private function pingExec($_mode = 'ip') { $latency = false; $ttl = escapeshellcmd($this->ttl); $host = escapeshellcmd($this->host); + $timeout = escapeshellcmd($this->timeout); if ($_mode == 'arp') { - $exec_string = 'sudo arping -c 10 -C 1 -w 500000 ' . $host . ' 2> /dev/null'; + $exec_string = "sudo arping -c 1 -C 1 -w 10 -W {$timeout} {$host} 2> /dev/null"; } else { - $exec_string = 'sudo ping -n -c 1 -t ' . $ttl . ' ' . $host . ' 2> /dev/null'; + $exec_string = "sudo ping -n -c 1 -t {$ttl} -W {$timeout} {$host} 2> /dev/null"; } exec($exec_string, $output, $return); $output = array_values(array_filter($output)); if (!empty($output[1])) { if (count($output) >= 5) { - $response = preg_match("/time(?:=|<)(?