1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-31 20:09:27 +02:00

Create getActiveVpnInterface(), update revision strings

This commit is contained in:
billz 2025-03-17 04:05:23 -07:00
parent 93395a8aa5
commit bd0e379d01

View File

@ -102,15 +102,15 @@ class Sysinfo
$revisions = array(
'0002' => 'Raspberry Pi Model B Rev 1.0',
'0003' => 'Raspberry Pi Model B Rev 1.0',
'0004' => 'Raspberry Pi Model B Rev 2.0 (256 MB)',
'0005' => 'Raspberry Pi Model B Rev 2.0 (256 MB)',
'0006' => 'Raspberry Pi Model B Rev 2.0 (256 MB)',
'0004' => 'Raspberry Pi Model B Rev 2.0',
'0005' => 'Raspberry Pi Model B Rev 2.0',
'0006' => 'Raspberry Pi Model B Rev 2.0',
'0007' => 'Raspberry Pi Model A',
'0008' => 'Raspberry Pi Model A',
'0009' => 'Raspberry Pi Model A',
'000d' => 'Raspberry Pi Model B Rev 2.0 (512 MB)',
'000e' => 'Raspberry Pi Model B Rev 2.0 (512 MB)',
'000f' => 'Raspberry Pi Model B Rev 2.0 (512 MB)',
'000d' => 'Raspberry Pi Model B Rev 2.0',
'000e' => 'Raspberry Pi Model B Rev 2.0',
'000f' => 'Raspberry Pi Model B Rev 2.0',
'0010' => 'Raspberry Pi Model B+',
'0013' => 'Raspberry Pi Model B+',
'0011' => 'Compute Module',
@ -128,9 +128,9 @@ class Sysinfo
'a220a0' => 'Compute Module 3',
'a020a0' => 'Compute Module 3',
'a02100' => 'Compute Module 3+',
'a03111' => 'Model 4B Revision 1.1 (1 GB)',
'b03111' => 'Model 4B Revision 1.1 (2 GB)',
'c03111' => 'Model 4B Revision 1.1 (4 GB)',
'a03111' => 'Raspberry Pi 4B Rev 1.1 (1 GB)',
'b03111' => 'Raspberry Pi 4B Rev 1.1 (2 GB)',
'c03111' => 'Raspberry Pi 4B Rev 1.1 (4 GB)',
'a03140' => 'Compute Module 4 (1 GB)',
'b03140' => 'Compute Module 4 (2 GB)',
'c03140' => 'Compute Module 4 (4 GB)',
@ -158,6 +158,8 @@ class Sysinfo
/**
* Determines if ad blocking is enabled and active
*
* @return bool $status
*/
public function adBlockStatus(): bool
{
@ -171,5 +173,30 @@ class Sysinfo
$status = $dnsmasq_state && $enabled ? true : false;
return $status;
}
/**
* Determines if a VPN interface is active
*
* @return string $interface
*/
public function getActiveVpnInterface(): ?string
{
$output = shell_exec('ip a 2>/dev/null');
if (!$output) {
return null;
}
$vpnInterfaces = ['wg0', 'tun0', 'tailscale0'];
// interface must have an 'UP' status and an IP address
foreach ($vpnInterfaces as $interface) {
if (strpos($output, "$interface:") !== false) {
if (preg_match("/\d+: $interface: .*<.*UP.*>/", $output) &&
preg_match("/inet\b.*$interface/", $output)) {
return $interface;
}
}
}
return null;
}
}