mirror of
https://github.com/opnsense/plugins.git
synced 2025-12-10 10:30:21 -06:00
net/ndp-proxy-go: Add pf table (firewall alias) functionality (#5069)
This commit is contained in:
parent
fafde8629f
commit
06170082ad
@ -1,5 +1,5 @@
|
||||
PLUGIN_NAME= ndp-proxy-go
|
||||
PLUGIN_VERSION= 1.1
|
||||
PLUGIN_VERSION= 1.2
|
||||
PLUGIN_COMMENT= IPv6 Neighbor Discovery Protocol (NDP) Proxy
|
||||
PLUGIN_MAINTAINER= cedrik@pischem.com
|
||||
PLUGIN_DEPENDS= ndp-proxy-go
|
||||
|
||||
@ -6,6 +6,10 @@ DOC: https://docs.opnsense.org/manual/ndp-proxy-go.html
|
||||
Plugin Changelog
|
||||
================
|
||||
|
||||
1.2
|
||||
|
||||
* Add firewall alias support
|
||||
|
||||
1.1
|
||||
|
||||
* Add experimental point-to-point device upstream support (e.g. PPPoE)
|
||||
|
||||
@ -37,4 +37,30 @@ class GeneralController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'ndpproxy';
|
||||
protected static $internalModelClass = 'OPNsense\NdpProxy\NdpProxy';
|
||||
|
||||
public function searchAliasAction()
|
||||
{
|
||||
return $this->searchBase('aliases.alias');
|
||||
}
|
||||
|
||||
public function setAliasAction($uuid)
|
||||
{
|
||||
return $this->setBase('alias', 'aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
public function addAliasAction()
|
||||
{
|
||||
return $this->addBase('alias', 'aliases.alias');
|
||||
}
|
||||
|
||||
public function getAliasAction($uuid = null)
|
||||
{
|
||||
return $this->getBase('alias', 'aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
public function delAliasAction($uuid)
|
||||
{
|
||||
return $this->delBase('aliases.alias', $uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,6 +37,9 @@ class GeneralController extends IndexController
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->pick('OPNsense/NdpProxy/general');
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
$this->view->generalForm = $this->getForm('general');
|
||||
|
||||
$this->view->formDialogAlias = $this->getForm('dialogAlias');
|
||||
$this->view->formGridAlias = $this->getFormGrid('dialogAlias');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>alias.interface</id>
|
||||
<label>Interface</label>
|
||||
<type>dropdown</type>
|
||||
<help>Add IPv6 addresses to the firewall alias that belong to this proxied interface. When choosing any, all IPv6 addresses will be added.</help>
|
||||
<grid_view>
|
||||
<formatter>any</formatter>
|
||||
</grid_view>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.alias</id>
|
||||
<label>Firewall alias</label>
|
||||
<type>dropdown</type>
|
||||
<help>Choose an "external (advanced)" type alias from "Firewall - Aliases". Whenever a client is discovered, the IPv6 address will be automatically added to the chosen alias. When the neighbor cache lifetime expires, the IPv6 address will be removed from the alias.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.description</id>
|
||||
<label>Description</label>
|
||||
<type>text</type>
|
||||
</field>
|
||||
</form>
|
||||
@ -37,5 +37,27 @@
|
||||
<Required>Y</Required>
|
||||
</debug>
|
||||
</general>
|
||||
<aliases>
|
||||
<alias type="ArrayField">
|
||||
<interface type="InterfaceField">
|
||||
<BlankDesc>any</BlankDesc>
|
||||
</interface>
|
||||
<alias type="ModelRelationField">
|
||||
<Model>
|
||||
<aliases>
|
||||
<source>OPNsense.Firewall.Alias</source>
|
||||
<items>aliases.alias</items>
|
||||
<display>name</display>
|
||||
<filters>
|
||||
<type>/^[Ee]xternal.*/</type>
|
||||
<name>/^(?!bogons$|bogonsv6$|virusprot$|sshlockout$|__.*).*/</name>
|
||||
</filters>
|
||||
</aliases>
|
||||
</Model>
|
||||
<Required>Y</Required>
|
||||
</alias>
|
||||
<description type="DescriptionField"/>
|
||||
</alias>
|
||||
</aliases>
|
||||
</items>
|
||||
</model>
|
||||
|
||||
@ -39,10 +39,41 @@
|
||||
},
|
||||
});
|
||||
|
||||
$("#{{formGridAlias['table_id']}}").UIBootgrid({
|
||||
search:'/api/ndpproxy/general/search_alias/',
|
||||
get:'/api/ndpproxy/general/get_alias/',
|
||||
set:'/api/ndpproxy/general/set_alias/',
|
||||
add:'/api/ndpproxy/general/add_alias/',
|
||||
del:'/api/ndpproxy/general/del_alias/',
|
||||
options: {
|
||||
formatters:{
|
||||
any: function(column, row) {
|
||||
if (row[column.id] !== '') {
|
||||
return row[`%${column.id}`] || row[column.id];
|
||||
} else {
|
||||
return '{{ lang._('any') }}';
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="content-box __mb">
|
||||
{{ partial("layout_partials/base_form", ['fields': generalForm, 'id': 'frm_GeneralSettings']) }}
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#aliases">{{ lang._('Aliases') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content content-box">
|
||||
<div id="general" class="tab-pane fade in active">
|
||||
{{ partial('layout_partials/base_form', ['fields': generalForm, 'id': 'frm_GeneralSettings']) }}
|
||||
</div>
|
||||
<div id="aliases" class="tab-pane fade in">
|
||||
{{ partial('layout_partials/base_bootgrid_table', formGridAlias)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ partial('layout_partials/base_apply_button', {'data_endpoint': '/api/ndpproxy/service/reconfigure', 'data_service_widget': 'ndpproxy'}) }}
|
||||
{{ partial('layout_partials/base_dialog',['fields':formDialogAlias,'id':formGridAlias['edit_dialog_id'],'label':lang._('Edit Alias')])}}
|
||||
|
||||
@ -30,6 +30,14 @@ ndp_proxy_go_downstream="{{ downstream_interfaces|join(' ') }}"
|
||||
{% if general.pcap_timeout %}
|
||||
{% do flags.append('--pcap-timeout ' ~ general.pcap_timeout ~ 'ms') %}
|
||||
{% endif %}
|
||||
{% for alias in helpers.toList('OPNsense.ndpproxy.aliases.alias') %}
|
||||
{% set iface = alias.interface|default('') %}
|
||||
{% if iface == '' %}
|
||||
{% do flags.append('--pf=:' ~ helpers.getUUID(alias.alias).name) %}
|
||||
{% else %}
|
||||
{% do flags.append('--pf=' ~ helpers.physical_interface(iface) ~ ':' ~ helpers.getUUID(alias.alias).name) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if flags|length > 0 %}
|
||||
ndp_proxy_go_flags="{{ flags|join(' ') }}"
|
||||
{% endif %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user