diff options
author | HouraisanNEET <HouraisanNEET@users.noreply.github.com> | 2021-06-01 11:44:04 +0300 |
---|---|---|
committer | HouraisanNEET <HouraisanNEET@users.noreply.github.com> | 2021-06-01 11:47:28 +0300 |
commit | 397ae63e3c612e23228308108f64e9fb818f6c8a (patch) | |
tree | ad97ee5609d93157ba17db69ad2ba58cf5538569 | |
parent | e928e50bf8db6312c824faef75d2f0cf65b11511 (diff) |
Catch RuntimeException
Signed-off-by: HouraisanNEET <HouraisanNEET@users.noreply.github.com>
-rw-r--r-- | lib/OperatingSystems/FreeBSD.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/OperatingSystems/FreeBSD.php b/lib/OperatingSystems/FreeBSD.php index 6ef4cfb..1651e82 100644 --- a/lib/OperatingSystems/FreeBSD.php +++ b/lib/OperatingSystems/FreeBSD.php @@ -17,7 +17,7 @@ declare(strict_types=1); * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> + * along with this program. If not, see <https://www.gnu.org/licenses/> * */ @@ -150,13 +150,24 @@ class FreeBSD implements IOperatingSystem { public function getNetworkInterfaces(): array { $result = []; - $ifconfig = $this->executeCommand('/sbin/ifconfig -a'); + try { + $ifconfig = $this->executeCommand('/sbin/ifconfig -a'); + } catch (\RuntimeException $e) { + return $result; + } + preg_match_all("/^(?<=(?!\t)).*(?=:)/m", $ifconfig, $interfaces); foreach ($interfaces[0] as $interface) { $iface = []; $iface['interface'] = $interface; - $intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']); + + try { + $intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']); + } catch (\RuntimeException $e) { + continue; + } + preg_match_all("/(?<=inet ).\S*/m", $intface, $ipv4); preg_match_all("/(?<=inet6 )((.*(?=%))|(.\S*))/m", $intface, $ipv6); $iface['ipv4'] = implode(' ', $ipv4[0]); |