diff --git a/net/zerotier/Makefile b/net/zerotier/Makefile
index 1aa41e2be..5ff20188d 100644
--- a/net/zerotier/Makefile
+++ b/net/zerotier/Makefile
@@ -1,5 +1,5 @@
PLUGIN_NAME= zerotier
-PLUGIN_VERSION= 1.2.0
+PLUGIN_VERSION= 1.3.0
PLUGIN_COMMENT= Virtual Networks That Just Work
PLUGIN_DEPENDS= zerotier
PLUGIN_MAINTAINER= dharrigan@gmail.com
diff --git a/net/zerotier/src/etc/inc/plugins.inc.d/zerotier.inc b/net/zerotier/src/etc/inc/plugins.inc.d/zerotier.inc
index e0804a84c..3f2cd08d1 100644
--- a/net/zerotier/src/etc/inc/plugins.inc.d/zerotier.inc
+++ b/net/zerotier/src/etc/inc/plugins.inc.d/zerotier.inc
@@ -29,8 +29,13 @@
function zerotier_enabled()
{
- $zerotier = new \OPNsense\Zerotier\Zerotier();
- return (string)$zerotier->enabled == '1';
+ $mdlZerotier = new \OPNsense\Zerotier\Zerotier();
+ return isEnabled($mdlZerotier);
+}
+
+function isEnabled($node)
+{
+ return $node->enabled->__toString() == "1";
}
function zerotier_services()
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/ZerotierController.php b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/NetworkController.php
similarity index 58%
rename from net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/ZerotierController.php
rename to net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/NetworkController.php
index 26624e80f..bc8de1402 100644
--- a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/ZerotierController.php
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/NetworkController.php
@@ -29,43 +29,21 @@
namespace OPNsense\Zerotier\Api;
+require_once 'plugins.inc.d/zerotier.inc';
+
use \OPNsense\Base\ApiMutableModelControllerBase;
use \OPNsense\Base\UIModelGrid;
use \OPNsense\Core\Backend;
use \OPNsense\Core\Config;
use \OPNsense\Zerotier\Zerotier;
-class ZerotierController extends ApiMutableModelControllerBase
+class NetworkController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'Zerotier';
static protected $internalModelClass = '\OPNsense\Zerotier\Zerotier';
- public function getAction()
- {
- $result = array();
- if ($this->request->isGet()) {
- $mdlZerotier = $this->getModel();
- $result['zerotier'] = $mdlZerotier->getNodes();
- }
- return $result;
- }
-
- public function setAction()
- {
- $result = array("result" => "failed");
- if($this->request->isPost()) {
- $mdlZerotier = $this->getModel();
- $mdlZerotier->setNodes($this->request->getPost("zerotier"));
- $mdlZerotier->serializeToConfig();
- Config::getInstance()->save();
- $enabled = $this->isEnabled($mdlZerotier);
- $result["result"] = $this->toggleZerotierService($enabled);
- }
- return $result;
- }
-
- public function searchNetworkAction()
+ public function searchAction()
{
$this->sessionClose();
$mdlZerotier = $this->getModel();
@@ -76,7 +54,7 @@ class ZerotierController extends ApiMutableModelControllerBase
);
}
- public function getNetworkAction($uuid = null)
+ public function getAction($uuid = null)
{
$mdlZerotier = $this->getModel();
if ($uuid != null) {
@@ -91,30 +69,52 @@ class ZerotierController extends ApiMutableModelControllerBase
return array();
}
- public function setNetworkAction()
+ public function infoAction($uuid = null)
+ {
+ $mdlZerotier = $this->getModel();
+ if ($uuid != null) {
+ $network = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
+ if ($network != null) {
+ $networkId = $network->networkId->__toString();
+ return array
+ (
+ "title" => gettext("Information on network") . " " . $networkId,
+ "message" => $this->listZerotierNetwork($networkId)
+ );
+ }
+ }
+ return array();
+ }
+
+ public function setAction($uuid = null)
{
$result = array("result" => "failed");
- if ($this->request->isPost()) {
- $mdlZerotier = new Zerotier();
- $mdlZerotier->setNodes($this->request->getPost("network"));
- $validationMessages = $mdlZerotier->performValidation();
- foreach ($validationMessages as $field => $msg) {
- if (!array_key_exists("validation", $result)) {
- $result["validations"] = array();
+ if ($this->request->isPost() && $this->request->hasPost("network")) {
+ if($uuid != null) {
+ $mdlZerotier = $this->getModel();
+ $network = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
+ if($network != null) {
+ $network->setNodes($this->request->getPost("network"));
+ $validationMessages = $mdlZerotier->performValidation();
+ foreach ($validationMessages as $field => $msg) {
+ if (!array_key_exists("validation", $result)) {
+ $result["validations"] = array();
+ }
+ $result["validation"]["network.".$msg->getField()] = $msg->getMessage();
+ }
+ if ($validationMessages->count() == 0) {
+ unset($result["validations"]);
+ $mdlZerotier->serializeToConfig();
+ Config::getInstance()->save();
+ $result["result"] = "saved";
+ }
}
- $result["validation"]["network.".$msg->getField()] = $msg->getMessage();
- }
- if ($validationMessages->count() == 0) {
- unset($result["validations"]);
- $mdlZerotier->serializeToConfig();
- Config::getInstance()->save();
- $result["result"] = "saved";
}
}
return $result;
}
- public function addNetworkAction()
+ public function addAction()
{
$result = array("result" => "failed");
if ($this->request->isPost() && $this->request->hasPost("network")) {
@@ -137,20 +137,20 @@ class ZerotierController extends ApiMutableModelControllerBase
return $result;
}
- public function delNetworkAction($uuid = null)
+ public function delAction($uuid = null)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
- $mdlZerotier = $this->getModel();
if ($uuid != null) {
- if (!$this->isEnabled($mdlZerotier)) {
+ $mdlZerotier = $this->getModel();
+ if (!isEnabled($mdlZerotier)) {
$result["result"] = "service_not_enabled";
return $result;
}
- $node = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
- if ($this->isEnabled($node)) {
+ $network = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
+ if (isEnabled($network)) {
# Ensure we remove the interface before deleting the network
- $this->toggleZerotierNetwork($node->networkId, 0);
+ $this->toggleZerotierNetwork($network->networkId, 0);
}
if ($mdlZerotier->networks->network->del($uuid)) {
$mdlZerotier->serializeToConfig();
@@ -164,24 +164,24 @@ class ZerotierController extends ApiMutableModelControllerBase
return $result;
}
- public function toggleNetworkAction($uuid)
+ public function toggleAction($uuid = null)
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
- $mdlZerotier = $this->getModel();
if ($uuid != null) {
- if (!$this->isEnabled($mdlZerotier)) {
+ $mdlZerotier = $this->getModel();
+ if (!isEnabled($mdlZerotier)) {
$result["result"] = "service_not_enabled";
return $result;
}
- $node = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
- if ($node != null) {
- $networkId = $node->networkId;
- if ($this->isEnabled($node)) {
- $node->enabled = "0";
+ $network = $mdlZerotier->getNodeByReference('networks.network.' . $uuid);
+ if ($network != null) {
+ $networkId = $network->networkId;
+ if (isEnabled($network)) {
+ $network->enabled = "0";
$result['result'] = $this->toggleZerotierNetwork($networkId, 0);
} else {
- $node->enabled = "1";
+ $network->enabled = "1";
$result['result'] = $this->toggleZerotierNetwork($networkId, 1);
}
$mdlZerotier->serializeToConfig();
@@ -192,49 +192,22 @@ class ZerotierController extends ApiMutableModelControllerBase
return $result;
}
- public function statusAction()
- {
- $mdlZerotier = $this->getModel();
- $enabled = (string)$mdlZerotier->enabled == '1';
-
- $backend = new Backend();
- $response = $backend->configdRun('zerotier status');
-
- if (strpos($response, "not running") > 0) {
- if ($enabled) {
- $status = "stopped";
- } else {
- $status = "disabled";
- }
- } elseif (strpos($response, "is running") > 0) {
- $status = "running";
- } elseif (!$enabled) {
- $status = "disabled";
- } else {
- $status = "unknown";
- }
-
- return array("result" => $status);
- }
-
private function toggleZerotierNetwork($networkId, $enabled)
{
- $backend = new Backend();
$action = $enabled ? 'join' : 'leave';
- return trim($backend->configdRun("zerotier $action $networkId"));
+ return trim((new Backend())->configdRun("zerotier $action $networkId"));
}
- private function toggleZerotierService($enabled)
+ private function listZerotierNetwork($networkId)
{
- $backend = new Backend();
- $backend->configdRun("template reload OPNsense/zerotier");
- $action = $enabled ? "start" : "stop";
- return trim($backend->configdRun("zerotier $action"));
- }
-
- private function isEnabled($node)
- {
- return $node->enabled->__toString() == "1";
+ $zerotierNetworks = trim((new Backend())->configdRun("zerotier listnetworks"));
+ $zerotierNetworks = explode("200 listnetworks", $zerotierNetworks);
+ foreach($zerotierNetworks as $zerotierNetwork) {
+ if(strpos($zerotierNetwork, $networkId) !== false) {
+ return $zerotierNetwork;
+ }
+ }
+ return gettext("Unable to obtain Zerotier information for network") . " " . $networkId . "! " . gettext("Is the network enabled?");
}
}
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/SettingsController.php b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/SettingsController.php
new file mode 100644
index 000000000..6432d9ac5
--- /dev/null
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/Api/SettingsController.php
@@ -0,0 +1,102 @@
+request->isGet()) {
+ $mdlZerotier = $this->getModel();
+ $result = array("zerotier" => $mdlZerotier->getNodes());
+ }
+ return $result;
+ }
+
+ public function setAction()
+ {
+ $result = array("result" => "failed");
+ if($this->request->isPost() && $this->request->hasPost("zerotier")) {
+ $mdlZerotier = $this->getModel();
+ $mdlZerotier->setNodes($this->request->getPost("zerotier"));
+ $mdlZerotier->serializeToConfig();
+ Config::getInstance()->save();
+ $enabled = isEnabled($mdlZerotier);
+ $result["result"] = $this->toggleZerotierService($enabled);
+ }
+ return $result;
+ }
+
+ public function statusAction()
+ {
+ $mdlZerotier = $this->getModel();
+ $enabled = isEnabled($mdlZerotier);
+
+ $response = trim((new Backend())->configdRun('zerotier status'));
+
+ if (strpos($response, "not running") > 0) {
+ if (isEnabled($mdlZerotier)) {
+ $status = "stopped";
+ } else {
+ $status = "disabled";
+ }
+ } elseif (strpos($response, "is running") > 0) {
+ $status = "running";
+ } elseif (!$enabled) {
+ $status = "disabled";
+ } else {
+ $status = "unknown";
+ }
+
+ return array("result" => $status);
+ }
+
+ private function toggleZerotierService($enabled)
+ {
+ $backend = new Backend();
+ $backend->configdRun("template reload OPNsense/zerotier");
+ $action = $enabled ? "start" : "stop";
+ return trim($backend->configdRun("zerotier $action"));
+ }
+
+}
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/IndexController.php b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/IndexController.php
index 1e4eac172..8579ea595 100644
--- a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/IndexController.php
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/IndexController.php
@@ -33,9 +33,9 @@ class IndexController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
- $this->view->title = "VPN: Zerotier";
+ $this->view->title = gettext("VPN : Zerotier : Settings");
$this->view->pick('OPNsense/Zerotier/index');
- $this->view->globalForm = $this->getForm("global");
+ $this->view->settingsForm = $this->getForm("settings");
$this->view->dialogNetworkForm = $this->getForm("dialogNetwork");
}
}
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/OverviewController.php b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/OverviewController.php
new file mode 100644
index 000000000..6eab68659
--- /dev/null
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/OverviewController.php
@@ -0,0 +1,70 @@
+view->title = gettext("VPN : Zerotier : Overview");
+ $this->view->pick('OPNsense/Zerotier/overview');
+ $this->view->information = $this->information();
+ $this->view->networks = $this->listNetworks();
+ $this->view->peers = $this->listPeers();
+ }
+
+ private function information()
+ {
+ return $this->invokeConfigdRun("info_json");
+ }
+
+ private function listNetworks()
+ {
+ return $this->invokeConfigdRun("listnetworks_json");
+ }
+
+ private function listPeers()
+ {
+ return $this->invokeConfigdRun("listpeers_json");
+ }
+
+ private function invokeConfigdRun($action)
+ {
+ if(!zerotier_enabled()) {
+ return (object)[];
+ }
+ $result = json_decode(trim((new Backend())->configdRun("zerotier $action")), true);
+ return $result !== null ? $result : (object)[];
+ }
+}
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/dialogNetwork.xml b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/dialogNetwork.xml
index 7f153b64b..c8789ac0d 100644
--- a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/dialogNetwork.xml
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/dialogNetwork.xml
@@ -7,8 +7,8 @@
network.description
- Description
+ Local Description
text
- Description to help identify this network
+ Local Description to help identify this network
diff --git a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/global.xml b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/settings.xml
similarity index 54%
rename from net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/global.xml
rename to net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/settings.xml
index 3ab096cc8..7c569b293 100644
--- a/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/global.xml
+++ b/net/zerotier/src/opnsense/mvc/app/controllers/OPNsense/Zerotier/forms/settings.xml
@@ -5,12 +5,17 @@
checkbox
This will activate the Zerotier service
+
+ zerotier.apiAccessToken
+ API Access Token
+ text
+ Access Token used for the Zerotier API service
+
zerotier.localconf
local.conf settings
textbox
10
- Contains configuration options that apply to the local node
+ A JSON document containing configuration options that apply to the local node
-
diff --git a/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Menu/Menu.xml b/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Menu/Menu.xml
index 55c880fef..75af8d0db 100644
--- a/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Menu/Menu.xml
+++ b/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Menu/Menu.xml
@@ -1,5 +1,8 @@
-
+
+
+
+
diff --git a/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Zerotier.xml b/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Zerotier.xml
index a4487fa67..d081852fb 100644
--- a/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Zerotier.xml
+++ b/net/zerotier/src/opnsense/mvc/app/models/OPNsense/Zerotier/Zerotier.xml
@@ -3,12 +3,16 @@
Zerotier - Virtual Networks That Just Work.
- 1.2.0
+ 1.3.0
0
Y
+
+
+ N
+
N
diff --git a/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/index.volt b/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/index.volt
index c06f06806..44a4272de 100644
--- a/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/index.volt
+++ b/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/index.volt
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
$(document).ready(function() {
- var zerotierSettings = {'global': '/api/zerotier/zerotier/get'};
+ var zerotierSettings = {'settings': '/api/zerotier/settings/get'};
mapDataToFormUI(zerotierSettings).done(function(data) {
formatTokenizersUI();
@@ -40,28 +40,29 @@ POSSIBILITY OF SUCH DAMAGE.
$("#grid-networks").UIBootgrid(
{
- search: '/api/zerotier/zerotier/searchNetwork',
- get:'/api/zerotier/zerotier/getNetwork/',
- set:'/api/zerotier/zerotier/setNetwork/',
- add:'/api/zerotier/zerotier/addNetwork/',
- del:'/api/zerotier/zerotier/delNetwork/',
- toggle:'/api/zerotier/zerotier/toggleNetwork/'
+ search: '/api/zerotier/network/search',
+ get:'/api/zerotier/network/get/',
+ set:'/api/zerotier/network/set/',
+ add:'/api/zerotier/network/add/',
+ del:'/api/zerotier/network/del/',
+ info:'/api/zerotier/network/info/',
+ toggle:'/api/zerotier/network/toggle/'
}
);
- ajaxCall(url="/api/zerotier/zerotier/status", sendData={}, callback=function(data, status) {
+ ajaxGet(url="/api/zerotier/settings/status", sendData={}, callback=function(data, status) {
updateServiceStatusUI(data['result']);
toggleNetworksTab(data['result']);
});
- $("#btn_save_global").click(function() {
- $("#global_progress").addClass("fa fa-spinner fa-pulse");
- saveFormToEndpoint(url="/api/zerotier/zerotier/set", formid="global", callback_ok=function(data, status) {
- ajaxCall(url="/api/zerotier/zerotier/status", sendData={}, callback=function(data, status) {
+ $("#btn_save_settings").click(function() {
+ $("#settings_progress").addClass("fa fa-spinner fa-pulse");
+ saveFormToEndpoint(url="/api/zerotier/settings/set", formid="settings", callback_ok=function(data, status) {
+ ajaxGet(url="/api/zerotier/settings/status", sendData={}, callback=function(data, status) {
updateServiceStatusUI(data['result']);
toggleNetworksTab(data['result']);
});
- $("#global_progress").removeClass("fa fa-spinner fa-pulse");
+ $("#settings_progress").removeClass("fa fa-spinner fa-pulse");
});
});
@@ -83,14 +84,14 @@ POSSIBILITY OF SUCH DAMAGE.
-
+
- {{ partial("layout_partials/base_form", ['fields': globalForm, 'id': 'global', 'apply_btn_id': 'btn_save_global']) }}
+ {{ partial("layout_partials/base_form", ['fields': settingsForm, 'id': 'settings', 'apply_btn_id': 'btn_save_settings']) }}
@@ -98,8 +99,9 @@ POSSIBILITY OF SUCH DAMAGE.
{{ lang._('Enabled') }}
- {{ lang._('Network Id') }}
- {{ lang._('Description') }}
+ {{ lang._('Network Id') }}
+ {{ lang._('Local Description') }}
+ {{ lang._('Commands') }}
{{ lang._('ID') }}
diff --git a/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/overview.volt b/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/overview.volt
new file mode 100644
index 000000000..11691e251
--- /dev/null
+++ b/net/zerotier/src/opnsense/mvc/app/views/OPNsense/Zerotier/overview.volt
@@ -0,0 +1,284 @@
+{#
+
+OPNsense® is Copyright © 2014 – 2017 by Deciso B.V.
+Copyright (C) 2017 David Harrigan
+
+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.
+
+#}
+
+{% set networksFirstRow = true, peersFirstRow = true %}
+
+
+
+
+
+
+
+
+
+
+
+ {% for network in networks %}
+
+
+
+
+
+
+
+ {{ lang._("Network Id") }} : {{ network['nwid'] | e }} ({{ network['name'] | e }})
+ {% if networksFirstRow == true %}
+ {% set networksFirstRow = false %}
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+ {% for key, value in network %}
+ {% set value = value | default('null') %}
+
+ {{ key | e }}
+ {% if value is type('boolean') %}
+ {{ value == true ? 'true' : 'false' }}
+ {% elseif value is iterable %}
+
+
+ {% if key == "assignedAddresses" %}
+
+
+ {{ lang._("Addresses") }}
+
+
+ {% if value|length > 0 %}
+ {% for index in 0..value|length - 1 %}
+
+ {{ value[index] | e }}
+
+ {% endfor %}
+ {% else %}
+
+ {{ lang._("No addresses currently defined.") }}
+
+ {% endif %}
+
+ {% elseif key == "routes" %}
+
+
+ {{ lang._("target") }}
+ {{ lang._("via") }}
+ {{ lang._("metric") }}
+ {{ lang._("flags") }}
+
+
+
+ {% if value|length > 0 %}
+ {% for index in 0..value|length - 1 %}
+ {% set route = value[index] %}
+
+ {{ route["target"] | e }}
+ {{ route["via"] | e }}
+ {{ route["metric"] | e }}
+ {{ route["flags"] | e }}
+
+ {% endfor %}
+ {% else %}
+ {{ lang._("No routes currently defined.") }}
+ {% endif %}
+
+ {% endif %}
+
+
+ {% else %}
+ {{ value | e }}
+ {% endif %}
+
+ {% endfor %}
+
+
+
+
+ {% elsefor %}
+ {{ lang._("Unable to retrieve Zerotier network information. Is the service enabled, do you have enabled networks and is there internet connectivity?") }}
+ {% endfor %}
+
+
+
+
+
+
+
+
+ {% for peer in peers %}
+
+
+
+
+
+
+
+ {{ lang._("Peer") }} : {{ peer['address'] | e }} ({{ peer['role'] | e }})
+ {% if peersFirstRow == true %}
+ {% set peersFirstRow = false %}
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+ {% for key, value in peer %}
+ {% set value = value | default('null') %}
+
+ {{ key | e }}
+ {% if value is type('boolean') %}
+ {{ value == true ? 'true' : 'false' }}
+ {% elseif value is iterable %}
+
+
+ {% if key == "paths" %}
+
+
+ {{ lang._("active") }}
+ {{ lang._("address") }}
+ {{ lang._("expired") }}
+ {{ lang._("lastReceive") }}
+ {{ lang._("lastSend") }}
+ {{ lang._("linkQuality") }}
+ {{ lang._("preferred") }}
+ {{ lang._("trustedPathId") }}
+
+
+
+ {% if value|length > 0 %}
+ {% for index in 0..value|length - 1 %}
+ {% set path = value[index] %}
+
+ {{ path["active"] | e }}
+ {{ path["address"] | e }}
+ {{ path["expired"] ? 'true' : 'false' }}
+ {{ path["lastReceive"] | e }}
+ {{ path["lastSend"] | e }}
+ {{ path["linkQuality"] | e }}
+ {{ path["preferred"] | e }}
+ {{ path["trustedPathId"] | e }}
+
+ {% endfor %}
+ {% else %}
+
+ {{ lang._("No routes currently defined.") }}
+
+ {% endif %}
+
+ {% endif %}
+
+
+ {% else %}
+ {{ value | e }}
+ {% endif %}
+
+ {% endfor %}
+
+
+
+
+ {% elsefor %}
+ {{ lang._("Unable to retrieve Zerotier peer information. Is the service enabled and is there internet connectivity?") }}
+ {% endfor %}
+
+
+
+
+
diff --git a/net/zerotier/src/opnsense/service/conf/actions.d/actions_zerotier.conf b/net/zerotier/src/opnsense/service/conf/actions.d/actions_zerotier.conf
index 8dd1fd3c3..5df6767c1 100644
--- a/net/zerotier/src/opnsense/service/conf/actions.d/actions_zerotier.conf
+++ b/net/zerotier/src/opnsense/service/conf/actions.d/actions_zerotier.conf
@@ -33,3 +33,39 @@ command:/usr/local/bin/zerotier-cli
parameters: leave %s
type:script_output
message:Leaving Zerotier Network
+
+[info]
+command:/usr/local/bin/zerotier-cli info
+parameters:
+type:script_output
+message:Listing Zerotier Info
+
+[listnetworks]
+command:/usr/local/bin/zerotier-cli listnetworks
+parameters:
+type:script_output
+message:Listing Zerotier Networks
+
+[listpeers]
+command:/usr/local/bin/zerotier-cli listpeers
+parameters:
+type:script_output
+message:Listing Zerotier Peers
+
+[info_json]
+command:/usr/local/bin/zerotier-cli -j info
+parameters:
+type:script_output
+message:Listing Zerotier Info (as JSON)
+
+[listnetworks_json]
+command:/usr/local/bin/zerotier-cli -j listnetworks
+parameters:
+type:script_output
+message:Listing Zerotier Networks (as JSON)
+
+[listpeers_json]
+command:/usr/local/bin/zerotier-cli -j listpeers
+parameters:
+type:script_output
+message:Listing Zerotier Peers (as JSON)