From 07e689549f2b50994ced253eabcacb5ea0225255 Mon Sep 17 00:00:00 2001 From: Mark Bonsack Date: Fri, 17 Jan 2020 22:40:15 -0800 Subject: [PATCH] Simplify log paths with junction/channel * Remove two-pass gomplate template for unique ports and replace with simpler junction/channel syntax --- .../p_rfc3164-juniper_netscreen.conf.tmpl | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/package/etc/conf.d/log_paths/p_rfc3164-juniper_netscreen.conf.tmpl b/package/etc/conf.d/log_paths/p_rfc3164-juniper_netscreen.conf.tmpl index 6fca3d1..153519c 100644 --- a/package/etc/conf.d/log_paths/p_rfc3164-juniper_netscreen.conf.tmpl +++ b/package/etc/conf.d/log_paths/p_rfc3164-juniper_netscreen.conf.tmpl @@ -3,16 +3,20 @@ {{- $context := dict "port_id" "JUNIPER_NETSCREEN" "parser" "common" }} {{- tmpl.Exec "t/source_network.t" $context }} -{{- /* The following is an inline template to generate the actual log path */}} -{{- define "log_path"}} log { -{{- if eq (.) "yes"}} - source(s_DEFAULT); - filter(f_juniper_netscreen); -{{- end}} -{{- if eq (.) "no"}} - source (s_JUNIPER_NETSCREEN); + junction { + channel { + source (s_DEFAULT); + filter(f_juniper_netscreen); + flags(final); + }; +{{- if or (or (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_TCP_PORT")) (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_UDP_PORT"))) (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_TLS_PORT")) }} + channel { + source (s_JUNIPER_NETSCREEN); + flags (final); + }; {{- end}} + }; rewrite { set("juniper_netscreen", value("fields.sc4s_vendor_product")); @@ -31,13 +35,4 @@ log { {{- end}} flags(flow-control,final); -}; -{{- end}} - -{{- if or (or (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_TCP_PORT")) (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_UDP_PORT"))) (getenv (print "SC4S_LISTEN_JUNIPER_NETSCREEN_TLS_PORT")) }} -# Listen on the specified dedicated port(s) for JUNIPER_NETSCREEN traffic -{{ tmpl.Exec "log_path" "no" }} -{{- end }} - -# Listen on the default port (typically 514) for JUNIPER_NETSCREEN traffic -{{ tmpl.Exec "log_path" "yes" }} \ No newline at end of file +}; \ No newline at end of file