Commit 8ab33da1 authored by Ad Schellevis's avatar Ad Schellevis

(traffic shaper) add support for address lists, and invert src/dst... merge from master

parent 8769d7b4
......@@ -28,6 +28,12 @@
<type>text</type>
<help>source ip or network, examples 10.0.0.0/24, 10.0.0.1</help>
</field>
<field>
<id>rule.source_not</id>
<label>invert source</label>
<type>checkbox</type>
<help>invert source (not)</help>
</field>
<field>
<id>rule.src_port</id>
<label>src-port</label>
......@@ -40,6 +46,12 @@
<type>text</type>
<help>destination ip or network, examples 10.0.0.0/24, 10.0.0.1</help>
</field>
<field>
<id>rule.destination_not</id>
<label>invert destination</label>
<type>checkbox</type>
<help>invert destination (not)</help>
</field>
<field>
<id>rule.dst_port</id>
<label>dst-port</label>
......
<model>
<mount>//OPNsense/TrafficShaper</mount>
<version>1.0.1</version>
<description>
OPNsense traffic shaper
</description>
......@@ -215,16 +216,26 @@
</proto>
<source type="NetworkField">
<Required>Y</Required>
<FieldSeparator>,</FieldSeparator>
<default>any</default>
</source>
<source_not type="BooleanField">
<default>0</default>
<Required>Y</Required>
</source_not>
<src_port type="PortField">
<Required>Y</Required>
<default>any</default>
</src_port>
<destination type="NetworkField">
<Required>Y</Required>
<FieldSeparator>,</FieldSeparator>
<default>any</default>
</destination>
<destination_not type="BooleanField">
<default>0</default>
<Required>Y</Required>
</destination_not>
<dst_port type="PortField">
<Required>Y</Required>
<default>any</default>
......
......@@ -175,7 +175,9 @@ add 60000 return via any
{# 2 interface defined, use both to match packets (2 rules) #}
{% if rule.direction == 'in' or not rule.direction %}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {{ rule.source }} to {{rule.destination
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {%
if rule.source_not|default('0') == '1' %}not {% endif %}{{ rule.source }} to {%
if rule.destination_not|default('0') == '1' %}not {% endif %}{{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} recv {{
physical_interface(rule.interface) }} {%
if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif
......@@ -184,7 +186,9 @@ add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{
{% endif %}
{% if rule.direction == 'out' or not rule.direction %}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {{ rule.source }} to {{rule.destination
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {%
if rule.source_not|default('0') == '1' %}not {% endif %}{{ rule.source }} to {%
if rule.destination_not|default('0') == '1' %}not {% endif %}{{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} xmit {{
physical_interface(rule.interface) }} {%
if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif
......@@ -194,7 +198,9 @@ add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{
{% else %}
{# normal, single interface situation #}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {{ rule.source }} to {{rule.destination
helpers.getUUID(rule.target).number }} {{ rule.proto.split('_')[0] }} from {%
if rule.source_not|default('0') == '1' %}not {% endif %}{{ rule.source }} to {%
if rule.destination_not|default('0') == '1' %}not {% endif %}{{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} {{rule.direction}} {%
if rule.proto.split('_')[1]|default('') == 'ack' %}{{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif %} via {{
physical_interface(rule.interface)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment