Commit 285c4c62 authored by Ad Schellevis's avatar Ad Schellevis

(trafficshaper) use macro to determine interface ( replace...

(trafficshaper) use macro to determine interface ( replace helpers.getNodeByTag('interfaces.xyz').if with physical_interface('xyz')
parent 339b77d1
{# Macro import #}
{% from 'OPNsense/Macros/interface.macro' import physical_interface %}
{# collect interfaces list (with / without captive portal enabled) #} {# collect interfaces list (with / without captive portal enabled) #}
{% set cp_interface_list = [] %} {% set cp_interface_list = [] %}
{% set no_cp_interface_list = [] %} {% set no_cp_interface_list = [] %}
...@@ -146,38 +148,38 @@ add 60000 return via any ...@@ -146,38 +148,38 @@ add 60000 return via any
{% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %} {% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %}
{% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence') %} {% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence') %}
{% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %} {% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %}
{% if helpers.getNodeByTag('interfaces.'+rule.interface) %} {% if physical_interface(rule.interface) %}
{% if helpers.getUUID(rule.target).enabled|default('0') == '1' %} {% if helpers.getUUID(rule.target).enabled|default('0') == '1' %}
{% if helpers.getUUIDtag(rule.target) == 'pipe' or {% if helpers.getUUIDtag(rule.target) == 'pipe' or
helpers.getUUID(helpers.getUUID(rule.target).pipe).enabled|default('0') == '1' helpers.getUUID(helpers.getUUID(rule.target).pipe).enabled|default('0') == '1'
%} %}
{% if rule.interface2 and helpers.getNodeByTag('interfaces.'+rule.interface2) %} {% if rule.interface2 and physical_interface(rule.interface2) %}
{# 2 interface defined, use both to match packets (2 rules) #} {# 2 interface defined, use both to match packets (2 rules) #}
{% if rule.direction == 'in' or not rule.direction %} {% if rule.direction == 'in' or not rule.direction %}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{ 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 {{ rule.source }} to {{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} recv {{ }} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} recv {{
helpers.getNodeByTag('interfaces.'+rule.interface).if }} {% physical_interface(rule.interface) }} {%
if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif
%} xmit {{helpers.getNodeByTag('interfaces.'+rule.interface2).if %} xmit {{physical_interface(rule.interface2)
}} }}
{% endif %} {% endif %}
{% if rule.direction == 'out' or not rule.direction %} {% if rule.direction == 'out' or not rule.direction %}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{ 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 {{ rule.source }} to {{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} xmit {{ }} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} xmit {{
helpers.getNodeByTag('interfaces.'+rule.interface).if }} {% physical_interface(rule.interface) }} {%
if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif if rule.proto.split('_')[1]|default('') == 'ack' %} {{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif
%} recv {{helpers.getNodeByTag('interfaces.'+rule.interface2).if %} recv {{physical_interface(rule.interface2)
}} }}
{% endif %} {% endif %}
{% else %} {% else %}
{# normal, single interface situation #} {# normal, single interface situation #}
add {{loop.index + 60000}} {{ helpers.getUUIDtag(rule.target) }} {{ 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 {{ rule.source }} to {{rule.destination
}} src-port {{ rule.src_port }} dst-port {{ rule.dst_port }} {{rule.direction}} {% }} 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 {{ if rule.proto.split('_')[1]|default('') == 'ack' %}{{ rule.proto.split('_')[2]|default('') }} tcpflags ack {% endif %} via {{
helpers.getNodeByTag('interfaces.'+rule.interface).if physical_interface(rule.interface)
}} }}
{% endif %} {% endif %}
{% endif %} {% endif %}
......
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