diff --git a/LICENSE b/LICENSE index 581d81334..f2a880a17 100644 --- a/LICENSE +++ b/LICENSE @@ -7,7 +7,6 @@ Copyright (c) 2023 Bernhard Frenking Copyright (c) 2023 Cannon Matthews Copyright (c) 2019 Cloudfence - Julio Camargo (JCC) Copyright (c) 2005-2006 Colin Smith -Copyright (c) 2020 D. Domig Copyright (c) 2021 Dan Lundqvist Copyright (c) 2021 David Berry Copyright (c) 2017-2018 David Harrigan @@ -50,7 +49,6 @@ Copyright (c) 2021 Nicola Pellegrini Copyright (c) 2022 Nikolaj Brinch Jørgensen Copyright (c) 2021 Nim G Copyright (c) 2023 Oliver Hartl -Copyright (c) 2022 Patrik Kernstock Copyright (c) 2022 Robbert Rijkse Copyright (c) 2023 sattamjh Copyright (c) 2004-2012 Scott Ullrich diff --git a/Mk/defaults.mk b/Mk/defaults.mk index 178fbe0a4..f1a2f19ad 100644 --- a/Mk/defaults.mk +++ b/Mk/defaults.mk @@ -45,7 +45,7 @@ VERSIONBIN= ${LOCALBASE}/sbin/opnsense-version _PLUGIN_ABI!= ${VERSIONBIN} -a PLUGIN_ABI?= ${_PLUGIN_ABI} .else -PLUGIN_ABI?= 23.7 +PLUGIN_ABI?= 24.1 .endif PHPBIN= ${LOCALBASE}/bin/php diff --git a/README.md b/README.md index 197bce5a2..0e8e71402 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ misc/theme-rebellion -- A suitably dark theme misc/theme-tukan -- The tukan theme - blue/white misc/theme-vicuna -- The vicuna theme - blue sapphire net/chrony -- Chrony time synchronisation -net/firewall -- Firewall API supplemental package (pending removal) net/freeradius -- RADIUS Authentication, Authorization and Accounting Server net/frr -- The FRRouting Protocol Suite net/ftp-proxy -- Control ftp-proxy processes @@ -64,10 +63,8 @@ net/siproxd -- Siproxd is a proxy daemon for the SIP protocol net/sslh -- sslh configuration front-end net/tayga -- Tayga NAT64 net/udpbroadcastrelay -- Control ubpbroadcastrelay processes -net/upnp -- Universal Plug and Play Service +net/upnp -- Universal Plug and Play (UPnP IGD & PCP/NAT-PMP) Service net/vnstat -- Network traffic monitor -net/wireguard -- WireGuard VPN service kernel implementation (pending removal) -net/wireguard-go -- WireGuard VPN service Go implementation (pending removal) net/wol -- Wake on LAN Service net/zerotier -- Virtual Networks That Just Work net-mgmt/collectd -- Collect system and application performance metrics periodically @@ -94,7 +91,6 @@ security/tinc -- Tinc VPN security/tor -- The Onion Router security/wazuh-agent -- Agent for the open source security platform Wazuh sysutils/apcupsd -- APCUPSD - APC UPS daemon -sysutils/api-backup -- EoL, core endpoint is /api/core/backup/download/this (pending removal) sysutils/apuled -- PC Engine APU LED control (development only) sysutils/dec-hw -- Deciso hardware specific information sysutils/dmidecode -- Display hardware information on the dashboard diff --git a/net/firewall/Makefile b/net/firewall/Makefile deleted file mode 100644 index 4b2543eaa..000000000 --- a/net/firewall/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PLUGIN_NAME= firewall -PLUGIN_VERSION= 1.5 -PLUGIN_COMMENT= Firewall API supplemental package -PLUGIN_OBSOLETE= yes -PLUGIN_MAINTAINER= ad@opnsense.org -PLUGIN_TIER= 2 - -.include "../../Mk/plugins.mk" diff --git a/net/firewall/pkg-descr b/net/firewall/pkg-descr deleted file mode 100644 index 30776806e..000000000 --- a/net/firewall/pkg-descr +++ /dev/null @@ -1,4 +0,0 @@ -This package extends the standard OPNsense firewall system with endpoints for machine to machine management tasks. -Gui components are initially only intended to ease testing and to explain current functionality. - -In the long term this might replace the default firewall in OPNsense. diff --git a/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc b/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc deleted file mode 100644 index 3c9aa2fce..000000000 --- a/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc +++ /dev/null @@ -1,48 +0,0 @@ -rules->rule->sortedBy(["sequence"]) as $key => $rule) { - $content = $rule->serialize(); - $content["#ref"] = "ui/firewall/filter#" . (string)$rule->getAttributes()['uuid']; - $fw->registerFilterRule($rule->getPriority(), $content); - } - - foreach ($mdlFilter->snatrules->rule->sortedBy(["sequence"]) as $key => $rule) { - $fw->registerSNatRule(50, $rule->serialize()); - } - foreach ($mdlFilter->npt->rule->sortedBy(["sequence"]) as $key => $rule) { - $fw->registerNptRule(50, $rule->serialize()); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterBaseController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterBaseController.php deleted file mode 100644 index 56cfeff77..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterBaseController.php +++ /dev/null @@ -1,178 +0,0 @@ - []]; - $catcount = []; - if (!empty(static::$categorysource)) { - $node = $this->getModel(); - foreach (explode('.', static::$categorysource) as $ref) { - $node = $node->$ref; - } - foreach ($node->iterateItems() as $item) { - if (!empty((string)$item->categories)) { - foreach (explode(',', (string)$item->categories) as $cat) { - if (!isset($catcount[$cat])) { - $catcount[$cat] = 0; - } - $catcount[$cat] += 1; - } - } - } - } - foreach ((new Category())->categories->category->iterateItems() as $key => $category) { - $response['rows'][] = [ - "uuid" => $key, - "name" => (string)$category->name, - "color" => (string)$category->color, - "used" => isset($catcount[$key]) ? $catcount[$key] : 0 - ]; - } - array_multisort(array_column($response['rows'], "name"), SORT_ASC, SORT_NATURAL, $response['rows']); - - return $response; - } - - /** - * list of available network options - * @return array - */ - public function listNetworkSelectOptionsAction() - { - $result = [ - 'single' => [ - 'label' => gettext("Single host or Network") - ], - 'aliases' => [ - 'label' => gettext("Aliases"), - 'items' => [] - ], - 'networks' => [ - 'label' => gettext("Networks"), - 'items' => [ - 'any' => gettext('any'), - '(self)' => gettext("This Firewall") - ] - ] - ]; - foreach ((Config::getInstance()->object())->interfaces->children() as $ifname => $ifdetail) { - $descr = htmlspecialchars(!empty($ifdetail->descr) ? $ifdetail->descr : strtoupper($ifname)); - $result['networks']['items'][$ifname] = $descr . " " . gettext("net"); - if (!isset($ifdetail->virtual)) { - $result['networks']['items'][$ifname . "ip"] = $descr . " " . gettext("address"); - } - } - foreach ((new Alias())->aliases->alias->iterateItems() as $alias) { - if (strpos((string)$alias->type, "port") === false) { - $result['aliases']['items'][(string)$alias->name] = (string)$alias->name; - } - } - - return $result; - } - - - public function applyAction($rollback_revision = null) - { - if ($this->request->isPost()) { - if ($rollback_revision != null) { - // background rollback timer - (new Backend())->configdpRun('pfplugin rollback_timer', [$rollback_revision], true); - } - return array("status" => (new Backend())->configdRun('filter reload')); - } else { - return array("status" => "error"); - } - } - - public function cancelRollbackAction($rollback_revision) - { - if ($this->request->isPost()) { - return array( - "status" => (new Backend())->configdpRun('pfplugin cancel_rollback', [$rollback_revision]) - ); - } else { - return array("status" => "error"); - } - } - - public function savepointAction() - { - if ($this->request->isPost()) { - // trigger a save, so we know revision->time matches our running config - Config::getInstance()->save(); - return array( - "status" => "ok", - "retention" => (string)Config::getInstance()->backupCount(), - "revision" => (string)Config::getInstance()->object()->revision->time - ); - } else { - return array("status" => "error"); - } - } - - public function revertAction($revision) - { - if ($this->request->isPost()) { - Config::getInstance()->lock(); - $filename = Config::getInstance()->getBackupFilename($revision); - if (!$filename) { - Config::getInstance()->unlock(); - return ["status" => gettext("unknown (or removed) savepoint")]; - } - $this->getModel()->rollback($revision); - Config::getInstance()->unlock(); - (new Backend())->configdRun('filter reload'); - return ["status" => "ok"]; - } else { - return array("status" => "error"); - } - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterController.php deleted file mode 100644 index 7af4676eb..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/FilterController.php +++ /dev/null @@ -1,67 +0,0 @@ -request->get('category'); - $filter_funct = function ($record) use ($category) { - return empty($category) || array_intersect(explode(',', $record->categories), $category); - }; - return $this->searchBase("rules.rule", ['enabled', 'sequence', 'description'], "sequence", $filter_funct); - } - - public function setRuleAction($uuid) - { - return $this->setBase("rule", "rules.rule", $uuid); - } - - public function addRuleAction() - { - return $this->addBase("rule", "rules.rule"); - } - - public function getRuleAction($uuid = null) - { - return $this->getBase("rule", "rules.rule", $uuid); - } - - public function delRuleAction($uuid) - { - return $this->delBase("rules.rule", $uuid); - } - - public function toggleRuleAction($uuid, $enabled = null) - { - return $this->toggleBase("rules.rule", $uuid, $enabled); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/NptController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/NptController.php deleted file mode 100644 index 9b04139d2..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/NptController.php +++ /dev/null @@ -1,72 +0,0 @@ -request->get('category'); - $filter_funct = function ($record) use ($category) { - return empty($category) || array_intersect(explode(',', $record->categories), $category); - }; - return $this->searchBase( - "npt.rule", - ['enabled', 'sequence', 'source_net', 'destination_net', 'trackif', 'description'], - "sequence", - $filter_funct - ); - } - - public function setRuleAction($uuid) - { - return $this->setBase("rule", "npt.rule", $uuid); - } - - public function addRuleAction() - { - return $this->addBase("rule", "npt.rule"); - } - - public function getRuleAction($uuid = null) - { - return $this->getBase("rule", "npt.rule", $uuid); - } - - public function delRuleAction($uuid) - { - return $this->delBase("npt.rule", $uuid); - } - - public function toggleRuleAction($uuid, $enabled = null) - { - return $this->toggleBase("npt.rule", $uuid, $enabled); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/SourceNatController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/SourceNatController.php deleted file mode 100644 index 5833225d9..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/SourceNatController.php +++ /dev/null @@ -1,67 +0,0 @@ -request->get('category'); - $filter_funct = function ($record) use ($category) { - return empty($category) || array_intersect(explode(',', $record->categories), $category); - }; - return $this->searchBase("snatrules.rule", ['enabled', 'sequence', 'description'], "sequence", $filter_funct); - } - - public function setRuleAction($uuid) - { - return $this->setBase("rule", "snatrules.rule", $uuid); - } - - public function addRuleAction() - { - return $this->addBase("rule", "snatrules.rule"); - } - - public function getRuleAction($uuid = null) - { - return $this->getBase("rule", "snatrules.rule", $uuid); - } - - public function delRuleAction($uuid) - { - return $this->delBase("snatrules.rule", $uuid); - } - - public function toggleRuleAction($uuid, $enabled = null) - { - return $this->toggleBase("snatrules.rule", $uuid, $enabled); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php deleted file mode 100644 index e558fe813..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php +++ /dev/null @@ -1,50 +0,0 @@ -view->pick('OPNsense/Firewall/filter'); - $this->view->SavePointBtns = true; - $this->view->ruleController = "filter"; - $this->view->gridFields = [ - [ - 'id' => 'enabled', 'formatter' => 'rowtoggle' ,'width' => '6em', 'heading' => gettext('Enabled') - ], - [ - 'id' => 'sequence','width' => '9em', 'heading' => gettext('Sequence') - ], - [ - 'id' => 'description', 'heading' => gettext('Description') - ] - ]; - $this->view->formDialogFilterRule = $this->getForm("dialogFilterRule"); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/NptController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/NptController.php deleted file mode 100644 index d701a8003..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/NptController.php +++ /dev/null @@ -1,59 +0,0 @@ -view->pick('OPNsense/Firewall/filter'); - $this->view->ruleController = "npt"; - $this->view->gridFields = [ - [ - 'id' => 'enabled', 'formatter' => 'rowtoggle' ,'width' => '6em', 'heading' => gettext('Enabled') - ], - [ - 'id' => 'sequence','width' => '9em', 'heading' => gettext('Sequence') - ], - [ - 'id' => 'source_net', 'heading' => gettext('Internal IPv6 Prefix') - ], - [ - 'id' => 'destination_net', 'heading' => gettext('External IPv6 Prefix') - ], - [ - 'id' => 'trackif', 'heading' => gettext('Track if') - ], - [ - 'id' => 'description', 'heading' => gettext('Description') - ] - ]; - - $this->view->formDialogFilterRule = $this->getForm("dialogNptRule"); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/SourceNatController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/SourceNatController.php deleted file mode 100644 index 9e24cc700..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/SourceNatController.php +++ /dev/null @@ -1,50 +0,0 @@ -view->pick('OPNsense/Firewall/filter'); - $this->view->SavePointBtns = true; - $this->view->ruleController = "source_nat"; - $this->view->gridFields = [ - [ - 'id' => 'enabled', 'formatter' => 'rowtoggle' ,'width' => '6em', 'heading' => gettext('Enabled') - ], - [ - 'id' => 'sequence','width' => '9em', 'heading' => gettext('Sequence') - ], - [ - 'id' => 'description', 'heading' => gettext('Description') - ] - ]; - $this->view->formDialogFilterRule = $this->getForm("dialogSNatRule"); - } -} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogFilterRule.xml b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogFilterRule.xml deleted file mode 100644 index af4cda9bc..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogFilterRule.xml +++ /dev/null @@ -1,114 +0,0 @@ -
- - rule.enabled - - checkbox - Enable this rule - - - rule.sequence - - text - - - rule.action - - dropdown - Choose what to do with packets that match the criteria specified below. - Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded. - - - - rule.quick - - checkbox - - If a packet matches a rule specifying quick, then that rule is considered the last matching rule and the specified action is taken. - When a rule does not have quick enabled, the last matching rule wins. - - - - rule.interface - - select_multiple - - - rule.direction - - dropdown - - Direction of the traffic. The default policy is to filter inbound traffic, which sets the policy to the interface originally receiving the traffic. - - - - rule.ipprotocol - - dropdown - - - rule.protocol - - dropdown - - - rule.source_net - - text - - - rule.source_port - - text - true - Source port number or well known name (imap, imaps, http, https, ...), for ranges use a dash - - - rule.source_not - - checkbox - Use this option to invert the sense of the match. - - - rule.destination_net - - text - - - rule.destination_not - - checkbox - Use this option to invert the sense of the match. - - - rule.destination_port - - text - Destination port number or well known name (imap, imaps, http, https, ...), for ranges use a dash - - - rule.gateway - - dropdown - - Leave as 'default' to use the system routing table. Or choose a gateway to utilize policy based routing. - - - - rule.log - - checkbox - Log packets that are handled by this rule - - - rule.categories - - select_multiple - - For grouping purposes you may select multiple groups here to organize items. - - - rule.description - - text - -
diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogNptRule.xml b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogNptRule.xml deleted file mode 100644 index 4c68b0e40..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogNptRule.xml +++ /dev/null @@ -1,53 +0,0 @@ -
- - rule.enabled - - checkbox - Enable this rule - - - rule.sequence - - text - - - rule.log - - checkbox - Log packets that are handled by this rule - - - rule.interface - - dropdown - - - rule.source_net - - text - - - rule.destination_net - - text - Enter the external IPv6 prefix for this network prefix translation. Leave empty to auto-detect the prefix address using the specified tracking interface instead. The prefix size specified for the internal prefix will also be applied to the external prefix. - - - rule.trackif - - dropdown - Use prefix defined on the selected interface instead of the interface this rule applies to when target prefix is not provided. - - - rule.categories - - select_multiple - - For grouping purposes you may select multiple groups here to organize items. - - - rule.description - - text - -
diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogSNatRule.xml b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogSNatRule.xml deleted file mode 100644 index 90dc7a90b..000000000 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/forms/dialogSNatRule.xml +++ /dev/null @@ -1,101 +0,0 @@ -
- - rule.enabled - - checkbox - Enable this rule - - - rule.nonat - - checkbox - Enabling this option will disable NAT for traffic matching this rule and stop processing Outbound NAT rules. - - - rule.sequence - - text - - - rule.interface - - dropdown - - - rule.ipprotocol - - dropdown - - - rule.protocol - - dropdown - - - rule.source_net - - text - - - rule.source_port - - text - true - Source port number or well known name (imap, imaps, http, https, ...), for ranges use a dash - - - rule.source_not - - checkbox - Use this option to invert the sense of the match. - - - rule.destination_net - - text - - - rule.destination_not - - checkbox - Use this option to invert the sense of the match. - - - rule.destination_port - - text - Destination port number or well known name (imap, imaps, http, https, ...), for ranges use a dash - - - rule.target - - text - - Packets matching this rule will be mapped to the IP address given here. - - - - rule.target_port - - text - Destination port number or well known name (imap, imaps, http, https, ...) - - - rule.log - - checkbox - Log packets that are handled by this rule - - - rule.categories - - select_multiple - - For grouping purposes you may select multiple groups here to organize items. - - - rule.description - - text - -
diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/ACL/ACL.xml b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/ACL/ACL.xml deleted file mode 100644 index c8a66f358..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/ACL/ACL.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - Firewall: Automation: Filter - - ui/firewall/filter/* - api/firewall/filter/* - - - - Firewall: Automation: Source NAT - - ui/firewall/source_nat/* - api/firewall/source_nat/* - - - - Firewall: Automation: NPTv6 - - ui/firewall/npt/* - api/firewall/npt/* - - - diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php deleted file mode 100644 index a3c69c53c..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php +++ /dev/null @@ -1,138 +0,0 @@ -iterateItems() as $key => $node) { - if (!in_array($key, $map_manual)) { - if (is_a($node, "OPNsense\\Base\\FieldTypes\\BooleanField")) { - $result[$key] = !empty((string)$node); - } elseif (is_a($node, "OPNsense\\Base\\FieldTypes\\ProtocolField")) { - if ((string)$node != 'any') { - $result[$key] = (string)$node; - } - } else { - $result[$key] = (string)$node; - } - } - } - // source / destination mapping - $result['source'] = array(); - if (!empty((string)$this->source_net)) { - $result['source']['network'] = (string)$this->source_net; - if (!empty((string)$this->source_not)) { - $result['source']['not'] = true; - } - if (!empty((string)$this->source_port)) { - $result['source']['port'] = (string)$this->source_port; - } - } - $result['destination'] = array(); - if (!empty((string)$this->destination_net)) { - $result['destination']['network'] = (string)$this->destination_net; - if (!empty((string)$this->destination_not)) { - $result['destination']['not'] = true; - } - if (!empty((string)$this->destination_port)) { - $result['destination']['port'] = (string)$this->destination_port; - } - } - // field mappings and differences - $result['disabled'] = empty((string)$this->enabled); - $result['descr'] = (string)$this->description; - $result['type'] = (string)$this->action; - if (strpos((string)$this->interface, ",") !== false) { - $result['floating'] = true; - } - return $result; - } - - /** - * rule priority is threaded equally to the legacy rules, first "floating" then groups and single interface - * rules are handled last - * @return int priority in the ruleset, sequence should determine sort order. - */ - public function getPriority() - { - $configObj = Config::getInstance()->object(); - $interface = (string)$this->interface; - if (strpos($interface, ",") !== false) { - // floating (multiple interfaces involved) - return 1000; - } elseif ( - !empty($configObj->interfaces) && - !empty($configObj->interfaces->$interface) && - !empty($configObj->interfaces->$interface->type) && - $configObj->interfaces->$interface->type == 'group' - ) { - // group type - return 2000; - } else { - // default - return 3000; - } - } -} - -/** - * Class FilterRuleField - * @package OPNsense\Firewall\FieldTypes - */ -class FilterRuleField extends ArrayField -{ - /** - * @inheritDoc - */ - public function newContainerField($ref, $tagname) - { - $container_node = new FilterRuleContainerField($ref, $tagname); - $parentmodel = $this->getParentModel(); - $container_node->setParentModel($parentmodel); - return $container_node; - } -} diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/SourceNatRuleField.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/SourceNatRuleField.php deleted file mode 100644 index b26c5d602..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/SourceNatRuleField.php +++ /dev/null @@ -1,111 +0,0 @@ - false, - 'source_net' => false, - 'source_not' => false, - 'source_port' => 'sourceport', - 'destination_net' => false, - 'destination_not' => false, - 'destination_port' => 'dstport', - 'target_port' => 'natport', - 'description' => 'descr' - ]; - // 1-on-1 map (with type conversion if needed) - foreach ($this->iterateItems() as $key => $node) { - $target_fieldname = isset($source_mapper[$key]) ? $source_mapper[$key] : $key; - if ($target_fieldname) { - if (is_a($node, "OPNsense\\Base\\FieldTypes\\BooleanField")) { - $result[$target_fieldname] = !empty((string)$node); - } elseif (is_a($node, "OPNsense\\Base\\FieldTypes\\ProtocolField")) { - if ((string)$node != 'any') { - $result[$target_fieldname] = (string)$node; - } - } else { - $result[$target_fieldname] = (string)$node; - } - } - } - - $result['disabled'] = empty((string)$this->enabled); - // source / destination mapping, doesn't use port construct like it would for rules. - $result['source'] = array(); - if (!empty((string)$this->source_net)) { - $result['source']['network'] = (string)$this->source_net; - if (!empty((string)$this->source_not)) { - $result['source']['not'] = true; - } - } - $result['destination'] = array(); - if (!empty((string)$this->destination_net)) { - $result['destination']['network'] = (string)$this->destination_net; - if (!empty((string)$this->destination_not)) { - $result['destination']['not'] = true; - } - } - - return $result; - } -} - -/** - * Class SourceNatRuleField - * @package OPNsense\Firewall\FieldTypes - */ -class SourceNatRuleField extends ArrayField -{ - /** - * @inheritDoc - */ - public function newContainerField($ref, $tagname) - { - $container_node = new SourceNatRuleContainerField($ref, $tagname); - $parentmodel = $this->getParentModel(); - $container_node->setParentModel($parentmodel); - return $container_node; - } -} diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php deleted file mode 100644 index 03978bc45..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php +++ /dev/null @@ -1,164 +0,0 @@ -object(); - - // standard model validations - $messages = parent::performValidation($validateFullModel); - foreach ([$this->rules->rule, $this->snatrules->rule] as $rules) { - foreach ($rules->iterateItems() as $rule) { - if ($validateFullModel || $rule->isFieldChanged()) { - // port / protocol validation - if (!empty((string)$rule->source_port) && !in_array($rule->protocol, ['TCP', 'UDP'])) { - $messages->appendMessage(new Message( - gettext("Source ports are only valid for tcp or udp type rules."), - $rule->source_port->__reference - )); - } - if (!empty((string)$rule->destination_port) && !in_array($rule->protocol, ['TCP', 'UDP'])) { - $messages->appendMessage(new Message( - gettext("Destination ports are only valid for tcp or udp type rules."), - $rule->destination_port->__reference - )); - } - // validate protocol family - $dest_is_addr = Util::isSubnet($rule->destination_net) || Util::isIpAddress($rule->destination_net); - $dest_proto = strpos($rule->destination_net, ':') === false ? "inet" : "inet6"; - if ($dest_is_addr && $dest_proto != $rule->ipprotocol) { - $messages->appendMessage(new Message( - gettext("Destination address type should match selected TCP/IP protocol version."), - $rule->destination_net->__reference - )); - } - $src_is_addr = Util::isSubnet($rule->source_net) || Util::isIpAddress($rule->source_net); - $src_proto = strpos($rule->source_net, ':') === false ? "inet" : "inet6"; - if ($src_is_addr && $src_proto != $rule->ipprotocol) { - $messages->appendMessage(new Message( - gettext("Source address type should match selected TCP/IP protocol version."), - $rule->source_net->__reference - )); - } - // Additional source nat validations - if ($rule->target !== null) { - $target_is_addr = Util::isSubnet($rule->target) || Util::isIpAddress($rule->target); - $target_proto = strpos($rule->target, ':') === false ? "inet" : "inet6"; - if ($target_is_addr && $target_proto != $rule->ipprotocol) { - $messages->appendMessage(new Message( - gettext("Target address type should match selected TCP/IP protocol version."), - $rule->target->__reference - )); - } - if (!empty((string)$rule->target_port) && !in_array($rule->protocol, ['TCP', 'UDP'])) { - $messages->appendMessage(new Message( - gettext("Target ports are only valid for tcp or udp type rules."), - $rule->target_port->__reference - )); - } - } - } - } - } - - foreach ($this->npt->rule->iterateItems() as $rule) { - if ($validateFullModel || $rule->isFieldChanged()) { - if (!empty((string)$rule->trackif)) { - if (!empty((string)$rule->destination_net)) { - $messages->appendMessage(new Message( - gettext('A track interface is only allowed without an external prefix.'), - $rule->trackif->__reference - )); - } - - if ( - (empty($config->interfaces->{$rule->interface}->ipaddrv6) || - $config->interfaces->{$rule->interface}->ipaddrv6 != 'dhcp6') || - empty($config->interfaces->{$rule->trackif}->{'track6-interface'}) || - $config->interfaces->{$rule->trackif}->{'track6-interface'} != (string)$rule->interface - ) { - $messages->appendMessage(new Message( - gettext('This interface is not tracking the current rule interface.'), - $rule->trackif->__reference - )); - } - } - - if (!empty((string)$rule->destination_net) && !empty((string)$rule->source_net)) { - /* defaults to /128 */ - $dparts = explode('/', (string)$rule->destination_net . '/128'); - $sparts = explode('/', (string)$rule->source_net . '/128'); - if ($dparts[1] != $sparts[1]) { - $messages->appendMessage(new Message( - gettext("External subnet should match internal subnet."), - $rule->destination_net->__reference - )); - } - } - } - } - return $messages; - } - - /** - * Rollback this model to a previous version. - * Make sure to remove this object afterwards, since its contents won't be updated. - * @param $revision float|string revision number - * @return bool action performed (backup revision existed) - */ - public function rollback($revision) - { - $filename = Config::getInstance()->getBackupFilename($revision); - if ($filename) { - // fiddle with the dom, copy OPNsense->Firewall->Filter from backup to current config - $sourcexml = simplexml_load_file($filename); - if ($sourcexml->OPNsense->Firewall->Filter) { - $sourcedom = dom_import_simplexml($sourcexml->OPNsense->Firewall->Filter); - $targetxml = Config::getInstance()->object(); - $targetdom = dom_import_simplexml($targetxml->OPNsense->Firewall->Filter); - $node = $targetdom->ownerDocument->importNode($sourcedom, true); - $targetdom->parentNode->replaceChild($node, $targetdom); - Config::getInstance()->save(); - return true; - } - } - return false; - } -} diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml deleted file mode 100644 index dc7399beb..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml +++ /dev/null @@ -1,263 +0,0 @@ - - //OPNsense/Firewall/Filter - 1.0.2 - MFP - - OPNsense firewall filter rules - - - - - - 1 - Y - - - 1 - 99999 - provide a valid sequence for sorting - Y - 1 - - - Y - pass - - Pass - Block - Reject - - - - 1 - Y - - - Y - Y - - - Y - in - - In - Out - - - - Y - inet - - IPv4 - IPv6 - - - - Y - any - - - - any - Y - - - 0 - Y - - - Y - Y - Y - Please specify a valid portnumber, name, alias or range - - - - any - Y - - - 0 - Y - - - Y - Y - Y - Please specify a valid portnumber, name, alias or range - - - interface gateways list - /tmp/gateway_list.json - 20 - Specify a valid gateway from the list matching the networks ip protocol. - - - 0 - Y - - - - - OPNsense.Firewall.Category - categories.category - name - - - Y - Related category not found. - - - N - /^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u - Description should be a string between 1 and 255 characters - - - - - - - 1 - Y - - - 0 - Y - - - 1 - 99999 - provide a valid sequence for sorting - Y - 1 - - - Y - lan - Y - - - Y - inet - - IPv4 - IPv6 - - - - Y - any - - - any - Y - - - 0 - Y - - - Y - Y - Y - Please specify a valid portnumber, name, alias or range - - - any - Y - - - 0 - Y - - - Y - Y - Y - Please specify a valid portnumber, name, alias or range - - - wanip - Y - - - Y - Y - - - 0 - Y - - - - - OPNsense.Firewall.Category - categories.category - name - - - Y - Related category not found. - - - N - /^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u - Description should be a string between 1 and 255 characters - - - - - - - 1 - Y - - - 0 - Y - - - 1 - 99999 - provide a valid sequence for sorting - Y - 1 - - - Y - lan - Y - - - Y - ipv6 - N - N - - - ipv6 - N - N - - - - - - - OPNsense.Firewall.Category - categories.category - name - - - Y - Related category not found. - - - N - /^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u - Description should be a string between 1 and 255 characters - - - - - diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Menu/Menu.xml b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Menu/Menu.xml deleted file mode 100644 index 455d06546..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Menu/Menu.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php deleted file mode 100644 index 2e33d2f7c..000000000 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php +++ /dev/null @@ -1,59 +0,0 @@ -Firewall->FilterRule ---> OPNsense->Firewall->Filter - $cfgObj = Config::getInstance()->object(); - if ( - !empty($cfgObj->OPNsense) && !empty($cfgObj->OPNsense->Firewall) - && !empty($cfgObj->OPNsense->Firewall->FilterRule) - ) { - // model migration created a new, empty rules section - if (empty($cfgObj->OPNsense->Firewall->Filter->rules)) { - unset($cfgObj->OPNsense->Firewall->Filter->rules); - $targetdom = dom_import_simplexml($cfgObj->OPNsense->Firewall->Filter); - foreach ($cfgObj->OPNsense->Firewall->FilterRule->children() as $child) { - $sourcedom = dom_import_simplexml($child); - $targetdom->appendChild($sourcedom); - } - unset($cfgObj->OPNsense->Firewall->FilterRule); - Config::getInstance()->save(); - } - } - } -} diff --git a/net/firewall/src/opnsense/mvc/app/views/OPNsense/Firewall/filter.volt b/net/firewall/src/opnsense/mvc/app/views/OPNsense/Firewall/filter.volt deleted file mode 100644 index 1b3abb397..000000000 --- a/net/firewall/src/opnsense/mvc/app/views/OPNsense/Firewall/filter.volt +++ /dev/null @@ -1,250 +0,0 @@ - - - - -
-
- - - - - - -{% for fieldlist in gridFields %} - -{% endfor %} - - - - - - - - - - - -
{{ lang._('ID') }}{{fieldlist['heading']|default('')}}{{ lang._('Commands') }}
- - -
-
- -
- -{% if SavePointBtns is defined %} -
- - -
-{% endif %} -

-
-
-
- - - -{{ partial("layout_partials/base_dialog",['fields':formDialogFilterRule,'id':'DialogFilterRule','label':lang._('Edit rule')])}} diff --git a/net/firewall/src/opnsense/scripts/pfplugin/rollback_cancel b/net/firewall/src/opnsense/scripts/pfplugin/rollback_cancel deleted file mode 100755 index c47f74b07..000000000 --- a/net/firewall/src/opnsense/scripts/pfplugin/rollback_cancel +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/local/bin/php -= 2) { - $revision = preg_replace("/[^0-9.]/", "", $argv[1]); - if (!empty($revision)) { - $lckfile = "/tmp/pfplugin_{$revision}.lock"; - if (file_exists($lckfile)) { - unlink($lckfile); - exit(0); - } - } -} -exit(1); diff --git a/net/firewall/src/opnsense/scripts/pfplugin/rollback_timer b/net/firewall/src/opnsense/scripts/pfplugin/rollback_timer deleted file mode 100755 index 819a1f12c..000000000 --- a/net/firewall/src/opnsense/scripts/pfplugin/rollback_timer +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/local/bin/php -= 2) { - $revision = preg_replace("/[^0-9.]/", "", $argv[1]); - if (!empty($revision)) { - $lckfile = "/tmp/pfplugin_{$revision}.lock"; - file_put_contents($lckfile, ""); - // give the api 60 seconds to callback - for ($i=0; $i < 60 ; ++$i) { - if (!file_exists($lckfile)) { - // got feedback - exit(0); - } - sleep(1); - } - @unlink($lckfile); - // no feedback, revert - $mdlFilter = new OPNsense\Firewall\Filter(); - if ($mdlFilter->rollback($revision)) { - (new OPNsense\Core\Backend())->configdRun('filter reload'); - } else { - syslog(LOG_WARNING, "unable to revert to unexisting revision : {$revision}"); - } - } -} diff --git a/net/firewall/src/opnsense/service/conf/actions.d/actions_pfplugin.conf b/net/firewall/src/opnsense/service/conf/actions.d/actions_pfplugin.conf deleted file mode 100644 index 61a13f477..000000000 --- a/net/firewall/src/opnsense/service/conf/actions.d/actions_pfplugin.conf +++ /dev/null @@ -1,11 +0,0 @@ -[rollback_timer] -command:/usr/local/bin/flock -n -E 0 -o /tmp/pfplugin_rollback_timer.lock /usr/local/opnsense/scripts/pfplugin/rollback_timer -parameters: %s -type:script -message:wait for api feedback or revert to previous filter plugin config - -[cancel_rollback] -command: /usr/local/opnsense/scripts/pfplugin/rollback_cancel -parameters: %s -type:script_output -message:cancel pfplugin rollback diff --git a/net/wireguard-go/Makefile b/net/wireguard-go/Makefile deleted file mode 100644 index e2fda1061..000000000 --- a/net/wireguard-go/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -PLUGIN_NAME= wireguard-go -PLUGIN_VERSION= 1.13 -PLUGIN_REVISION= 8 -PLUGIN_COMMENT= WireGuard VPN service Go implementation -PLUGIN_CONFLICTS= wireguard -PLUGIN_OBSOLETE= yes -PLUGIN_DEPENDS= wireguard-go wireguard-tools -PLUGIN_MAINTAINER= m.muenz@gmail.com - -.include "../../Mk/plugins.mk" diff --git a/net/wireguard-go/pkg-descr b/net/wireguard-go/pkg-descr deleted file mode 100644 index 5d84964c9..000000000 --- a/net/wireguard-go/pkg-descr +++ /dev/null @@ -1,78 +0,0 @@ -WireGuard® is an extremely simple yet fast and modern VPN -that utilizes state-of-the-art cryptography. It aims to be -faster, simpler, leaner, and more useful than IPSec, while -avoiding the massive headache. It intends to be considerably -more performant than OpenVPN. WireGuard is designed as a -general purpose VPN for running on embedded interfaces and -super computers alike, fit for many different circumstances. -Initially released for the Linux kernel, it is now -cross-platform and widely deployable. It is currently under -heavy development, but already it might be regarded as the -most secure, easiest to use, and simplest VPN solution in -the industry. - -WWW: https://www.wireguard.com/ - -Changelog ---------- - -1.13 - -* Reworked widget and assorted cleanups (contributed by Patrik Kernstock) -* Improve widget public key overlapping (contributed by Victor Haggqvist) - -1.12 - -* Adjust validation for naming local instance and endpoints - -1.11 - -* Add script for renewal of Wireguard DNS-based entries for stale connections (#2956) -* Trim whitespace around new public and private keys in config (#2982) - -1.10 - -* Remove instance limit - -1.9 - -* Rename interface label in filter rules (#2577) - -1.8 - -* Empty port in Endpoint is allowed - -1.7 - -* Make tunnel address (wg interface address) optional - -1.6 - -* Move DNS setting to advanced -* Make listen port optional - -1.5 - -* Allow synchronization of config - -1.4 - -* Add IPv6 gateway support (contributed by Alexander Korinek) - -1.3 - -* Client/peer name validation to use HostnameField - -1.2 - -* Dashboard widget (contributed by D. Domig) - -1.1 - -* Allow adding interface route for PBR - -1.0 - -* Support for most features like S2S, Roadwarrior -* DNS, MTU, PSK -* Allow to disable setting routes for PBR diff --git a/net/wireguard-go/src/etc/inc/plugins.inc.d/wireguard.inc b/net/wireguard-go/src/etc/inc/plugins.inc.d/wireguard.inc deleted file mode 100644 index ad234adcf..000000000 --- a/net/wireguard-go/src/etc/inc/plugins.inc.d/wireguard.inc +++ /dev/null @@ -1,110 +0,0 @@ - - * 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. - */ - -function wireguard_enabled() -{ - $model = new \OPNsense\Wireguard\General(); - return (string)$model->enabled == '1'; -} - -function wireguard_services() -{ - $services = []; - - if (!wireguard_enabled()) { - return $services; - } - - $service = [ - 'description' => gettext('WireGuard VPN'), - 'configd' => [ - 'restart' => ['wireguard restart'], - 'start' => ['wireguard start'], - 'stop' => ['wireguard stop'], - ], - 'name' => 'wireguard-go', - ]; - - $services[] = $service; - - return $services; -} - -function wireguard_interfaces() -{ - $interfaces = []; - - if (!wireguard_enabled()) { - return $interfaces; - } - - $interfaces['wireguard'] = [ - 'descr' => gettext('WireGuard (Group)'), - 'if' => 'wireguard', - 'virtual' => true, - 'enable' => true, - 'type' => 'group', - 'networks' => [], - ]; - - return $interfaces; -} - -function wireguard_xmlrpc_sync() -{ - $result = []; - - $result['id'] = 'wireguard'; - $result['section'] = 'OPNsense.wireguard'; - $result['description'] = gettext('WireGuard'); - $result['services'] = ['wireguard-go']; - - return [$result]; -} - -function wireguard_devices() -{ - $names = []; - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $key => $node) { - if (!empty((string)$node->enabled)) { - $device = 'wg' . $node->instance; - $names[$device] = [ - 'descr' => sprintf('%s (WireGuard - %s)', $device, (string)$node->name), - 'ifdescr' => (string)$node->name, - 'name' => $device, - ]; - } - } - return [[ - 'configurable' => false, - 'pattern' => '^wg', - 'type' => 'wireguard', - 'volatile' => true, - 'names' => $names, - ]]; -} diff --git a/net/wireguard-go/src/etc/rc.syshook.d/start/50-wireguard b/net/wireguard-go/src/etc/rc.syshook.d/start/50-wireguard deleted file mode 100755 index 78ab22804..000000000 --- a/net/wireguard-go/src/etc/rc.syshook.d/start/50-wireguard +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# start again to fix problems with failed name resolution (no need to restart) -configctl -dq wireguard start diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php deleted file mode 100644 index ae7d84660..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; - -class ClientController extends ApiMutableModelControllerBase -{ - protected static $internalModelName = 'client'; - protected static $internalModelClass = '\OPNsense\Wireguard\Client'; - - public function searchClientAction() - { - return $this->searchBase('clients.client', array("enabled", "name", "pubkey", "tunneladdress", "serveraddress", "serverport")); - } - - public function getClientAction($uuid = null) - { - $this->sessionClose(); - return $this->getBase('client', 'clients.client', $uuid); - } - - public function addClientAction() - { - return $this->addBase('client', 'clients.client'); - } - - public function delClientAction($uuid) - { - return $this->delBase('clients.client', $uuid); - } - - public function setClientAction($uuid) - { - return $this->setBase('client', 'clients.client', $uuid); - } - - public function toggleClientAction($uuid) - { - return $this->toggleBase('clients.client', $uuid); - } -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php deleted file mode 100644 index 1aca5548d..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php +++ /dev/null @@ -1,138 +0,0 @@ - - * Copyright (C) 2022 Patrik Kernstock - * - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; -use OPNsense\Core\Config; -use OPNsense\Core\Backend; - -class GeneralController extends ApiMutableModelControllerBase -{ - protected static $internalModelClass = '\OPNsense\Wireguard\General'; - protected static $internalModelName = 'general'; - - public function getStatusAction() - { - // get wireguard configuration - $config = Config::getInstance()->object(); - $config = $config->OPNsense->wireguard; - - // craft peers array - $peers = []; - $peers_uuid_pubkey = []; - // enabled, name, pubkey - foreach ($config->client->clients->client as $client) { - $peerUuid = (string)$client->attributes()['uuid']; - $peers_uuid_pubkey[$peerUuid] = (string) $client->pubkey; - $peers[$peerUuid] = [ - "name" => (string) $client->name, - "enabled" => (int) $client->enabled, - "publicKey" => (string) $client->pubkey, - ]; - } - - // prepare and initialize the server array - $status = []; - $peer_pubkey_reference = []; - foreach ($config->server->servers->server as $server) { - if ($server->enabled != "1") { - continue; - } - - // build basic server array - $interface = "wg" . $server->instance; - $status[$interface] = [ - "instance" => (int) $server->instance, - "interface" => (string) $interface, - "enabled" => (int) $server->enabled, - "name" => (string) $server->name, - "peers" => [], - ]; - - // parse and add peers with initial values to array - if (strlen($server->peers) > 0) { - // there is at least one peer defined - $serverPeers = explode(",", (string) $server->peers); - // iteriate over each peer uuid - foreach ($serverPeers as $peerUuid) { - // skipping removed peer that is still referenced in server - if (!isset($peers[$peerUuid])) { - continue; - } - // remember interface and pubkey <> peer-uuid reference for referencing handshake logic below - $peer_pubkey_reference[$interface][$peers_uuid_pubkey[$peerUuid]] = $peerUuid; - // merge peer info and initial values for handshake data - $status[$interface]["peers"][$peerUuid] = array_merge( - $peers[$peerUuid], - [ - "lastHandshake" => "0000-00-00 00:00:00+00:00", - ] - ); - } - } - } - - // Get latest handshakes by running CLI command locally - $data = (new Backend())->configdRun("wireguard showhandshake"); - - // parse and set handshake to status datastructure - $data = trim($data); - if (strlen($data) !== 0) { - $wgHandshakes = explode("\n", $data); - foreach ($wgHandshakes as $handshake) { - $item = explode("\t", trim($handshake)); - - // set interface name and publickey - $interface = trim($item[0]); - $pubkey = trim($item[1]); - - // calculate handshake time based on local timezone - $epoch = $item[2]; - if ($epoch > 0) { - $dt = new \DateTime("@$epoch"); - $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); - $latest = $dt->format("Y-m-d H:i:sP"); - - // set handshake - $peerUuid = $peer_pubkey_reference[$interface][$pubkey]; - if (!empty($peerUuid)) { - $status[$interface]["peers"][$peerUuid]["lastHandshake"] = $latest; - } - } - } - } - - return [ - "items" => $status - ]; - } -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php deleted file mode 100644 index 5bf57767a..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php +++ /dev/null @@ -1,108 +0,0 @@ - - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; -use OPNsense\Core\Backend; - -class ServerController extends ApiMutableModelControllerBase -{ - protected static $internalModelName = 'server'; - protected static $internalModelClass = '\OPNsense\Wireguard\Server'; - - public function searchServerAction() - { - $search = $this->searchBase('servers.server', array("enabled", "instance", "peers", "name", "networks", "pubkey", "port", "tunneladdress")); - // prepend "wg" to all instance IDs to use as interface name - foreach ($search["rows"] as $key => $server) { - $search["rows"][$key]["interface"] = "wg" . $server["instance"]; - } - return $search; - } - - public function getServerAction($uuid = null) - { - $this->sessionClose(); - return $this->getBase('server', 'servers.server', $uuid); - } - - public function addServerAction($uuid = null) - { - if ($this->request->isPost() && $this->request->hasPost("server")) { - if ($uuid != null) { - $node = $this->getModel()->getNodeByReference('servers.server.' . $uuid); - } else { - $node = $this->getModel()->servers->server->Add(); - } - $node->setNodes($this->request->getPost("server")); - if (empty((string)$node->pubkey) && empty((string)$node->privkey)) { - // generate new keypair - $backend = new Backend(); - $keyspriv = $backend->configdpRun("wireguard genkey", 'private'); - $keyspub = $backend->configdpRun("wireguard genkey", 'public'); - $node->privkey = trim($keyspriv); - $node->pubkey = trim($keyspub); - } - return $this->validateAndSave($node, 'server'); - } - return array("result" => "failed"); - } - - public function delServerAction($uuid) - { - return $this->delBase('servers.server', $uuid); - } - - public function setServerAction($uuid = null) - { - if ($this->request->isPost() && $this->request->hasPost("server")) { - if ($uuid != null) { - $node = $this->getModel()->getNodeByReference('servers.server.' . $uuid); - } else { - $node = $this->getModel()->servers->server->Add(); - } - $node->setNodes($this->request->getPost("server")); - if (empty((string)$node->pubkey) && empty((string)$node->privkey)) { - // generate new keypair - $backend = new Backend(); - $keyspriv = $backend->configdpRun("wireguard genkey", 'private'); - $keyspub = $backend->configdpRun("wireguard genkey", 'public'); - $node->privkey = trim($keyspriv); - $node->pubkey = trim($keyspub); - } - return $this->validateAndSave($node, 'server'); - } - return array("result" => "failed"); - } - - public function toggleServerAction($uuid) - { - return $this->toggleBase('servers.server', $uuid); - } -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php deleted file mode 100644 index 627911beb..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php +++ /dev/null @@ -1,76 +0,0 @@ - - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableServiceControllerBase; -use OPNsense\Core\Backend; -use OPNsense\Wireguard\General; - -/** - * Class ServiceController - * @package OPNsense\Wireguard - */ -class ServiceController extends ApiMutableServiceControllerBase -{ - protected static $internalServiceClass = '\OPNsense\Wireguard\General'; - protected static $internalServiceTemplate = 'OPNsense/Wireguard'; - protected static $internalServiceEnabled = 'enabled'; - protected static $internalServiceName = 'wireguard'; - - /** - * hook group interface registration on reconfigure - * @return bool - */ - protected function invokeInterfaceRegistration() - { - return true; - } - - /** - * show wireguard config - * @return array - */ - public function showconfAction() - { - $backend = new Backend(); - $response = $backend->configdRun("wireguard showconf"); - return array("response" => $response); - } - - /** - * show wireguard handshakes - * @return array - */ - public function showhandshakeAction() - { - $backend = new Backend(); - $response = $backend->configdRun("wireguard showhandshake"); - return array("response" => $response); - } -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php deleted file mode 100644 index 404fce682..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php +++ /dev/null @@ -1,40 +0,0 @@ - - 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\Wireguard; - -class GeneralController extends \OPNsense\Base\IndexController -{ - public function indexAction() - { - $this->view->generalForm = $this->getForm("general"); - $this->view->formDialogEditWireguardClient = $this->getForm("dialogEditWireguardClient"); - $this->view->formDialogEditWireguardServer = $this->getForm("dialogEditWireguardServer"); - $this->view->pick('OPNsense/Wireguard/general'); - } -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml deleted file mode 100644 index 231e9c692..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml +++ /dev/null @@ -1,52 +0,0 @@ -
- - client.enabled - - checkbox - This will enable or disable the client config. - - - client.name - - text - Set the name for this instance. - - - client.pubkey - - text - Public key of this instance. - - - client.psk - - text - Shared secret (PSK) for this peer. You can generate a key using "wg genpsk" on a client with WireGuard installed. - - - client.tunneladdress - - - select_multiple - true - List of addresses allowed to pass trough the tunnel adapter. Please use CIDR notation like 10.0.0.1/24. - - - client.serveraddress - - text - Set public IP address the endpoint listens to. - - - client.serverport - - text - Set port the endpoint listens to. - - - client.keepalive - - text - Set persistent keepalive interval in seconds. - -
diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml deleted file mode 100644 index eff1f9504..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml +++ /dev/null @@ -1,82 +0,0 @@ -
- - server.enabled - - checkbox - This will enable or disable the server config. - - - server.name - - text - Set the name for this instance. - - - server.instance - - info - This is the instance number to give the wg interface a unique name (wgX). - - - server.pubkey - - text - Public key of this instance. You can specify your own one, or a key will be generated after saving. - - - server.privkey - - text - Private key of this instance. You can specify your own one, or a key will be generated after saving. Please keep this key safe. - - - server.port - - text - Optionally set a fixed port for this instance to listen on. The standard port range starts at 51820. - - - server.mtu - - text - true - Set the interface MTU for this interface. Leaving empty uses the MTU from main interface which is fine for most setups. - - - server.dns - - select_multiple - - true - true - Set the interface specific DNS server. - - - server.tunneladdress - - - select_multiple - true - List of addresses to configure on the tunnel adapter. Please use CIDR notation like 10.0.0.1/24. - - - server.peers - - select_multiple - true - List of peers for this server. - - - server.disableroutes - - checkbox - This will prevent installing routes. Usually you only enable this to do own routing decisions via a local gateway and gateway rules. - - - server.gateway - - text - true - Set the gateway IP here when using Disable Routes feature. You also have to add this as a gateway in OPNsense. - -
diff --git a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml b/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml deleted file mode 100644 index 7a74ebf81..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml +++ /dev/null @@ -1,8 +0,0 @@ -
- - general.enabled - - checkbox - This will activate WireGuard and start all enabled instances. - -
diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml deleted file mode 100644 index 21012db80..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - VPN: Wireguard - - ui/wireguard/* - api/wireguard/* - - - diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php deleted file mode 100644 index b069a766d..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php +++ /dev/null @@ -1,31 +0,0 @@ - - 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class Client extends BaseModel -{ -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml deleted file mode 100644 index 69527a433..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml +++ /dev/null @@ -1,47 +0,0 @@ - - //OPNsense/wireguard/client - Wireguard Client configuration - 0.0.7 - - - - - 1 - Y - - - - Y - /^([0-9a-zA-Z._\-]){1,64}$/u - Should be a string between 1 and 64 characters. Allowed characters are alphanumeric characters, dash and underscores. - - - Y - Should be a base64-encoded 32 byte string. - - - N - Should be a base64-encoded 32 byte string. - - - - , - Y - Y - - - N - - - N - - - 1 - 86400 - Please specify a value between 1 and 86400. - N - - - - - diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php deleted file mode 100644 index 6caf9eaba..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php +++ /dev/null @@ -1,35 +0,0 @@ - - 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class General extends BaseModel -{ -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml deleted file mode 100644 index 432fd654c..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml +++ /dev/null @@ -1,11 +0,0 @@ - - //OPNsense/wireguard/general - WireGuard configuration - 0.0.1 - - - 0 - Y - - - diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml deleted file mode 100644 index a2934e1b0..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php deleted file mode 100644 index 8fccdd577..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php +++ /dev/null @@ -1,31 +0,0 @@ - - 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class Server extends BaseModel -{ -} diff --git a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml b/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml deleted file mode 100644 index 476091d23..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml +++ /dev/null @@ -1,77 +0,0 @@ - - //OPNsense/wireguard/server - Wireguard Server configuration - 0.0.4 - - - - - 1 - Y - - - - Y - /^([0-9a-zA-Z._\-]){1,64}$/u - Should be a string between 1 and 64 characters. Allowed characters are alphanumeric characters, dash and underscores. - - - Y - - - N - - - N - - - N - - - 1 - 9300 - N - - - N - /^([a-fA-F0-9\.:\[\]]*?,)*([a-fA-F0-9\.:\[\]]*)$/ - Please use valid IPv4 or IPv6 addresses. - - - - , - N - Y - - - 0 - Y - - - You have to enable Disable Routes option. - DependConstraint - - gateway - - - - - - N - - - - - - Y - N - Choose an Peer. - - - - - diff --git a/net/wireguard-go/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt b/net/wireguard-go/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt deleted file mode 100644 index 8b0accd2d..000000000 --- a/net/wireguard-go/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt +++ /dev/null @@ -1,199 +0,0 @@ -{# - # OPNsense (c) 2014-2018 by Deciso B.V. - # OPNsense (c) 2018 Michael Muenz - # 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. - #} - - - - -
-
-
- {{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}} -
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - -
{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Endpoint Address') }}{{ lang._('Endpoint Port') }}{{ lang._('Allowed IPs') }}{{ lang._('ID') }}{{ lang._('Commands') }}
- -
-
-
- -

-
-
-
- - - - - - - - - - - - - - - - - - - - - -
{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Interface') }}{{ lang._('Tunnel Address') }}{{ lang._('Port') }}{{ lang._('Endpoints') }}{{ lang._('ID') }}{{ lang._('Commands') }}
- -
-
-
- -

-
-
-
-

-    
-
-

-    
-
- -{{ partial("layout_partials/base_dialog",['fields':formDialogEditWireguardClient,'id':'dialogEditWireguardClient','label':lang._('Edit Endpoint')])}} -{{ partial("layout_partials/base_dialog",['fields':formDialogEditWireguardServer,'id':'dialogEditWireguardServer','label':lang._('Edit Local Configuration')])}} - - diff --git a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/genkey.sh b/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/genkey.sh deleted file mode 100755 index b580bf49d..000000000 --- a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/genkey.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2018 Michael Muenz -# -# 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 BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - -TMPDIR="/tmp" -GENPRIV="/usr/local/bin/wg genkey" -GENPUB="/usr/local/bin/wg pubkey" - -cleanup() { - # Delete old files - rm -f $TMPDIR/wireguard.* -} - -private() { - # Generate a private key and put it to /tmp - umask 077 && ${GENPRIV} | tee ${TMPDIR}/wireguard.priv -} - -public() { - # Generate a public key and put it to /tmp - ${GENPUB} < ${TMPDIR}/wireguard.priv | tee ${TMPDIR}/wireguard.pub -} - -case "$1" in -private) - cleanup - private - ;; -public) - public - ;; -esac diff --git a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/post.sh b/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/post.sh deleted file mode 100755 index 375ca3835..000000000 --- a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/post.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [ -f /etc/rc.conf.d/wireguard ]; then - . /etc/rc.conf.d/wireguard -fi - -for interface in ${wireguard_interfaces}; do - ifconfig ${interface} group wireguard -done - -/usr/local/etc/rc.routing_configure diff --git a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/resolve-dns.bash b/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/resolve-dns.bash deleted file mode 100755 index b7faf881a..000000000 --- a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/resolve-dns.bash +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/local/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (C) 2015-2020 Jason A. Donenfeld . All Rights Reserved. - -set -e -shopt -s nocasematch -shopt -s extglob -export LC_ALL=C - -for CONFIG_FILE in /usr/local/etc/wireguard/*.conf; do - - [[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] - INTERFACE="${BASH_REMATCH[1]}" - - process_peer() { - [[ $PEER_SECTION -ne 1 || -z $PUBLIC_KEY || -z $ENDPOINT ]] && return 0 - [[ $(wg show "$INTERFACE" latest-handshakes) =~ ${PUBLIC_KEY//+/\\+}\ ([0-9]+) ]] || return 0 - (( ($EPOCHSECONDS - ${BASH_REMATCH[1]}) > 135 )) || return 0 - wg set "$INTERFACE" peer "$PUBLIC_KEY" endpoint "$ENDPOINT" - reset_peer_section - } - - reset_peer_section() { - PEER_SECTION=0 - PUBLIC_KEY="" - ENDPOINT="" - } - - reset_peer_section - while read -r line || [[ -n $line ]]; do - stripped="${line%%\#*}" - key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}" - value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}" - [[ $key == "["* ]] && { process_peer; reset_peer_section; } - [[ $key == "[Peer]" ]] && PEER_SECTION=1 - if [[ $PEER_SECTION -eq 1 ]]; then - case "$key" in - PublicKey) PUBLIC_KEY="$value"; continue ;; - Endpoint) ENDPOINT="$value"; continue ;; - esac - fi - done < "$CONFIG_FILE" - process_peer -done diff --git a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/setup.sh b/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/setup.sh deleted file mode 100755 index 75ba580c9..000000000 --- a/net/wireguard-go/src/opnsense/scripts/OPNsense/Wireguard/setup.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -mkdir -p /var/run/wireguard -chmod 755 /var/run/wireguard diff --git a/net/wireguard-go/src/opnsense/service/conf/actions.d/actions_wireguard.conf b/net/wireguard-go/src/opnsense/service/conf/actions.d/actions_wireguard.conf deleted file mode 100644 index b2b96828f..000000000 --- a/net/wireguard-go/src/opnsense/service/conf/actions.d/actions_wireguard.conf +++ /dev/null @@ -1,43 +0,0 @@ -[start] -command:/usr/local/etc/rc.d/wireguard start; /usr/local/opnsense/scripts/OPNsense/Wireguard/post.sh -parameters: -type:script -message:Starting WireGuard - -[stop] -command:/usr/local/etc/rc.d/wireguard stop -parameters: -type:script -message:Stopping WireGuard - -[restart] -command:/usr/local/etc/rc.d/wireguard restart; /usr/local/opnsense/scripts/OPNsense/Wireguard/post.sh -parameters: -type:script -message:Restarting WireGuard -description: Restart WireGuard - -[renew] -command:/usr/local/opnsense/scripts/OPNsense/Wireguard/resolve-dns.bash -parameters: -type:script -message:Renew DNS for WireGuard -description:Renew DNS for WireGuard on stale connections - -[genkey] -command:/usr/local/opnsense/scripts/OPNsense/Wireguard/genkey.sh -parameters: %s -type:script_output -message:Generating WireGuard keys - -[showconf] -command:/usr/local/bin/wg show all -parameters: -type:script_output -message:Show WireGuard config - -[showhandshake] -command:/usr/local/bin/wg show all latest-handshakes -parameters: -type:script_output -message:Show WireGuard handshakes diff --git a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS b/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS deleted file mode 100644 index 655def7d1..000000000 --- a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS +++ /dev/null @@ -1,2 +0,0 @@ -wireguard:/etc/rc.conf.d/wireguard -wireguard-server.conf:/usr/local/etc/wireguard/wg[OPNsense.wireguard.server.servers.server.%.instance].conf diff --git a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard b/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard deleted file mode 100644 index c4c12667a..000000000 --- a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard +++ /dev/null @@ -1,15 +0,0 @@ -{% if helpers.exists('OPNsense.wireguard.general.enabled') and OPNsense.wireguard.general.enabled == '1' %} -wireguard_setup="/usr/local/opnsense/scripts/OPNsense/Wireguard/setup.sh" -wireguard_enable="YES" -{% if helpers.exists('OPNsense.wireguard.server.servers.server') %} -{% set activeservers=[] %} -{% for servers in helpers.toList('OPNsense.wireguard.server.servers.server') %} -{% if servers.enabled == '1' %} -{% do activeservers.append("wg" + servers.instance) %} -{% endif %} -{% endfor %} -{% endif %} -wireguard_interfaces="{{ activeservers | join(' ') }}" -{% else %} -wireguard_enable="NO" -{% endif %} diff --git a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf b/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf deleted file mode 100644 index 355ea0815..000000000 --- a/net/wireguard-go/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf +++ /dev/null @@ -1,53 +0,0 @@ -{% if helpers.exists('OPNsense.wireguard.general.enabled') and OPNsense.wireguard.general.enabled == '1' %} -{% if helpers.exists('OPNsense.wireguard.server.servers.server') %} -{% for server_list in helpers.toList('OPNsense.wireguard.server.servers.server') %} -{% if TARGET_FILTERS['OPNsense.wireguard.server.servers.server.' ~ loop.index0] or TARGET_FILTERS['OPNsense.wireguard.server.servers.server'] %} -{% if server_list.enabled == '1' %} -[Interface] -PrivateKey = {{ server_list.privkey }} -{% if server_list.tunneladdress|default('') != '' %} -Address = {{ server_list.tunneladdress }} -{% endif %} -{% if server_list.port|default('') != '' %} -ListenPort = {{ server_list.port }} -{% endif %} -{% if server_list.dns|default('') != '' %} -DNS = {{ server_list.dns }} -{% endif %} -{% if server_list.mtu|default('') != '' %} -MTU = {{ server_list.mtu }} -{% endif %} -{% if server_list.disableroutes == '1' %} -Table = off -{% endif %} -{% if server_list.disableroutes == '1' and server_list.gateway|default('') != '' %} -PostUp = route {{- ' -6' if ':' in server_list.gateway }} add {{ server_list.gateway }} -iface %i -PostDown = route {{- ' -6' if ':' in server_list.gateway }} del {{ server_list.gateway }} -iface %i -{% endif %} -{% if server_list.peers|default('') != '' %} -{% for peerlist in server_list.peers.split(",") %} -{% set peerlist2_data = helpers.getUUID(peerlist) %} -{% if peerlist2_data != {} and peerlist2_data.enabled == '1' %} - -[Peer] -# friendly_name = {{ peerlist2_data.name }} -PublicKey = {{ peerlist2_data.pubkey }} -{% if peerlist2_data.psk|default('') != '' %} -PresharedKey = {{ peerlist2_data.psk }} -{% endif %} -{% if peerlist2_data.serveraddress|default('') != '' %} -Endpoint = {{ peerlist2_data.serveraddress }}{% if peerlist2_data.serverport|default('') != '' %}:{{ peerlist2_data.serverport }}{% else %}:51820{% endif %} -{% endif %} - -AllowedIPs = {{ peerlist2_data.tunneladdress }} -{% if peerlist2_data.keepalive|default('') != '' %} -PersistentKeepalive = {{ peerlist2_data.keepalive }} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/net/wireguard-go/src/www/widgets/include/wireguard.inc b/net/wireguard-go/src/www/widgets/include/wireguard.inc deleted file mode 100644 index b95fc1fa6..000000000 --- a/net/wireguard-go/src/www/widgets/include/wireguard.inc +++ /dev/null @@ -1,4 +0,0 @@ - - * 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("guiconfig.inc"); -require_once("widgets/include/wireguard.inc"); - -$enabled = ($config["OPNsense"]["wireguard"]["general"]["enabled"] === "1" ? true : false); - -?> - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/net/wireguard/Makefile b/net/wireguard/Makefile deleted file mode 100644 index f2958e8ff..000000000 --- a/net/wireguard/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -PLUGIN_NAME= wireguard -PLUGIN_VERSION= 2.6 -PLUGIN_COMMENT= WireGuard VPN service kernel implementation -PLUGIN_DEPENDS= wireguard-kmod -PLUGIN_CONFLICTS= wireguard-go -PLUGIN_OBSOLETE= yes -PLUGIN_MAINTAINER= ad@opnsense.org - -.include "../../Mk/plugins.mk" diff --git a/net/wireguard/pkg-descr b/net/wireguard/pkg-descr deleted file mode 100644 index c045449d1..000000000 --- a/net/wireguard/pkg-descr +++ /dev/null @@ -1,127 +0,0 @@ -WireGuard® is an extremely simple yet fast and modern VPN -that utilizes state-of-the-art cryptography. It aims to be -faster, simpler, leaner, and more useful than IPSec, while -avoiding the massive headache. It intends to be considerably -more performant than OpenVPN. WireGuard is designed as a -general purpose VPN for running on embedded interfaces and -super computers alike, fit for many different circumstances. -Initially released for the Linux kernel, it is now -cross-platform and widely deployable. It is currently under -heavy development, but already it might be regarded as the -most secure, easiest to use, and simplest VPN solution in -the industry. - -WWW: https://www.wireguard.com/ - -Changelog ---------- - -2.6 - -* Consider missing CARP VHID as disabled - -2.5 - -* Fix error with empty tunnel address in instance (contributed by Monviech) -* Switch "setconf" to "syncconf" on (re)configuration -* Fix regression of UUID return in setClientAction() -* Reload the packet filter after reconfiguration -* Allow instance selection from peer -* Use "syncconf" on newwanip event -* CARP event handling improvements -* Minor UX and woring improvements - -2.4 - -* Only invoke routes for attached WireGuard instances -* Make bootup device creation more robust -* Correct interface group registration - -2.3 - -* Create WireGuard devices earlier to allow of to pick up NAT rules correctly -* Consolidate the GUI with regard to WireGuard terminology - -2.2 - -* Add VHID (CARP) tracking support - -2.1 - -* Only reload when interface configuration did not change -* Implement 'newwanip' and 'vpn' plugin facilities -* Refactor dashboard widget - -2.0 - -* Remove wireguard-go support and cleanup some go specific code as it's not being used anymore anyway -* Service control handler similar to OpenVPN, which offers control per instance/interface and keeps track of changed interfaces (configure only restarts the changed ones). -* Add some basic logging for the service handling and a view to inspect it. -* Configuration logs are being flushed to the correct log automatically as mwexecf() sends errors to syslog (which in this scope sends to wireguard) -* Reimplement https://github.com/WireGuard/wireguard-tools/tree/master/contrib/reresolve-dns using Python in reresolve-dns.py -* Enforce wireguard-tools rc script to be disabled when still installed, this should prevent bootup issues -* Move 'interface' calculated field to model for easy reusability -* Move diagnostics to VPN: WireGuard: Diagnostics -* Change keypair generation to a separate API call and form button to ease copy/paste when adding new servers. -* Change plugin maintainer - -1.13 - -* Reworked widget and assorted cleanups (contributed by Patrik Kernstock) -* Improve widget public key overlapping (contributed by Victor Haggqvist) - -1.12 - -* Adjust validation for naming local instance and endpoints - -1.11 - -* Add script for renewal of Wireguard DNS-based entries for stale connections (#2956) -* Trim whitespace around new public and private keys in config (#2982) - -1.10 - -* Remove instance limit - -1.9 - -* Rename interface label in filter rules (#2577) - -1.8 - -* Empty port in Endpoint is allowed - -1.7 - -* Make tunnel address (wg interface address) optional - -1.6 - -* Move DNS setting to advanced -* Make listen port optional - -1.5 - -* Allow synchronization of config - -1.4 - -* Add IPv6 gateway support (contributed by Alexander Korinek) - -1.3 - -* Client/peer name validation to use HostnameField - -1.2 - -* Dashboard widget (contributed by D. Domig) - -1.1 - -* Allow adding interface route for PBR - -1.0 - -* Support for most features like S2S, Roadwarrior -* DNS, MTU, PSK -* Allow to disable setting routes for PBR diff --git a/net/wireguard/src/etc/inc/plugins.inc.d/wireguard.inc b/net/wireguard/src/etc/inc/plugins.inc.d/wireguard.inc deleted file mode 100644 index e935fa4b5..000000000 --- a/net/wireguard/src/etc/inc/plugins.inc.d/wireguard.inc +++ /dev/null @@ -1,194 +0,0 @@ - - * 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. - */ - -function wireguard_enabled() -{ - return (string)(new \OPNsense\Wireguard\General())->enabled == '1'; -} - -function wireguard_services() -{ - $services = []; - - if (!wireguard_enabled()) { - return $services; - } - - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $key => $node) { - if (!empty((string)$node->enabled)) { - $services[] = [ - 'description' => 'WireGuard ' . htmlspecialchars($node->name), - 'configd' => [ - 'start' => ["wireguard start {$key}"], - 'restart' => ["wireguard restart {$key}"], - 'stop' => ["wireguard stop {$key}"], - ], - 'nocheck' => true, /* no daemon to check */ - 'id' => $key, - 'name' => "wireguard" - ]; - } - } - - return $services; -} - -function wireguard_syslog() -{ - return [ - 'wireguard' => ['facility' => ['wireguard']] - ]; -} - -function wireguard_interfaces() -{ - $interfaces = []; - - if (!wireguard_enabled()) { - return $interfaces; - } - - $interfaces['wireguard'] = [ - 'descr' => gettext('WireGuard (Group)'), - 'if' => 'wireguard', - 'virtual' => true, - 'enable' => true, - 'type' => 'group', - 'networks' => [], - ]; - - return $interfaces; -} - -function wireguard_xmlrpc_sync() -{ - $result = []; - - $result['id'] = 'wireguard'; - $result['section'] = 'OPNsense.wireguard'; - $result['description'] = gettext('WireGuard'); - $result['services'] = ['wireguard']; - - return [$result]; -} - -function wireguard_devices() -{ - $names = []; - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $key => $node) { - if (!empty((string)$node->enabled)) { - $names[(string)$node->interface] = [ - 'descr' => sprintf('%s (WireGuard - %s)', (string)$node->interface, (string)$node->name), - 'ifdescr' => (string)$node->name, - 'name' => (string)$node->interface - ]; - } - } - return [[ - 'function' => 'wireguard_prepare', /* XXX only (empty) device creation */ - 'configurable' => false, - 'pattern' => '^wg', - 'type' => 'wireguard', - 'volatile' => true, - 'names' => $names, - ]]; -} - -function wireguard_prepare($device) -{ - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $node) { - if ($device != (string)$node->interface) { - continue; - } - - /* deleting the stat file marks the interface for eventual reconfiguration */ - @unlink((string)$node->statFilename); - - if (!does_interface_exist($device)) { - mwexecf('/sbin/ifconfig wg create name %s', $device); - mwexecf('/sbin/ifconfig %s group wireguard', $device); - } - - return $device; - } - - return null; -} - -function wireguard_configure() -{ - return [ - 'newwanip' => ['wireguard_sync:2'], - 'vpn' => ['wireguard_configure_do:2'], - ]; -} - -function wireguard_configure_do($verbose = false, $unused = '') -{ - if (!wireguard_enabled()) { - return; - } - - service_log('Configuring WireGuard VPN...', $verbose); - - configd_run('wireguard configure'); - - service_log("done.\n", $verbose); -} - -function wireguard_sync($verbose = false, $unused = '') -{ - if (!wireguard_enabled()) { - return; - } - - $instances = []; - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $node) { - if (!empty((string)$node->enabled)) { - $instances[(string)$node->interface] = (string)$node->cnfFilename; - } - } - - if (!count($instances)) { - return; - } - - service_log('Synchronizing WireGuard VPN...', $verbose); - - openlog('wireguard', LOG_ODELAY, LOG_AUTH); - - foreach ($instances as $device => $config) { - mwexecf('/usr/bin/wg syncconf %s %s', [$device, $config]); - } - - closelog(); - reopenlog(); - - service_log("done.\n", $verbose); -} diff --git a/net/wireguard/src/etc/rc.syshook.d/carp/20-wireguard b/net/wireguard/src/etc/rc.syshook.d/carp/20-wireguard deleted file mode 100755 index 5e5e42d67..000000000 --- a/net/wireguard/src/etc/rc.syshook.d/carp/20-wireguard +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -configctl -dq wireguard configure $1 diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php deleted file mode 100644 index 90e4ed4c5..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ClientController.php +++ /dev/null @@ -1,115 +0,0 @@ - - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; -use OPNsense\Core\Config; -use OPNsense\Wireguard\Server; - -class ClientController extends ApiMutableModelControllerBase -{ - protected static $internalModelName = 'client'; - protected static $internalModelClass = '\OPNsense\Wireguard\Client'; - - public function searchClientAction() - { - return $this->searchBase( - 'clients.client', - ["enabled", "name", "pubkey", "tunneladdress", "serveraddress", "serverport"] - ); - } - - public function getClientAction($uuid = null) - { - $result = $this->getBase('client', 'clients.client', $uuid); - if (!empty($result['client'])) { - $result['client']['servers'] = []; - foreach ((new Server())->servers->server->iterateItems() as $key => $node) { - $result['client']['servers'][$key] = [ - 'value' => (string)$node->name, - 'selected' => in_array($uuid, explode(',', (string)$node->peers)) ? '1' : '0' - ]; - } - } - return $result; - } - - public function addClientAction() - { - return $this->setClientAction(null); - } - - public function delClientAction($uuid) - { - return $this->delBase('clients.client', $uuid); - } - - public function setClientAction($uuid) - { - $add_uuid = null; - if (!empty($this->request->getPost(static::$internalModelName)) && $this->request->isPost()) { - $servers = []; - if (!empty($this->request->getPost(static::$internalModelName)['servers'])) { - $servers = explode(',', $this->request->getPost(static::$internalModelName)['servers']); - } - Config::getInstance()->lock(); - $mdl = new Server(); - if (empty($uuid)) { - // add new client, generate uuid - $uuid = $mdl->servers->generateUUID(); - $add_uuid = $uuid; - } - foreach ($mdl->servers->server->iterateItems() as $key => $node) { - $peers = array_filter(explode(',', (string)$node->peers)); - if (in_array($uuid, $peers) && !in_array($key, $servers)) { - $node->peers = implode(',', array_diff($peers, [$uuid])); - } elseif (!in_array($uuid, $peers) && in_array($key, $servers)) { - $node->peers = implode(',', array_merge($peers, [$uuid])); - } - } - /** - * Save to in memory model. - * Ignore validations as $uuid might be new or trigger an existing validation issue. - * Persisting the data is handled by setBase() - */ - $mdl->serializeToConfig(false, true); - } - $result = $this->setBase('client', 'clients.client', $uuid); - if (!empty($add_uuid) && $result['result'] == 'saved') { - $result['uuid'] = $add_uuid; - } - return $result; - } - - public function toggleClientAction($uuid) - { - return $this->toggleBase('clients.client', $uuid); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php deleted file mode 100644 index b461b9f6a..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/GeneralController.php +++ /dev/null @@ -1,139 +0,0 @@ - - * Copyright (C) 2022 Patrik Kernstock - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; -use OPNsense\Core\Config; -use OPNsense\Core\Backend; - -class GeneralController extends ApiMutableModelControllerBase -{ - protected static $internalModelClass = '\OPNsense\Wireguard\General'; - protected static $internalModelName = 'general'; - - /** - * XXX: remove in 24.1 unused - */ - public function getStatusAction() - { - // get wireguard configuration - $config = Config::getInstance()->object(); - $config = $config->OPNsense->wireguard; - - // craft peers array - $peers = []; - $peers_uuid_pubkey = []; - // enabled, name, pubkey - foreach ($config->client->clients->client as $client) { - $peerUuid = (string)$client->attributes()['uuid']; - $peers_uuid_pubkey[$peerUuid] = (string) $client->pubkey; - $peers[$peerUuid] = [ - "name" => (string) $client->name, - "enabled" => (int) $client->enabled, - "publicKey" => (string) $client->pubkey, - ]; - } - - // prepare and initialize the server array - $status = []; - $peer_pubkey_reference = []; - foreach ($config->server->servers->server as $server) { - if ($server->enabled != "1") { - continue; - } - - // build basic server array - $interface = "wg" . $server->instance; - $status[$interface] = [ - "instance" => (int) $server->instance, - "interface" => (string) $interface, - "enabled" => (int) $server->enabled, - "name" => (string) $server->name, - "peers" => [], - ]; - - // parse and add peers with initial values to array - if (strlen($server->peers) > 0) { - // there is at least one peer defined - $serverPeers = explode(",", (string) $server->peers); - // iteriate over each peer uuid - foreach ($serverPeers as $peerUuid) { - // skipping removed peer that is still referenced in server - if (!isset($peers[$peerUuid])) { - continue; - } - // remember interface and pubkey <> peer-uuid reference for referencing handshake logic below - $peer_pubkey_reference[$interface][$peers_uuid_pubkey[$peerUuid]] = $peerUuid; - // merge peer info and initial values for handshake data - $status[$interface]["peers"][$peerUuid] = array_merge( - $peers[$peerUuid], - [ - "lastHandshake" => "0000-00-00 00:00:00+00:00", - ] - ); - } - } - } - - // Get latest handshakes by running CLI command locally - $data = (new Backend())->configdRun("wireguard showhandshake"); - - // parse and set handshake to status datastructure - $data = trim($data); - if (strlen($data) !== 0) { - $wgHandshakes = explode("\n", $data); - foreach ($wgHandshakes as $handshake) { - $item = explode("\t", trim($handshake)); - - // set interface name and publickey - $interface = trim($item[0]); - $pubkey = trim($item[1]); - - // calculate handshake time based on local timezone - $epoch = $item[2]; - if ($epoch > 0) { - $dt = new \DateTime("@$epoch"); - $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); - $latest = $dt->format("Y-m-d H:i:sP"); - - // set handshake - $peerUuid = $peer_pubkey_reference[$interface][$pubkey]; - if (!empty($peerUuid)) { - $status[$interface]["peers"][$peerUuid]["lastHandshake"] = $latest; - } - } - } - } - - return [ - "items" => $status - ]; - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php deleted file mode 100644 index c810dd2ae..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServerController.php +++ /dev/null @@ -1,78 +0,0 @@ - - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableModelControllerBase; -use OPNsense\Core\Backend; - -class ServerController extends ApiMutableModelControllerBase -{ - protected static $internalModelName = 'server'; - protected static $internalModelClass = '\OPNsense\Wireguard\Server'; - - public function keyPairAction() - { - return json_decode((new Backend())->configdRun('wireguard gen_keypair'), true); - } - - public function searchServerAction() - { - $search = $this->searchBase( - 'servers.server', - ["enabled", "instance", "peers", "name", "networks", "pubkey", "port", "tunneladdress", 'interface'] - ); - return $search; - } - - public function getServerAction($uuid = null) - { - return $this->getBase('server', 'servers.server', $uuid); - } - - public function addServerAction($uuid = null) - { - return $this->addBase('server', 'servers.server', $uuid); - } - - public function delServerAction($uuid) - { - return $this->delBase('servers.server', $uuid); - } - - public function setServerAction($uuid = null) - { - return $this->setBase('server', 'servers.server', $uuid); - } - - public function toggleServerAction($uuid) - { - return $this->toggleBase('servers.server', $uuid); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php deleted file mode 100644 index eab399815..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/Api/ServiceController.php +++ /dev/null @@ -1,123 +0,0 @@ - - * 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\Wireguard\Api; - -use OPNsense\Base\ApiMutableServiceControllerBase; -use OPNsense\Core\Backend; -use OPNsense\Wireguard\General; -use OPNsense\Wireguard\Client; -use OPNsense\Wireguard\Server; - -/** - * Class ServiceController - * @package OPNsense\Wireguard - */ -class ServiceController extends ApiMutableServiceControllerBase -{ - protected static $internalServiceClass = '\OPNsense\Wireguard\General'; - protected static $internalServiceTemplate = 'OPNsense/Wireguard'; - protected static $internalServiceEnabled = 'enabled'; - protected static $internalServiceName = 'wireguard'; - - /** - * @return array - */ - public function reconfigureAction() - { - if (!$this->request->isPost()) { - return ['result' => 'failed']; - } - - $this->sessionClose(); - $backend = new Backend(); - $backend->configdRun('interface invoke registration'); - $backend->configdRun('template reload ' . escapeshellarg(static::$internalServiceTemplate)); - $backend->configdpRun('wireguard configure'); - - return ['result' => 'ok']; - } - - /** - * show wireguard config - * XXX: remove in 24.1 - * @return array - */ - public function showconfAction() - { - $response = (new Backend())->configdRun("wireguard showconf"); - return array("response" => $response); - } - - /** - * show wireguard handshakes - * XXX: remove in 24.1 - * @return array - */ - public function showhandshakeAction() - { - $response = (new Backend())->configdRun("wireguard showhandshake"); - return array("response" => $response); - } - - /** - * wg show all dump output - * @return array - */ - public function showAction() - { - $payload = json_decode((new Backend())->configdRun("wireguard show") ?? '', true); - $records = !empty($payload) && !empty($payload['records']) ? $payload['records'] : []; - $key_descriptions = []; - $ifnames = []; - foreach ((new Client())->clients->client->iterateItems() as $key => $client) { - $key_descriptions[(string)$client->pubkey] = (string)$client->name; - } - foreach ((new Server())->servers->server->iterateItems() as $key => $server) { - $key_descriptions[(string)$server->pubkey] = (string)$server->name; - $ifnames[(string)$server->interface] = (string)$server->name; - } - foreach ($records as &$record) { - if (!empty($record['public-key']) && !empty($key_descriptions[$record['public-key']])) { - $record['name'] = $key_descriptions[$record['public-key']]; - } else { - $record['name'] = ''; - } - $record['ifname'] = $ifnames[$record['if']]; - } - $filter_funct = null; - $types = $this->request->get('type'); - if (!empty($types)) { - $filter_funct = function ($record) use ($types) { - return in_array($record['type'], $types); - }; - } - return $this->searchRecordsetBase($records, null, null, $filter_funct); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/DiagnosticsController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/DiagnosticsController.php deleted file mode 100644 index 37f723f53..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/DiagnosticsController.php +++ /dev/null @@ -1,44 +0,0 @@ -view->pick('OPNsense/Wireguard/diagnostics'); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php deleted file mode 100644 index 0683a6e8e..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/GeneralController.php +++ /dev/null @@ -1,39 +0,0 @@ - - * 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\Wireguard; - -class GeneralController extends \OPNsense\Base\IndexController -{ - public function indexAction() - { - $this->view->generalForm = $this->getForm("general"); - $this->view->formDialogEditWireguardClient = $this->getForm("dialogEditWireguardClient"); - $this->view->formDialogEditWireguardServer = $this->getForm("dialogEditWireguardServer"); - $this->view->pick('OPNsense/Wireguard/general'); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml deleted file mode 100644 index ff303f842..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardClient.xml +++ /dev/null @@ -1,58 +0,0 @@ -
- - client.enabled - - checkbox - This will enable or disable the peer. - - - client.name - - text - Set the name for this peer. - - - client.pubkey - - text - Public key of this peer. You can generate the key using the private key piped to "wg pubkey". - - - client.psk - - text - Shared secret (PSK) for this peer. You can generate a key using "wg genpsk". - - - client.tunneladdress - - - select_multiple - true - List of addresses allowed to pass trough the tunnel adapter. Please use CIDR notation like 10.0.0.1/24. - - - client.serveraddress - - text - Set public IP address the endpoint listens to. - - - client.serverport - - text - Set port the endpoint listens to. - - - client.servers - - select_multiple - List of instances this peer belongs to. - - - client.keepalive - - text - Set persistent keepalive interval in seconds. - -
diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml deleted file mode 100644 index 3b23f056f..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/dialogEditWireguardServer.xml +++ /dev/null @@ -1,87 +0,0 @@ -
- - server.enabled - - checkbox - This will enable or disable the instance. - - - server.name - - text - Set the name for this instance. - - - server.instance - - info - This is the instance number to give the WireGuard device a unique name (wgX). - - - server.pubkey - - text - Public key of this instance. You can specify your own one, or a key will be generated after saving. - - - server.privkey - - text - Private key of this instance. You can specify your own one, or a key will be generated after saving. Please keep this key safe. - - - server.port - - text - Optionally set a fixed port for this instance to listen on. The standard port range starts at 51820. - - - server.mtu - - text - true - Set a specific device MTU for this instance. - - - server.dns - - select_multiple - - true - true - Set specific DNS servers for this instance. Use with care. - - - server.tunneladdress - - - select_multiple - true - List of addresses to configure on the device. Please use CIDR notation like 10.0.0.1/24. - - - server.carp_depend_on - - dropdown - The CARP VHID to depend on. When this virtual address is not in master state, then the instance will be shutdown. - - - server.peers - - select_multiple - List of peers for this instance. - - - server.disableroutes - - checkbox - This will prevent installing routes. Usually you only enable this to do own routing decisions via a local gateway and gateway rules. - - - server.gateway - - text - true - Set the gateway IP here when using "Disable routes" feature. You also have to add this as a system gateway. - -
diff --git a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml b/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml deleted file mode 100644 index 7a74ebf81..000000000 --- a/net/wireguard/src/opnsense/mvc/app/controllers/OPNsense/Wireguard/forms/general.xml +++ /dev/null @@ -1,8 +0,0 @@ -
- - general.enabled - - checkbox - This will activate WireGuard and start all enabled instances. - -
diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml deleted file mode 100644 index 94360e776..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/ACL/ACL.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - VPN: WireGuard - - ui/wireguard/* - api/wireguard/* - - - diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php deleted file mode 100644 index fbe1917bf..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.php +++ /dev/null @@ -1,35 +0,0 @@ - - * 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class Client extends BaseModel -{ -} diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml deleted file mode 100644 index 82c24d1d5..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Client.xml +++ /dev/null @@ -1,36 +0,0 @@ - - //OPNsense/wireguard/client - WireGuard peer configuration - 0.0.7 - - - - - 1 - Y - - - Y - /^([0-9a-zA-Z._\-]){1,64}$/u - Should be a string between 1 and 64 characters. Allowed characters are alphanumeric characters, dash and underscores. - - - Y - - - - , - Y - Y - - - - - 1 - 86400 - Please specify a value between 1 and 86400. - - - - - diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/FieldTypes/ServerField.php b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/FieldTypes/ServerField.php deleted file mode 100644 index a327af5fb..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/FieldTypes/ServerField.php +++ /dev/null @@ -1,58 +0,0 @@ -internalChildnodes as $node) { - if (!$node->getInternalIsVirtual()) { - $files = [ - 'cnfFilename' => "/usr/local/etc/wireguard/wg{$node->instance}.conf", - 'statFilename' => "/usr/local/etc/wireguard/wg{$node->instance}.stat", - 'interface' => "wg{$node->instance}", - ]; - foreach ($files as $name => $payload) { - $new_item = new TextField(); - $new_item->setInternalIsVirtual(); - $new_item->setValue($payload); - $node->addChildNode($name, $new_item); - } - } - } - return parent::actionPostLoadingEvent(); - } -} diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php deleted file mode 100644 index 09358565a..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.php +++ /dev/null @@ -1,35 +0,0 @@ - - * 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class General extends BaseModel -{ -} diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml deleted file mode 100644 index 1868a8885..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/General.xml +++ /dev/null @@ -1,11 +0,0 @@ - - //OPNsense/wireguard/general - WireGuard configuration - 0.0.1 - - - 0 - Y - - - diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml deleted file mode 100644 index f2c15f406..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Menu/Menu.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php deleted file mode 100644 index 6b4c136ef..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.php +++ /dev/null @@ -1,35 +0,0 @@ - - * 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\Wireguard; - -use OPNsense\Base\BaseModel; - -class Server extends BaseModel -{ -} diff --git a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml b/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml deleted file mode 100644 index 3fe0a0153..000000000 --- a/net/wireguard/src/opnsense/mvc/app/models/OPNsense/Wireguard/Server.xml +++ /dev/null @@ -1,73 +0,0 @@ - - //OPNsense/wireguard/server - WireGuard instance configuration - 0.0.4 - - - - - 1 - Y - - - Y - /^([0-9a-zA-Z._\-]){1,64}$/u - Should be a string between 1 and 64 characters. Allowed characters are alphanumeric characters, dash and underscores. - - - Y - - - Y - A public key is required - - - Y - A private key is required - - - - 1 - 9300 - - - /^([a-fA-F0-9\.:\[\]]*?,)*([a-fA-F0-9\.:\[\]]*)$/ - Please use valid IPv4 or IPv6 addresses. - - - , - Y - - - 0 - Y - - - You have to enable Disable Routes option. - DependConstraint - - gateway - - - - - - - carp - mvc - - - - - - Y - Choose an Peer. - - - - - diff --git a/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/diagnostics.volt b/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/diagnostics.volt deleted file mode 100644 index 1f812c463..000000000 --- a/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/diagnostics.volt +++ /dev/null @@ -1,97 +0,0 @@ -{# - # Copyright (c) 2023 Deciso B.V. - # 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. - #} - - - -
- - - - - - - - - - - - - - - - - -
{{ lang._('Device') }}{{ lang._('Type') }}{{ lang._('Status') }}{{ lang._('Public key') }}{{ lang._('Name') }}{{ lang._('Port / Endpoint') }}{{ lang._('Handshake') }}{{ lang._('Send') }}{{ lang._('Received') }}
-
diff --git a/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt b/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt deleted file mode 100644 index 5cc1f6d62..000000000 --- a/net/wireguard/src/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt +++ /dev/null @@ -1,173 +0,0 @@ -{# - # Copyright (c) 2014-2023 Deciso B.V. - # Copyright (c) 2018 Michael Muenz - # 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. - #} - - - - - - -
-
- {{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}} -
-
- - - - - - - - - - - - - - - - - - - - - -
{{ lang._('ID') }}{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Endpoint address') }}{{ lang._('Endpoint port') }}{{ lang._('Allowed IPs') }}{{ lang._('ID') }}{{ lang._('Commands') }}
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
{{ lang._('ID') }}{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Device') }}{{ lang._('Tunnel Address') }}{{ lang._('Port') }}{{ lang._('Peers') }}{{ lang._('ID') }}{{ lang._('Commands') }}
- - -
-
-
- -
-
-
-
- -

-
-
-
- -{{ partial("layout_partials/base_dialog",['fields':formDialogEditWireguardClient,'id':'dialogEditWireguardClient','label':lang._('Edit peer')])}} -{{ partial("layout_partials/base_dialog",['fields':formDialogEditWireguardServer,'id':'dialogEditWireguardServer','label':lang._('Edit instance')])}} diff --git a/net/wireguard/src/opnsense/scripts/Wireguard/gen_keypair.py b/net/wireguard/src/opnsense/scripts/Wireguard/gen_keypair.py deleted file mode 100755 index beada99c7..000000000 --- a/net/wireguard/src/opnsense/scripts/Wireguard/gen_keypair.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/local/bin/python3 - -""" - Copyright (c) 2023 Ad Schellevis - 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. -""" -import subprocess -import ujson - - -def keypair(): - sp = subprocess.run(['/usr/bin/wg', 'genkey'], capture_output=True, text=True) - if sp.returncode == 0: - privkey = sp.stdout.strip() - sp = subprocess.run(['/usr/bin/wg', 'pubkey'], input=privkey, capture_output=True, text=True) - if sp.returncode == 0: - return {'privkey': privkey, 'pubkey': sp.stdout.strip()} - return None - -response = keypair() -if not response: - print(ujson.dumps({'status': 'failed'})) -else: - response['status'] = 'ok' - print(ujson.dumps(response)) diff --git a/net/wireguard/src/opnsense/scripts/Wireguard/reresolve-dns.py b/net/wireguard/src/opnsense/scripts/Wireguard/reresolve-dns.py deleted file mode 100755 index 219f6d5f2..000000000 --- a/net/wireguard/src/opnsense/scripts/Wireguard/reresolve-dns.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/local/bin/python3 - -""" - Copyright (c) 2023 Ad Schellevis - 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. -""" -# Python implementation to re-resolve dns entries, for reference see: -# https://github.com/WireGuard/wireguard-tools/tree/master/contrib/reresolve-dns -import glob -import os -import time -import subprocess - - - -sp = subprocess.run(['/usr/bin/wg', 'show', 'all', 'latest-handshakes'], capture_output=True, text=True) -ts_now = time.time() -handshakes = {} -for line in sp.stdout.split('\n'): - parts = line.split() - if len(parts) == 3 and parts[2].isdigit(): - handshakes["%s-%s" % (parts[0], parts[1])] = ts_now - int(parts[2]) - - -for filename in glob.glob('/usr/local/etc/wireguard/*.conf'): - this_peer = {} - ifname = os.path.basename(filename).split('.')[0] - with open(filename, 'r') as fhandle: - for line in fhandle: - if line.startswith('[Peer]'): - this_peer = {'ifname': ifname} - elif line.startswith('PublicKey'): - this_peer['PublicKey'] = line.split('=', 1)[1].strip() - elif line.startswith('Endpoint'): - this_peer['Endpoint'] = line.split('=', 1)[1].strip() - - if 'Endpoint' in this_peer and 'PublicKey' in this_peer: - peer_key = "%(ifname)s-%(PublicKey)s" % this_peer - if handshakes.get(peer_key, 999) > 135: - # skip if there has been a handshake recently - subprocess.run( - [ - '/usr/bin/wg', - 'set', - ifname, - 'peer', - this_peer['PublicKey'], - 'endpoint', - this_peer['Endpoint'] - ], - capture_output=True, - text=True - ) - this_peer = {} diff --git a/net/wireguard/src/opnsense/scripts/Wireguard/wg-service-control.php b/net/wireguard/src/opnsense/scripts/Wireguard/wg-service-control.php deleted file mode 100755 index b0cd9c13d..000000000 --- a/net/wireguard/src/opnsense/scripts/Wireguard/wg-service-control.php +++ /dev/null @@ -1,303 +0,0 @@ -#!/usr/local/bin/php -vip->iterateItems() as $id => $item) { - if ($item->mode == 'carp') { - $uuids[(string)$item->vhid] = $id; - $vhids[$id] = ['status' => 'DISABLED', 'vhid' => (string)$item->vhid]; - } - } - foreach (legacy_interfaces_details() as $ifdata) { - if (!empty($ifdata['carp'])) { - foreach ($ifdata['carp'] as $data) { - if (isset($uuids[$data['vhid']])) { - $vhids[$uuids[$data['vhid']]] = ['status' => $data['status'], 'vhid' => $data['vhid']]; - } - } - } - } - return $vhids; -} - - -/** - * mimic wg-quick behaviour, but bound to our config - */ -function wg_start($server, $fhandle, $ifcfgflag = 'up') -{ - if (!does_interface_exist($server->interface)) { - mwexecf('/sbin/ifconfig wg create name %s', [$server->interface]); - mwexecf('/sbin/ifconfig %s group wireguard', [$server->interface]); - } - mwexecf('/usr/bin/wg syncconf %s %s', [$server->interface, $server->cnfFilename]); - - /* The tunneladdress can be empty, so array_filter without callback filters empty strings out. */ - foreach (array_filter(explode(',', (string)$server->tunneladdress)) as $alias) { - $proto = strpos($alias, ':') === false ? "inet" : "inet6"; - mwexecf('/sbin/ifconfig %s %s %s alias', [$server->interface, $proto, $alias]); - } - if (!empty((string)$server->mtu)) { - mwexecf('/sbin/ifconfig %s mtu %s', [$server->interface, $server->mtu]); - } - mwexecf('/sbin/ifconfig %s %s', [$server->interface, $ifcfgflag]); - - if (empty((string)$server->disableroutes)) { - /** - * Add routes for all configured peers, wg-quick seems to parse 'wg show wgX allowed-ips' for this, - * but this should logically congtain the same networks. - * - * XXX: For some reason these routes look a bit off, not very well integrated into OPNsense. - * In the long run it might make sense to have some sort of pluggable model facility - * where these (and maybe other) static routes hook into. - **/ - $peers = explode(',', $server->peers); - $routes_to_add = ['inet' => [], 'inet6' => []]; - foreach ((new OPNsense\Wireguard\Client())->clients->client->iterateItems() as $key => $client) { - if (empty((string)$client->enabled) || !in_array($key, $peers)) { - continue; - } - foreach (explode(',', (string)$client->tunneladdress) as $tunneladdress) { - $ipproto = strpos($tunneladdress, ":") === false ? "inet" : "inet6"; - /* wg-quick seems to prevent /0 being routed and translates this automatically */ - if (str_ends_with(trim($tunneladdress), '/0')) { - if ($ipproto == 'inet') { - array_push($routes_to_add[$ipproto], '0.0.0.0/1', '128.0.0.0/1'); - } else { - array_push($routes_to_add[$ipproto], '::/1', '8000::/1'); - } - } else { - $routes_to_add[$ipproto][] = $tunneladdress; - } - } - } - foreach ($routes_to_add as $ipproto => $routes) { - foreach (array_unique($routes) as $route) { - mwexecf('/sbin/route -q -n add -%s %s -interface %s', [$ipproto, $route, $server->interface]); - } - } - } elseif (!empty((string)$server->gateway)) { - /* Only bind the gateway ip to the tunnel */ - $ipprefix = strpos($tunneladdress, ":") === false ? "-4" : "-6"; - mwexecf('/sbin/route -q -n add %s %s -iface %s', [$ipprefix, $server->gateway, $server->interface]); - } - - // flush checksum to ease change detection - fseek($fhandle, 0); - ftruncate($fhandle, 0); - fwrite($fhandle, @md5_file($server->cnfFilename) . "|" . wg_reconfigure_hash($server)); - syslog(LOG_NOTICE, "wireguard instance {$server->name} ({$server->interface}) started"); - interfaces_restart_by_device(false, [(string)$server->interface], false); -} - -/** - * stop wireguard tunnel, kill the device, the routes should drop automatically. - */ -function wg_stop($server) -{ - if (does_interface_exist($server->interface)) { - legacy_interface_destroy($server->interface); - } - syslog(LOG_NOTICE, "wireguard instance {$server->name} ({$server->interface}) stopped"); -} - - -/** - * Calculate a hash which determines if we are able to reconfigure without a restart of the tunnel. - * We currently assume if something changed on the interface or peer routes are being pushed, it's safer to - * restart then reload. - */ -function wg_reconfigure_hash($server) -{ - if (empty((string)$server->disableroutes)) { - return md5(uniqid('', true)); // random hash, should always reconfigure - } - return md5( - sprintf( - '%s|%s|%s', - $server->tunneladdress, - $server->mtu, - $server->gateway - ) - ); -} - -/** - * The stat hash file answers two questions, [1] has anything changed, which is answered using an md5 hash of the - * configuration file. The second question, if something has changed, is it safe to only reload the configuration. - * This is answered by wg_reconfigure_hash() for the instance in question. - */ -function get_stat_hash($fhandle) -{ - fseek($fhandle, 0); - $payload = stream_get_contents($fhandle) ?? ''; - $parts = explode('|', $payload); - return [ - 'file' => $parts[0] ?? '', - 'interface' => $parts[1] ?? '' - ]; -} - -$opts = getopt('ah', [], $optind); -$args = array_slice($argv, $optind); - -/* setup syslog logging */ -openlog("wireguard", LOG_ODELAY, LOG_AUTH); - -if (isset($opts['h']) || empty($args) || !in_array($args[0], ['start', 'stop', 'restart', 'configure'])) { - echo "Usage: wg-service-control.php [-a] [-h] [stop|start|restart|configure] [uuid|vhid]\n\n"; - echo "\t-a all instances\n"; -} elseif (isset($opts['a']) || !empty($args[1])) { - // either a server id (uuid) or a vhid could be offered - $server_id = $vhid = null; - if (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $args[1] ?? '') == 1) { - $server_id = $args[1]; - } elseif (!empty($args[1])) { - $vhid = explode('@', $args[1])[0]; - } - - $action = $args[0]; - - $server_devs = []; - if (!empty((string)(new OPNsense\Wireguard\General())->enabled)) { - $vhids = get_vhid_status(); - foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $key => $node) { - $carp_depend_on = (string)$node->carp_depend_on; - if (empty((string)$node->enabled)) { - continue; - } elseif ($server_id != null && $key != $server_id) { - continue; - } elseif ($vhid != null && (!empty($vhids[$carp_depend_on]) && $vhids[$carp_depend_on]['vhid'] != $vhid)) { - continue; - } - /** - * CARP may influence the interface status (up or down). - * In order to fluently switch between roles, one should only have to change the interface flag in this - * case, which means we can still reconfigure an interface in the usual way and just omit sending traffic - * when in BACKUP or INIT mode. - */ - $carp_if_flag = 'up'; - if (!empty($vhids[$carp_depend_on]) && $vhids[$carp_depend_on]['status'] != 'MASTER') { - $carp_if_flag = 'down'; - } - $server_devs[] = (string)$node->interface; - $statHandle = fopen($node->statFilename, "a+"); - if (flock($statHandle, LOCK_EX)) { - $ifdetails = legacy_interfaces_details((string)$node->interface); - switch ($action) { - case 'stop': - wg_stop($node); - break; - case 'start': - wg_start($node, $statHandle, $carp_if_flag); - break; - case 'restart': - wg_stop($node); - wg_start($node, $statHandle, $carp_if_flag); - break; - case 'configure': - $ifstatus = '-'; - if (!empty($ifdetails[(string)$node->interface])) { - $ifstatus = in_array('up', $ifdetails[(string)$node->interface]['flags']) ? 'up' : 'down'; - } - - if (!empty($carp_depend_on) && !empty($vhid)) { - // CARP event traceability when a vhid is being passed - syslog( - LOG_NOTICE, - sprintf( - "Wireguard configure event instance %s (%s) vhid: %s carp: %s interface: %s", - $node->name, - $node->interface, - $vhid, - !empty($vhids[$carp_depend_on]) ? $vhids[$carp_depend_on]['status'] : '-', - $ifstatus - ) - ); - } - if ( - @md5_file($node->cnfFilename) != get_stat_hash($statHandle)['file'] || - empty($ifdetails[(string)$node->interface]) - ) { - if (get_stat_hash($statHandle)['interface'] != wg_reconfigure_hash($node)) { - // Fluent reloading not supported for this instance, make sure the user is informed - syslog( - LOG_NOTICE, - "wireguard instance {$node->name} ({$node->interface}) " . - "can not reconfigure without stopping it first." - ); - wg_stop($node); - } - wg_start($node, $statHandle, $carp_if_flag); - } else { - // when triggered via a CARP event, check our interface status [UP|DOWN] - if ($ifstatus != $carp_if_flag) { - mwexecf('/sbin/ifconfig %s %s', [$node->interface, $carp_if_flag]); - } - } - break; - } - flock($statHandle, LOCK_UN); - } - fclose($statHandle); - } - } - - /** - * When -a is specified, cleanup up old or disabled instances (files and interfaces) - */ - if ($server_id == null && $vhid == null) { - foreach (glob('/usr/local/etc/wireguard/wg*') as $filename) { - $this_dev = explode('.', basename($filename))[0]; - if (!in_array($this_dev, $server_devs)) { - @unlink($filename); - if (does_interface_exist($this_dev)) { - legacy_interface_destroy($this_dev); - } - } - } - } - - if (count($server_devs)) { - configd_run('filter reload'); /* XXX required for NAT rules, but needs coalescing */ - } -} -closelog(); diff --git a/net/wireguard/src/opnsense/scripts/Wireguard/wg_show.py b/net/wireguard/src/opnsense/scripts/Wireguard/wg_show.py deleted file mode 100755 index 987efb443..000000000 --- a/net/wireguard/src/opnsense/scripts/Wireguard/wg_show.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/local/bin/python3 - -""" - Copyright (c) 2023 Ad Schellevis - 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. -""" -import subprocess -import ujson - - -interfaces = {} -for line in subprocess.run(['/sbin/ifconfig'], capture_output=True, text=True).stdout.split("\n"): - if not line.startswith('\t') and line.find('<') > -1: - ifname = line.split(':')[0] - interfaces[ifname] = 'up' if 'UP' in line.split('<')[1].split('>')[0].split(',') else 'down' - -sp = subprocess.run(['/usr/bin/wg', 'show', 'all', 'dump'], capture_output=True, text=True) -result = {'records': []} -if sp.returncode == 0: - for line in sp.stdout.split("\n"): - record = {} - parts = line.split("\t") - # parse fields as explained in 'man wg' - record['if'] = parts[0] if len(parts) else None - if len(parts) == 5: - # intentially skip private key, should not expose it - record['type'] = 'interface' - record['public-key'] = parts[2] - record['listen-port'] = parts[3] - record['fwmark'] = parts[4] - # convenience, copy listen-port to endpoint - record['endpoint'] = parts[3] - record['status'] = interfaces.get(record['if'], 'down') - elif len(parts) == 9: - record['type'] = 'peer' - record['public-key'] = parts[1] - # intentially skip preshared-key, should not expose it - record['endpoint'] = parts[3] - record['allowed-ips'] = parts[4] - record['latest-handshake'] = int(parts[5]) if parts[5].isdigit() else 0 - record['transfer-rx'] = int(parts[6]) if parts[6].isdigit() else 0 - record['transfer-tx'] = int(parts[7]) if parts[7].isdigit() else 0 - record['persistent-keepalive'] = parts[8] - else: - continue - result['records'].append(record) - result['status'] = 'ok' -else: - result['status'] = 'failed' - -print(ujson.dumps(result)) diff --git a/net/wireguard/src/opnsense/service/conf/actions.d/actions_wireguard.conf b/net/wireguard/src/opnsense/service/conf/actions.d/actions_wireguard.conf deleted file mode 100644 index 555afb2cd..000000000 --- a/net/wireguard/src/opnsense/service/conf/actions.d/actions_wireguard.conf +++ /dev/null @@ -1,54 +0,0 @@ -[start] -command:/usr/local/opnsense/scripts/Wireguard/wg-service-control.php -parameters: start %s -type:script -message: start wireguard instance %s - -[stop] -command:/usr/local/opnsense/scripts/Wireguard/wg-service-control.php -parameters: stop %s -type:script -message: stop wireguard instance %s - -[restart] -command:/usr/local/opnsense/scripts/Wireguard/wg-service-control.php -parameters: restart %s -type:script -message: restart wireguard instance %s - -[configure] -command:/usr/local/opnsense/scripts/Wireguard/wg-service-control.php -parameters: -a configure %s -type:script -message: configure wireguard instances (%s) - -[renew] -command:/usr/local/opnsense/scripts/Wireguard/reresolve-dns.py -parameters: -type:script -message:Renew DNS for WireGuard -description:Renew DNS for WireGuard on stale connections - -[gen_keypair] -command:/usr/local/opnsense/scripts/Wireguard/gen_keypair.py -parameters: -type:script_output -message:Generating WireGuard keypair - -[show] -command:/usr/local/opnsense/scripts/Wireguard/wg_show.py -parameters: -type:script_output -message:show WireGuard statistics [dump] - -[showconf] -command:/usr/bin/wg show all -parameters: -type:script_output -message:Show WireGuard config - -[showhandshake] -command:/usr/bin/wg show all latest-handshakes -parameters: -type:script_output -message:Show WireGuard handshakes diff --git a/net/wireguard/src/opnsense/service/templates/OPNsense/Syslog/local/wireguard.conf b/net/wireguard/src/opnsense/service/templates/OPNsense/Syslog/local/wireguard.conf deleted file mode 100644 index c3ec362d4..000000000 --- a/net/wireguard/src/opnsense/service/templates/OPNsense/Syslog/local/wireguard.conf +++ /dev/null @@ -1,6 +0,0 @@ -################################################################### -# Local syslog-ng configuration filter definition [wireguard]. -################################################################### -filter f_local_wireguard { - program("wireguard"); -}; diff --git a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS b/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS deleted file mode 100644 index 655def7d1..000000000 --- a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/+TARGETS +++ /dev/null @@ -1,2 +0,0 @@ -wireguard:/etc/rc.conf.d/wireguard -wireguard-server.conf:/usr/local/etc/wireguard/wg[OPNsense.wireguard.server.servers.server.%.instance].conf diff --git a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard b/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard deleted file mode 100644 index 40a3c2f45..000000000 --- a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard +++ /dev/null @@ -1,2 +0,0 @@ -# disable the wireguard rc scripts when installed, bootup handled via rc.syshook -wireguard_enable="NO" diff --git a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf b/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf deleted file mode 100644 index 3c78652de..000000000 --- a/net/wireguard/src/opnsense/service/templates/OPNsense/Wireguard/wireguard-server.conf +++ /dev/null @@ -1,48 +0,0 @@ -{% if helpers.exists('OPNsense.wireguard.general.enabled') and OPNsense.wireguard.general.enabled == '1' %} -{% if helpers.exists('OPNsense.wireguard.server.servers.server') %} -{% for server_list in helpers.toList('OPNsense.wireguard.server.servers.server') %} -{% if TARGET_FILTERS['OPNsense.wireguard.server.servers.server.' ~ loop.index0] or TARGET_FILTERS['OPNsense.wireguard.server.servers.server'] %} -{% if server_list.enabled == '1' %} -#################################################### -# Interface settings, not used by `wg` # -# Only used for reference and detection of changes # -# in the configuration # -#################################################### -# Address = {{server_list.tunneladdress|default('')}} -# DNS = {{ server_list.dns|default('')}} -# MTU = {{ server_list.mtu|default('') }} -# disableroutes = {{server_list.disableroutes}} -# gateway = {{server_list.gateway}} - -[Interface] -PrivateKey = {{ server_list.privkey }} -{% if server_list.port|default('') != '' %} -ListenPort = {{ server_list.port }} -{% endif %} -{% if server_list.peers|default('') != '' %} -{% for peerlist in server_list.peers.split(",") %} -{% set peerlist2_data = helpers.getUUID(peerlist) %} -{% if peerlist2_data != {} and peerlist2_data.enabled == '1' %} - -[Peer] -# friendly_name = {{ peerlist2_data.name }} -PublicKey = {{ peerlist2_data.pubkey }} -{% if peerlist2_data.psk|default('') != '' %} -PresharedKey = {{ peerlist2_data.psk }} -{% endif %} -{% if peerlist2_data.serveraddress|default('') != '' %} -Endpoint = {{ peerlist2_data.serveraddress }}{% if peerlist2_data.serverport|default('') != '' %}:{{ peerlist2_data.serverport }}{% else %}:51820{% endif %} -{% endif %} - -AllowedIPs = {{ peerlist2_data.tunneladdress }} -{% if peerlist2_data.keepalive|default('') != '' %} -PersistentKeepalive = {{ peerlist2_data.keepalive }} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/net/wireguard/src/www/widgets/include/wireguard.inc b/net/wireguard/src/www/widgets/include/wireguard.inc deleted file mode 100644 index f1bae7fe4..000000000 --- a/net/wireguard/src/www/widgets/include/wireguard.inc +++ /dev/null @@ -1,4 +0,0 @@ - - * 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. - */ -?> - - - - - - - - - - - - - - - - - -
- - - - - diff --git a/sysutils/api-backup/Makefile b/sysutils/api-backup/Makefile deleted file mode 100644 index 759fd29cc..000000000 --- a/sysutils/api-backup/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -PLUGIN_NAME= api-backup -PLUGIN_VERSION= 1.1 -PLUGIN_OBSOLETE= yes -PLUGIN_COMMENT= EoL, core endpoint is /api/core/backup/download/this -PLUGIN_MAINTAINER= franz.fabian.94@gmail.com - -.include "../../Mk/plugins.mk" diff --git a/sysutils/api-backup/pkg-descr b/sysutils/api-backup/pkg-descr deleted file mode 100644 index 2a2a1cfe6..000000000 --- a/sysutils/api-backup/pkg-descr +++ /dev/null @@ -1,12 +0,0 @@ -Provide the functionality to download the config.xml - -Plugin Changelog -================ - -1.1 - -* add json download functionality - -1.0 - -* initial release diff --git a/sysutils/api-backup/src/opnsense/mvc/app/controllers/OPNsense/Backup/Api/BackupController.php b/sysutils/api-backup/src/opnsense/mvc/app/controllers/OPNsense/Backup/Api/BackupController.php deleted file mode 100644 index d23675582..000000000 --- a/sysutils/api-backup/src/opnsense/mvc/app/controllers/OPNsense/Backup/Api/BackupController.php +++ /dev/null @@ -1,90 +0,0 @@ - $status, - 'filename' => 'config.xml', - 'filetype' => 'application/xml', - 'content' => base64_encode($data), - ); - return $response; - } else { - $this->response->setStatusCode(200, "OK"); - $this->response->setContentType('application/xml', 'UTF-8'); - $this->response->setHeader("Content-Disposition", "attachment; filename=\"config.xml\""); - $data = file_get_contents(self::CONFIG_XML); - $this->response->setContent($data); - } - } - - /** - * process API results, serialize return data to json. - * @param $dispatcher - * @return string json data - */ - public function afterExecuteRoute($dispatcher) - { - // check if reponse headers are already set - if ($this->response->getHeaders()->get("Status") != null) { - // Headers already set, send unmodified response. - } else { - // process response, serialize to json object - $data = $dispatcher->getReturnedValue(); - if (is_array($data)) { - $this->response->setContentType('application/json', 'UTF-8'); - if ($this->isExternalClient()) { - $this->response->setContent(json_encode($data)); - } else { - $this->response->setContent(htmlspecialchars(json_encode($data), ENT_NOQUOTES)); - } - } - } - - return $this->response->send(); - } -} diff --git a/sysutils/api-backup/src/opnsense/mvc/app/models/OPNsense/Backup/ACL/ACL.xml b/sysutils/api-backup/src/opnsense/mvc/app/models/OPNsense/Backup/ACL/ACL.xml deleted file mode 100644 index 2a1b83765..000000000 --- a/sysutils/api-backup/src/opnsense/mvc/app/models/OPNsense/Backup/ACL/ACL.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Backup API - - api/backup/* - - -