From 0100e6c993f089a5856b01cc7335283ed02658b9 Mon Sep 17 00:00:00 2001 From: Matt <125427297+ConstrictM@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:24:25 -0400 Subject: [PATCH] feat(freebsd): support dns lookup FreeBSD uses /etc/resolv.conf for DNS. The same logic used in Linux is the same for FreeBSD. Signed-off-by: Matt <125427297+ConstrictM@users.noreply.github.com> --- lib/OperatingSystems/FreeBSD.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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. *