Skip to content

Commit

Permalink
Simplify log paths with junction/channel
Browse files Browse the repository at this point in the history
* Remove two-pass gomplate template for unique ports and replace with simpler junction/channel syntax
  • Loading branch information
Mark Bonsack committed Jan 18, 2020
1 parent c86a6d5 commit 07e6895
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions package/etc/conf.d/log_paths/p_rfc3164-juniper_netscreen.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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" }}
};

0 comments on commit 07e6895

Please sign in to comment.