Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions net/ndp-proxy-go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PLUGIN_NAME= ndp-proxy-go
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= IPv6 Neighbor Discovery Protocol Proxy
PLUGIN_MAINTAINER= [email protected]
PLUGIN_DEPENDS= ndp-proxy-go

.include "../../Mk/plugins.mk"
8 changes: 8 additions & 0 deletions net/ndp-proxy-go/pkg-descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
IPv6 Neighbor Discovery (ND), Router Advertisement (RA) and Duplicate Address Detection (DAD) Proxy

Plugin Changelog
================

0.1

* Initial Release
66 changes: 66 additions & 0 deletions net/ndp-proxy-go/src/etc/inc/plugins.inc.d/ndpproxy.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/*
* Copyright (C) 2025 Cedrik Pischem
* 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 ndpproxy_services()
{
global $config;

$services = [];

if (
isset($config['OPNsense']['ndpproxy']['general']['enabled']) &&
$config['OPNsense']['ndpproxy']['general']['enabled'] == 1
) {
$services[] = [
'description' => gettext('NDP Proxy'),
'configd' => [
'start' => ['ndpproxy start'],
'restart' => ['ndpproxy restart'],
'stop' => ['ndpproxy stop'],
],
'name' => 'ndpproxy',
'pidfile' => '/var/run/ndp_proxy_go.pid'
];
}

return $services;
}

function ndpproxy_xmlrpc_sync()
{
$result = [];

$result[] = array(
'description' => gettext('NDP Proxy'),
'section' => 'OPNsense.ndpproxy',
'id' => 'ndpproxy',
'services' => ["ndpproxy"],
);

return $result;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Copyright (C) 2025 Cedrik Pischem
*
* 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\NdpProxy\Api;

use OPNsense\Base\ApiMutableModelControllerBase;
use OPNsense\Core\Config;

class GeneralController extends ApiMutableModelControllerBase
{
protected static $internalModelName = 'ndpproxy';
protected static $internalModelClass = 'OPNsense\NdpProxy\NdpProxy';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Copyright (C) 2025 Cedrik Pischem
*
* 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\NdpProxy\Api;

use OPNsense\Base\ApiMutableServiceControllerBase;

class ServiceController extends ApiMutableServiceControllerBase
{
protected static $internalServiceClass = '\OPNsense\NdpProxy\NdpProxy';
protected static $internalServiceTemplate = 'OPNsense/NdpProxy';
protected static $internalServiceEnabled = 'general.enabled';
protected static $internalServiceName = 'ndpproxy';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Copyright (C) 2025 Cedrik Pischem
*
* 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\NdpProxy;

use OPNsense\Base\IndexController;

class GeneralController extends IndexController
{
public function indexAction()
{
$this->view->pick('OPNsense/NdpProxy/general');
$this->view->generalForm = $this->getForm("general");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<form>
<field>
<type>header</type>
<label>General Settings</label>
</field>
<field>
<id>ndpproxy.general.enabled</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable or disable this service.</help>
</field>
<field>
<type>header</type>
<label>Proxy Settings</label>
</field>
<field>
<id>ndpproxy.general.upstream</id>
<label>Upstream interface</label>
<type>dropdown</type>
<help>Choose the upstream interface which receives the external IPv6 prefix from the ISP. Usually, this is the WAN interface.</help>
</field>
<field>
<id>ndpproxy.general.downstream</id>
<label>Downstream interfaces</label>
<type>select_multiple</type>
<help>Choose one or multiple downstream interfaces which should proxy the upstream IPv6 prefix.</help>
</field>
<field>
<id>ndpproxy.general.ra</id>
<label>Proxy router advertisements</label>
<type>checkbox</type>
<help>Proxy upstream RAs to downstream interfaces. Disable this if you use your own RA daemon.</help>
</field>
<field>
<id>ndpproxy.general.routes</id>
<label>Install host routes</label>
<type>checkbox</type>
<help>Automatically create host routes for discovered clients. Disabling this means you must manually handle all routing decisions.</help>
</field>
<field>
<type>header</type>
<label>Performance Settings</label>
<collapse>true</collapse>
</field>
<field>
<id>ndpproxy.general.cache_ttl</id>
<label>Neighbor cache lifetime</label>
<type>text</type>
<hint>10</hint>
<help>Neighbor cache lifetime in minutes.</help>
</field>
<field>
<id>ndpproxy.general.cache_max</id>
<label>Maximum learned neighbors</label>
<type>text</type>
<hint>4096</hint>
<help>Maximum learned neighbors, increase for large networks.</help>
</field>
<field>
<id>ndpproxy.general.route_qps</id>
<label>Max route operations</label>
<type>text</type>
<hint>50</hint>
<help>Max route operations per second, increase for large networks.</help>
</field>
<field>
<id>ndpproxy.general.pcap_timeout</id>
<label>Packet capture timeout</label>
<type>text</type>
<hint>50</hint>
<help>Controls CPU usage vs. NDP responsiveness. Lower values (e.g., 25 ms) minimize latency during cache refresh at the cost of more CPU. Higher values (100–250 ms) reduce CPU use but may introduce small latency spikes.</help>
</field>
<field>
<id>ndpproxy.general.debug</id>
<label>Debug log</label>
<type>checkbox</type>
<help>Enable debug logging.</help>
</field>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<acl>
<page-ndp-proxy-general>
<name>Services: NDP Proxy: General Settings</name>
<description>Allow access to NDP Proxy General Settings</description>
<patterns>
<pattern>ui/ndpproxy/general/*</pattern>
<pattern>api/ndpproxy/general/*</pattern>
</patterns>
</page-ndp-proxy-general>
<page-ndp-proxy-log>
<name>Services: NDP Proxy: Log File</name>
<patterns>
<pattern>ui/diagnostics/log/core/ndpproxy/*</pattern>
<pattern>api/diagnostics/log/core/ndpproxy/*</pattern>
</patterns>
</page-ndp-proxy-log>
</acl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<menu>
<Services>
<ndpproxy VisibleName="NDP Proxy" cssClass="fa fa-bullseye fa-fw">
<Settings order="10" url="/ui/ndpproxy/general"/>
<Log VisibleName="Log File" order="20" url="/ui/diagnostics/log/core/ndpproxy"/>
</ndpproxy>
</Services>
</menu>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* Copyright (C) 2025 Cedrik Pischem
*
* 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\NdpProxy;

use OPNsense\Base\BaseModel;
use OPNsense\Base\Messages\Message;

class NdpProxy extends BaseModel
{
private function checkConfiguration($messages)
{
if ($this->general->enabled->isEqual('1')) {
foreach (['upstream', 'downstream'] as $field) {
if ($this->general->$field->isEmpty()) {
$messages->appendMessage(new Message(
gettext('Interface is required.'),
"general.$field"
));
}
}

$upstream = $this->general->upstream->getValue();
$downstreamList = array_filter(explode(',', $this->general->downstream->getValue()));

if (!empty($upstream) && in_array($upstream, $downstreamList, true)) {
$messages->appendMessage(new Message(
gettext('Downstream interfaces cannot contain upstream interface.'),
'general.downstream'
));
}
}
}

public function performValidation($validateFullModel = false)
{
$messages = parent::performValidation($validateFullModel);
$this->checkConfiguration($messages);
return $messages;
}
}
Loading