diff --git a/lib/OperatingSystems/FreeBSD.php b/lib/OperatingSystems/FreeBSD.php index 08e88a49..5ae3d6c8 100644 --- a/lib/OperatingSystems/FreeBSD.php +++ b/lib/OperatingSystems/FreeBSD.php @@ -122,6 +122,10 @@ public function getNetworkInfo(): array { if (count($gw[0]) > 0) { $result['gateway'] = implode(', ', array_map('trim', $gw[0])); } + $resolvConf = $this->readContent('/etc/resolv.conf'); + if (preg_match_all('/^\s*nameserver\s+(\S+)/m', $resolvConf, $matches)) { + $result['dns'] = implode(', ', array_unique($matches[1])); + } } catch (RuntimeException) { // okay } @@ -239,6 +243,17 @@ public function getThermalZones(): array { return []; } + /** + * @throws RuntimeException + */ + protected function readContent(string $filename): string { + $data = @file_get_contents($filename); + if ($data === false || $data === '') { + throw new RuntimeException('Unable to read: "' . $filename . '"'); + } + return trim($data); + } + /** * Execute a command with shell_exec. *