diff options
author | kesselb <mail@danielkesselberg.de> | 2021-06-03 12:20:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 12:20:37 +0300 |
commit | db8fb3d55b84b38a44430b212bb1b2b0ad0ec6f3 (patch) | |
tree | 7f2f170aa40260bd10857a318e24815740a26662 | |
parent | 530559b6688c53d67242f6de5c8248848c1c11d3 (diff) | |
parent | 397ae63e3c612e23228308108f64e9fb818f6c8a (diff) |
Merge pull request #300 from HouraisanNEET/patch-bsdv22.0.0beta3
Catch RuntimeException
-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]); |