security/netbird: UI refactor and improvements (#4831)

This commit is contained in:
Bethuel Mmbaga
2025-07-25 15:22:04 +02:00
committed by GitHub
parent b472a1d4e2
commit b9a3582c8b
32 changed files with 961 additions and 840 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
PLUGIN_NAME= netbird
PLUGIN_VERSION= 0.1
PLUGIN_VERSION= 0.2
PLUGIN_DEPENDS= netbird
PLUGIN_COMMENT= Peer-to-peer VPN that seamlessly connects your devices
PLUGIN_MAINTAINER= opn-netbird@sun-ri.se
PLUGIN_MAINTAINER= dev@netbird.io
PLUGIN_WWW= https://netbird.io
PLUGIN_DEVEL= yes
@@ -4,6 +4,7 @@
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,27 +31,40 @@
function netbird_enabled()
{
return !(new \OPNsense\Netbird\Netbird())->general->Enabled->isEmpty();
return !(new \OPNsense\Netbird\Settings())->general->enable->isEmpty();
}
function netbird_services()
{
$services = array();
$services = [];
if (!netbird_enabled()) {
return $services;
}
$services[] = array(
'description' => gettext('Netbird'),
'configd' => array(
'restart' => array('netbird restart'),
'start' => array('netbird start'),
'stop' => array('netbird stop'),
),
$services[] = [
'description' => gettext('NetBird'),
'configd' => [
'restart' => ['netbird restart'],
'start' => ['netbird start'],
'stop' => ['netbird stop'],
],
'name' => 'netbird',
'pidfile' => '/var/run/netbird.pid',
);
];
return $services;
}
function netbird_configure()
{
return [
'netbird_sync_config' => ['netbird_configure_do']
];
}
function netbird_configure_do($verbose = false)
{
service_log('Sync NetBird config...', $verbose);
(new \OPNsense\Netbird\Settings())->syncConfig();
service_log("done.\n", $verbose);
}
@@ -1,73 +0,0 @@
#!/usr/local/bin/php
<?php
/*
* Copyright (C) 2004 Scott Ullrich <sullrich@gmail.com>
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
require_once('config.inc');
require_once('util.inc');
require_once('interfaces.inc');
$model = new \OPNsense\Netbird\Netbird();
if ($model->general->Enabled->isEmpty()) {
exit(0);
}
if (!$model->general->CarpIf->isEqual('')) {
exit(0);
}
$target_vhid = $model->general->VHID;
$subsystem = !empty($argv[1]) ? $argv[1] : '';
$type = !empty($argv[2]) ? $argv[2] : '';
if ($type != 'MASTER' && $type != 'BACKUP') {
exit(1);
}
if (!strstr($subsystem, '@')) {
exit(1);
}
list ($vhid, $iface) = explode('@', $subsystem);
$friendly = convert_real_interface_to_friendly_interface_name($iface);
if ($carpif != $friendly || $vhid != $target_vhid) {
exit(0);
}
switch ($type) {
case 'MASTER':
shell_exec('/usr/local/bin/netbird up');
break;
case 'BACKUP':
shell_exec('/usr/local/bin/netbird down');
break;
}
@@ -0,0 +1,102 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\Netbird\Api;
use OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Core\Backend;
use OPNsense\Netbird\Authentication;
/**
* netbird authentication controller
* @package OPNsense\Netbird
*/
class AuthenticationController extends ApiMutableModelControllerBase
{
protected static $internalModelName = 'authentication';
protected static $internalModelClass = '\OPNsense\Netbird\Authentication';
public function getAction(): array
{
$mdl = new Authentication();
$managementUrl = $mdl->managementUrl->__toString();
$setupKey = $mdl->setupKey->__toString();
$defaultKey = '00000000-0000-0000-0000-000000000000';
if (!empty($setupKey) && $setupKey !== $defaultKey) {
$visiblePart = substr($setupKey, 0, 4);
$maskedKey = $visiblePart . str_repeat('*', max(4, strlen($setupKey) - 4));
}else{
$maskedKey = $defaultKey;
}
return [
'authentication' => [
'managementUrl' => $managementUrl,
'setupKey' => $maskedKey
]
];
}
public function upAction()
{
$backend = new Backend();
$mdl = new Authentication();
$status = json_decode($backend->configdRun("netbird status-json"), true);
$connected = $status['management']['connected'] ?? false;
if (json_last_error() === JSON_ERROR_NONE && $connected === true) {
$backend->configdRun("netbird down");
}
$managementUrl = $mdl->managementUrl->__toString();
$setupKey = $mdl->setupKey->__toString();
$result = $backend->configdpRun("netbird up-setup-key", array($managementUrl, $setupKey));
return ['result' => trim($result)];
}
public function downAction(): array
{
$backend = new Backend();
$status = json_decode($backend->configdRun("netbird status-json"), true);
$connected = $status['management']['connected'] ?? false;
if (json_last_error() === JSON_ERROR_NONE && $connected === true) {
$result = $backend->configdRun("netbird down");
return ['result' => trim($result)];
}
return ['result' => 'already disconnected or not running'];
}
}
@@ -1,9 +1,7 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,10 +29,6 @@
namespace OPNsense\Netbird\Api;
use OPNsense\Base\ApiMutableServiceControllerBase;
use OPNsense\Core\Backend;
use OPNsense\Core\Config;
use OPNsense\Netbird\Initial;
use OPNsense\Netbird\Netbird;
/**
* Class ServiceController
@@ -42,246 +36,8 @@ use OPNsense\Netbird\Netbird;
*/
class ServiceController extends ApiMutableServiceControllerBase
{
const NETBIRD_CONFIG_JSON = '/usr/local/etc/netbird/config.json';
protected static $internalServiceClass = '\OPNsense\Netbird\Netbird';
protected static $internalServiceEnabled = 'general.Enabled';
protected static $internalServiceClass = '\OPNsense\Netbird\Settings';
protected static $internalServiceEnabled = 'general.enable';
protected static $internalServiceTemplate = 'OPNsense/Netbird';
protected static $internalServiceName = 'netbird';
public function conStatusAction(): string
{
$backend = new Backend();
$bckResult = $backend->configdRun("netbird con-status");
if ($bckResult !== null) {
return nl2br(htmlspecialchars($bckResult));
}
return "Error retrieving connection status";
}
public function searchFilter($array, $value): bool
{
foreach ($array as $val) {
if (str_contains(strval($val), strtolower($value))) {
return true;
}
}
return false;
}
public function upDownStatusAction(): string
{
$backend = new Backend();
$bckResult = $backend->configdRun("netbird status");
if (!str_contains($bckResult, "is running")) {
return json_encode(array('updown' => "NOT RUNNING", 'status' => "Netbird is not running"));
}
$bckResult = $backend->configdRun("netbird short-con-status");
$txtStatus = nl2br(htmlspecialchars($bckResult));
$bckResult = $backend->configdRun("netbird con-status-json");
$status = json_decode($bckResult, true);
if (!$status['publicKey']) {
return json_encode(array('updown' => "DOWN", 'status' => $txtStatus));
}
return json_encode(array('updown' => "UP", 'status' => $txtStatus));
}
public function searchAction(): string
{
$request = $this->request;
$backend = new Backend();
$bckResult = $backend->configdRun("netbird status");
if (!str_contains($bckResult, "is running")) {
return json_encode(array('current' => 1, 'rowCount' => 0, 'total' => 0, 'rows' => array()));
}
$bckResult = $backend->configdRun("netbird con-status-json");
$status = json_decode($bckResult, true);
$itemsPerPage = $request->get('rowCount', 'int', -1);
$currentPage = $request->get('current', 'int', 1);
$sortBy = array('status');
$sortDescending = false;
$searchPhrase = strtolower($request->get('searchPhrase', 'string', ''));
if (!$status['peers']['details']) {
return json_encode(array('current' => 1, 'rowCount' => 0, 'total' => 0, 'rows' => array()));
}
$details = $status['peers']['details'];
$details = array_filter($details, function ($item) use ($searchPhrase) {
return $this->searchFilter($item, $searchPhrase);
});
$detailsFlat = array();
foreach ($details as $detail) {
$detailsFlat[] = $this->flattenOneLevel($detail);
}
if ($request->hasPost('sort') && is_array($request->get("sort")) && !empty($request->get("sort"))) {
$sortBy = array_keys($request->get("sort"));
if (!empty($sortBy) && $request->get("sort")[$sortBy[0]] == "desc") {
$sortDescending = true;
}
}
$sortValues = array();
foreach ($detailsFlat as $detail) {
$sortValues[] = $detail[$sortBy[0]];
}
array_multisort($sortValues, $sortDescending ? SORT_DESC : SORT_ASC, $detailsFlat);
$page = array_slice($detailsFlat, ($currentPage - 1) * $itemsPerPage, $itemsPerPage);
$page = $this->convertFieldsToDisplay($page);
$result = array('current' => $currentPage, 'rowCount' => count($page), 'total' => count($detailsFlat), 'rows' => $page);
return json_encode($result);
}
private function flattenOneLevel($array): array
{
$result = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
foreach ($value as $subkey => $subvalue) {
if ($key == "networks") {
$result[$key] = implode("<br />", $value);
} else {
$result[$key . "." . $subkey] = $subvalue;
}
}
} else {
$result[$key] = $value;
}
}
return $result;
}
public function setUpAction(): string
{
$backend = new Backend();
try {
return $backend->configdRun("netbird set-up");
} catch (\Exception $e) {
return "Error running netbird up" . "\n" . $e->getMessage();
}
}
public function initialUpAction(): string
{
$backend = new Backend();
$mdlInitial = new Initial();
$key = $mdlInitial->initial->setupkey->__toString();
$api = $mdlInitial->initial->mgmtservice->__toString();
$hostname = $mdlInitial->initial->hostname->__toString();
if ($hostname == "") {
$hostname = gethostname();
if (!$hostname) {
$hostname = "OPNsense";
} else {
if (str_contains($hostname, ".")) {
$hostname = explode(".", $hostname)[0];
}
}
$mdlInitial->initial->hostname = $hostname;
}
$mdlInitial->initial->setupkey = "00000000-0000-0000-0000-000000000000";
$mdlInitial->initial->initsure = 0;
$mdlInitial->serializeToConfig();
$cnf = Config::getInstance();
$cnf->save();
$bckresult = $backend->configdRun("netbird set-up-initial " . escapeshellarg($api) . " " . escapeshellarg($key) . " " . escapeshellarg($hostname));
return nl2br(htmlspecialchars($bckresult));
}
public function setDownAction(): string
{
$backend = new Backend();
try {
return $backend->configdRun("netbird set-down");
} catch (\Exception $e) {
return "Error running netbird down" . "\n" . $e->getMessage();
}
}
public function reloadAction()
{
$status = "failed";
if ($this->request->isPost()) {
try {
$mdlNetbird = new Netbird();
$backend = new Backend();
if (trim($backend->configdRun('template reload OPNsense/Netbird')) == "OK") {
$status = "ok";
}
$enabled = $mdlNetbird->general->Enabled->__toString() == 1;
$carpEnabled = $mdlNetbird->general->CarpIf->__toString() != '';
$disableClientRoutes = $mdlNetbird->general->DisableClientRoutes->__toString() == 1;
$disableServerRoutes = $mdlNetbird->general->DisableServerRoutes->__toString() == 1;
$disableDNS = $mdlNetbird->general->DisableDNS->__toString() == 1;
$rpEnabled = $mdlNetbird->general->QuantumEnabled->__toString() == 1;
$rpPermissive = $mdlNetbird->general->QuantumPermissive->__toString() == 1;
$wgPort = $mdlNetbird->general->WgPort->__toString();
$netbirdConfigJson = file_get_contents(self::NETBIRD_CONFIG_JSON);
$netbirdConfig = json_decode($netbirdConfigJson, true);
$netbirdConfig["DisableAutoConnect"] = $carpEnabled;
$netbirdConfig["DisableClientRoutes"] = $disableClientRoutes;
$netbirdConfig["DisableServerRoutes"] = $disableServerRoutes;
$netbirdConfig["DisableDNS"] = $disableDNS;
$netbirdConfig["RosenpassEnabled"] = $rpEnabled;
$netbirdConfig["RosenpassPermissive"] = $rpPermissive;
$netbirdConfig["WgPort"] = intval($wgPort);
$netbirdConfigJson = json_encode($netbirdConfig);
file_put_contents(self::NETBIRD_CONFIG_JSON, $netbirdConfigJson);
$action = $enabled ? "restart" : "stop";
$backend->configdRun("netbird $action");
} catch (\Exception $e) {
$status = "failed";
syslog(LOG_ERR, "netbird: failed to reload configuration: " . $e->getMessage());
}
}
return array("status" => $status);
}
/**
* @param array $page
* @return array
*/
public function convertFieldsToDisplay(array $page): array
{
for ($i = 0; $i < count($page); $i++) {
$page[$i]['latency'] = round($page[$i]['latency'] / 1000000, 2) . " ms";
$received = $page[$i]['transferReceived'];
$rcvUnit = "KiB";
$received /= 1024;
if ($received > 1024) {
$received /= 1024;
$rcvUnit = "MiB";
}
if ($received > 1024) {
$received /= 1024;
$rcvUnit = "GiB";
}
$sent = $page[$i]['transferSent'];
$sentUnit = "KiB";
$sent /= 1024;
if ($sent > 1024) {
$sent /= 1024;
$sentUnit = "MiB";
}
if ($sent > 1024) {
$sent /= 1024;
$sentUnit = "GiB";
}
$page[$i]['transferReceived'] = round($received, 2) . " " . $rcvUnit;
$page[$i]['transferSent'] = round($sent, 2) . " " . $sentUnit;
$page[$i]['lastStatusUpdate'] = date("Y-m-d H:i:s", strtotime($page[$i]['lastStatusUpdate']));
$page[$i]['lastWireguardHandshake'] = date("Y-m-d H:i:s", strtotime($page[$i]['lastWireguardHandshake']));
foreach ($page[$i] as $key => $value) {
if ($value == "true") {
$page[$i][$key] = 1;
} elseif ($value == "false") {
$page[$i][$key] = 0;
}
}
}
return $page;
}
}
@@ -1,9 +1,7 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,13 +29,35 @@
namespace OPNsense\Netbird\Api;
use OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Core\Backend;
/**
* Netbird settings controller
* netbird settings controller
* @package OPNsense\Netbird
*/
class SettingsController extends ApiMutableModelControllerBase
{
protected static $internalModelName = 'netbird';
protected static $internalModelClass = 'OPNsense\Netbird\Netbird';
protected static $internalModelName = 'settings';
protected static $internalModelClass = '\OPNsense\Netbird\Settings';
public function syncAction()
{
$backend = new Backend();
$result = $backend->configdRun("netbird sync-config");
if (stripos($result, 'done') === false) {
return [
'result' => 'failed to sync config: ' . $result,
];
}
$status = json_decode($backend->configdRun("netbird status-json"), true);
$connected = $status['management']['connected'] ?? false;
if (json_last_error() === JSON_ERROR_NONE && $connected === true) {
$backend->configdRun("netbird down");
$backend->configdRun("netbird up");
}
return ['result' => 'synced'];
}
}
@@ -4,6 +4,7 @@
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,13 +32,24 @@
namespace OPNsense\Netbird\Api;
use OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Core\Backend;
/**
* netbird settings controller
* Class StatusController
* @package OPNsense\Netbird
*/
class InitialController extends ApiMutableModelControllerBase
class StatusController extends ApiMutableModelControllerBase
{
protected static $internalModelName = 'netbird';
protected static $internalModelClass = 'OPNsense\Netbird\Initial';
protected static $internalModelClass = '\OPNsense\Netbird\Status';
protected static $internalModelName = 'Netbird';
public function statusAction(): array
{
$backend = new Backend();
$status = json_decode($backend->configdRun("netbird status-json"), true);
if (json_last_error() === JSON_ERROR_NONE && is_array($status)) {
return $status;
}
return [];
}
}
@@ -1,9 +1,7 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,13 +29,14 @@
namespace OPNsense\Netbird;
/**
* Class ConstatusController
* Class AuthenticationController
* @package OPNsense\Netbird
*/
class ConstatusController extends \OPNsense\Base\IndexController
class AuthenticationController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->pick('OPNsense/Netbird/constatus');
$this->view->authenticationForm = $this->getForm("authentication");
$this->view->pick('OPNsense/Netbird/authentication');
}
}
@@ -1,9 +1,7 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,15 +29,14 @@
namespace OPNsense\Netbird;
/**
* Class IndexController
* Class SettingsController
* @package OPNsense\Netbird
*/
class IndexController extends \OPNsense\Base\IndexController
class SettingsController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->generalForm = $this->getForm('general');
$this->view->initialUpForm = $this->getForm('initialup');
$this->view->pick('OPNsense/Netbird/index');
$this->view->settingsForm = $this->getForm("settings");
$this->view->pick('OPNsense/Netbird/settings');
}
}
@@ -0,0 +1,41 @@
<?php
/*
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\Netbird;
/**
* Class StatusController
* @package OPNsense\Netbird
*/
class StatusController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->pick('OPNsense/Netbird/status');
}
}
@@ -0,0 +1,14 @@
<form>
<field>
<id>authentication.managementUrl</id>
<label>Management URL</label>
<type>text</type>
<help>Base URL of the management service</help>
</field>
<field>
<id>authentication.setupKey</id>
<label>Setup Key</label>
<type>text</type>
<help>Set the authentication setup key</help>
</field>
</form>
@@ -1,56 +0,0 @@
<form>
<field>
<id>netbird.general.Enabled</id>
<label>Enabled</label>
<type>checkbox</type>
<help>Enable Netbird</help>
</field>
<field>
<id>netbird.general.WgPort</id>
<label>Wireguard Port</label>
<type>text</type>
</field>
<field>
<id>netbird.general.DisableDNS</id>
<label>Disable Netbird DNS lookups</label>
<type>checkbox</type>
<help>Disables DNS lookups for the Netbird network.</help>
</field>
<field>
<id>netbird.general.DisableServerRoutes</id>
<label>Disable Server Routes</label>
<type>checkbox</type>
<help>Prevents Netbird from being a routing peer for other Netbird peers.</help>
</field>
<field>
<id>netbird.general.DisableClientRoutes</id>
<label>Disable Client Routes</label>
<type>checkbox</type>
<help>Prevents Netbird from setting client routes to other remote peers.</help>
</field>
<field>
<id>netbird.general.QuantumEnabled</id>
<label>Rosenpass Enabled</label>
<type>checkbox</type>
<help>Enable Rosenpass</help>
</field>
<field>
<id>netbird.general.QuantumPermissive</id>
<label>Rosenpass Permissive Mode</label>
<type>checkbox</type>
<help>Enable Rosenpass permissive mode</help>
</field>
<field>
<id>netbird.general.CarpIf</id>
<label>CARP Interface</label>
<type>dropdown</type>
<help>If set to none Netbird up is executed and auto connect is enabled. If an interface is selected auto
connect is disabled. Please trigger a CARP event or execute Netbird up manually on the MASTER node.
</help>
</field>
<field>
<id>netbird.general.VHID</id>
<label>CARP VHID</label>
<type>text</type>
</field>
</form>
@@ -1,25 +0,0 @@
<form>
<field>
<id>netbird.initial.mgmtservice</id>
<label>Management Service URL</label>
<type>text</type>
</field>
<field>
<id>netbird.initial.setupkey</id>
<label>Setup Key</label>
<type>text</type>
</field>
<field>
<id>netbird.initial.hostname</id>
<label>Hostname</label>
<type>text</type>
<help>If empty the system hostname excluding the domain part will be used.</help>
</field>
<field>
<id>netbird.initial.initsure</id>
<label>I know what I'm doing</label>
<type>checkbox</type>
<help>If you enable this checkbox and submit the form your old netbird config will be deleted. In case of an error it will get restored. Should something go terribly wrong you can find the backups
in the configuration folder. (/usr/local/etc/netbird)</help>
</field>
</form>
@@ -0,0 +1,93 @@
<form>
<field>
<type>header</type>
<label>General</label>
</field>
<field>
<id>settings.general.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable NetBird</help>
</field>
<field>
<id>settings.general.wireguardPort</id>
<label>WireGuard Port</label>
<type>text</type>
<help>Wireguard interface listening port</help>
</field>
<field>
<type>header</type>
<label>Client Firewall</label>
</field>
<field>
<id>settings.firewall.allowConfig</id>
<label>Enable firewal</label>
<type>checkbox</type>
<help>Allow the client to filter traffic with its built-in firewall. If disabled, you must assign the NetBird interface and manage firewall rules via PFSense firewall management.
Additionally, NetBird routing and DNS may not function as intended.</help>
</field>
<field>
<id>settings.firewall.blockInboundConnection</id>
<label>Block Inbound Connection</label>
<type>checkbox</type>
<help>Block all inbound connections to the local machine from the WireGuard interface and any routed networks</help>
</field>
<field>
<type>header</type>
<label>SSH</label>
</field>
<field>
<id>settings.ssh.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Allows incoming SSH connections</help>
</field>
<field>
<type>header</type>
<label>DNS</label>
</field>
<field>
<id>settings.dns.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Allows the client to resolve and configure DNS on the host</help>
</field>
<field>
<type>header</type>
<label>Routing</label>
</field>
<field>
<id>settings.routing.accessLan</id>
<label>Access LAN</label>
<type>checkbox</type>
<help>Allow access to local networks (LAN) when using this peer as a routing peer or exit-node</help>
</field>
<field>
<id>settings.routing.acceptClientRoutes</id>
<label>Accept Client Routes</label>
<type>checkbox</type>
<help>Accept and process client routes received from the management</help>
</field>
<field>
<id>settings.routing.acceptServerRoutes</id>
<label>Accept Server Routes</label>
<type>checkbox</type>
<help>Enable this peer to act as a router for server routes received from the management</help>
</field>
<field>
<type>header</type>
<label>Post-Quantum</label>
</field>
<field>
<id>settings.postquantum.enableRosenpass</id>
<label>Enable Rosenpass</label>
<type>checkbox</type>
<help>Enable the Rosenpass to provide post-quantum secure connections (Experimental)</help>
</field>
<field>
<id>settings.postquantum.rosenpassPermissive</id>
<label>Rosenpass Permissive Mode</label>
<type>checkbox</type>
<help>Enable Rosenpass permissive mode</help>
</field>
</form>
@@ -1,6 +1,6 @@
<acl>
<page-vpn-netbird>
<name>VPN: Netbird</name>
<name>VPN: NetBird</name>
<patterns>
<pattern>ui/netbird/*</pattern>
<pattern>api/netbird/*</pattern>
@@ -1,9 +1,7 @@
<?php
/*
* Copyright (C) 2025 Ralph Moser, PJ Monitoring GmbH
* Copyright (C) 2025 squared GmbH
* Copyright (C) 2025 Christopher Linn, BackendMedia IT-Services GmbH
* Copyright (C) 2025 NetBird GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +30,6 @@ namespace OPNsense\Netbird;
use OPNsense\Base\BaseModel;
class Initial extends BaseModel
class Authentication extends BaseModel
{
}
@@ -0,0 +1,17 @@
<model>
<mount>//OPNsense/netbird/authentication</mount>
<description>NetBird authentication</description>
<version>1.0.0</version>
<items>
<managementUrl type="UrlField">
<Required>Y</Required>
<default>https://api.netbird.io:443</default>
<ValidationMessage>Please specify a valid URL</ValidationMessage>
</managementUrl>
<setupKey type="TextField">
<Required>Y</Required>
<Mask>/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i</Mask>
<ValidationMessage>Please specify a valid setup key</ValidationMessage>
</setupKey>
</items>
</model>
@@ -1,32 +0,0 @@
<model>
<mount>//OPNsense/netbird-initial</mount>
<description>
Netbird initial setup
</description>
<items>
<!-- container -->
<initial>
<!-- fields -->
<setupkey type="TextField">
<Mask>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i</Mask>
<ValidationMessage>Please specify a valid setup key.</ValidationMessage>
</setupkey>
<mgmtservice type="UrlField">
<Required>Y</Required>
<default>https://api.netbird.io:443</default>
</mgmtservice>
<hostname type="HostnameField">
<Required>N</Required>
<IpAllowed>N</IpAllowed>
<HostWildcardAllowed>N</HostWildcardAllowed>
<FqdnWildcardAllowed>N</FqdnWildcardAllowed>
<ZoneRootAllowed>N</ZoneRootAllowed>
<ValidationMessage>Please specify a valid hostname.</ValidationMessage>
</hostname>
<initsure type="BooleanField">
<default>0</default>
<Required>Y</Required>
</initsure>
</initial>
</items>
</model>
@@ -1,9 +1,10 @@
<menu>
<VPN>
<Netbird cssClass="fa fa-lock fa-fw">
<Settings order="40" url="/ui/netbird"/>
<ConStatus order="50" VisibleName="Status" url="/ui/netbird/constatus"/>
<LogFile VisibleName="Log File" order="60" url="/ui/diagnostics/log/core/netbird"/>
</Netbird>
<NetBird cssClass="fa fa-lock fa-fw">
<Authentication order="10" url="/ui/netbird/authentication"/>
<Settings order="20" url="/ui/netbird/settings"/>
<Status order="30" url="/ui/netbird/status"/>
<LogFile order="40" VisibleName="Log File" url="/ui/diagnostics/log/core/netbird"/>
</NetBird>
</VPN>
</menu>
@@ -1,46 +0,0 @@
<model>
<mount>//OPNsense/netbird</mount>
<version>0.8.1</version>
<description>Netbird plugin</description>
<items>
<!-- container -->
<general>
<!-- fields -->
<Enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</Enabled>
<WgPort type="IntegerField">
<Required>Y</Required>
<default>51820</default>
</WgPort>
<QuantumEnabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</QuantumEnabled>
<DisableDNS type="BooleanField">
<default>1</default>
<Required>Y</Required>
</DisableDNS>
<DisableServerRoutes type="BooleanField">
<default>1</default>
<Required>Y</Required>
</DisableServerRoutes>
<DisableClientRoutes type="BooleanField">
<default>1</default>
<Required>Y</Required>
</DisableClientRoutes>
<QuantumPermissive type="BooleanField">
<default>0</default>
<Required>Y</Required>
</QuantumPermissive>
<CarpIf type="InterfaceField">
<Required>N</Required>
</CarpIf>
<VHID type="IntegerField">
<Required>N</Required>
<default>1</default>
</VHID>
</general>
</items>
</model>

Some files were not shown because too many files have changed in this diff Show More