# Templates for local and remote logging
$template DynLocalIptables, "/var/log/rsyslog/local/iptables/iptables.%syslogseverity-text%.log"
$template DynRemoteIptables, "/var/log/rsyslog/remote/%hostname:::secpath-replace%/iptables/iptables.%syslogseverity-text%.log"

%if %%getVar('activer_reception_logs', 'non') == 'non'
# all messages go in local branch
:msg, contains, "iptables" ?DynLocalIptables
& stop
%else
# all messages from localhost go in local branch
if $msg contains 'iptables' and $fromhost-ip startswith '127' then ?DynLocalIptables
& stop
%if %%mode_conteneur_actif == 'oui'
# all messages from containers go in local branch
if $msg contains 'iptables' and $fromhost-ip startswith '%%adresse_ip_br0[:-2]' then ?DynLocalIptables
& stop
if $msg contains 'iptables' and $fromhost startswith '%%adresse_ip_br0[:-2]' then ?DynLocalIptables
& stop
%end if
# all remaining messages go in remote branch
:msg, contains, "iptables" ?DynRemoteIptables
& stop
%end if
