{% if not helpers.empty('OPNsense.Syslog.destinations.destination') %} {% for destination in helpers.toList('OPNsense.Syslog.destinations.destination') %} {% if destination.enabled|default('0') == '1' %} {% set dest_key = destination['@uuid']|replace('-', '')%} {% set applied_filters = [] %} ### log target {{destination['@uuid']}} : {{destination.description|default("")}} #### {% for key in ['program', 'level', 'facility'] %} {% if destination[key] %} filter f_{{dest_key}}_{{key}} { {% if key == 'program' %} {# program filters need to use separate clauses, a bit of magic to wrap the value in program("ITEM") #} {% set prog_list = ('program("%s")' % destination[key]).replace(',', '"),program("').split(',') %} {{ prog_list|join(' or ') }} {% else %} {# comma separated lists #} {{ "%s(%s)" % (key, destination[key]) }} {% endif %} }; {% do applied_filters.append(key) %} {% endif %} {% endfor %} destination d_{{dest_key}} { {% if destination.transport in ['udp4', 'udp6', 'tcp4', 'tcp6'] %} network( "{{destination.hostname}}" transport("{{destination.transport[:3]}}") port({{destination.port}}) ip-protocol({{destination.transport[3]}}) persist-name("{{dest_key}}") ); {% endif %} }; log { source(s_all); {% for filter in applied_filters %} filter(f_{{dest_key}}_{{filter}}); {% endfor %} destination(d_{{dest_key}}); }; {% endif %} {% endfor%} {% endif %}