diff --git a/package/etc/go_templates/source_network.t b/package/etc/go_templates/source_network.t index 47bfab1..a2ef26f 100644 --- a/package/etc/go_templates/source_network.t +++ b/package/etc/go_templates/source_network.t @@ -1,13 +1,8 @@ -{{ define "T1" }} - -# The following is the source port declaration for {{ (print .port_id) }} - -source s_{{ .port_id }} { - channel { - source { -{{- if or (getenv (print "SC4S_LISTEN_" .port_id "_UDP_PORT")) (eq .port_id "DEFAULT") }} - syslog ( +{{ define "UDP" }} + syslog ( transport("udp") + so-reuseport(1) + persist-name("udp{{.instance}}") port({{ getenv (print "SC4S_LISTEN_" .port_id "_UDP_PORT") "514" }}) ip-protocol(4) so-rcvbuf({{getenv "SC4S_SOURCE_UDP_SO_RCVBUFF" "1703936"}}) @@ -17,7 +12,21 @@ source s_{{ .port_id }} { use-fqdn(no) chain-hostnames(off) flags(validate-utf8, no-parse {{- if (conv.ToBool (getenv "SC4S_SOURCE_STORE_RAWMSG" "no")) }} store-raw-message {{- end}}) - ); + ); +{{- end}} + +{{ define "T1" }} + +# The following is the source port declaration for {{ (print .port_id) }} + +source s_{{ .port_id }} { + channel { + source { +{{- if or (getenv (print "SC4S_LISTEN_" .port_id "_UDP_PORT")) (eq .port_id "DEFAULT") }} +{{- range (math.Seq (getenv "SC4S_SOURCE_LISTEN_UDP_SOCKETS" "5"))}} +{{- $context := dict "instance" . "port_id" "DEFAULT" }} +{{- template "UDP" $context }} +{{- end}} {{- end}} {{- if or (getenv (print "SC4S_LISTEN_" .port_id "_TCP_PORT")) (eq .port_id "DEFAULT") }} network ( @@ -32,7 +41,7 @@ source s_{{ .port_id }} { use-dns(no) use-fqdn(no) chain-hostnames(off) - flags(no-parse {{- if (conv.ToBool (getenv "SC4S_SOURCE_STORE_RAWMSG" "no")) }} store-raw-message {{- end}}) + flags(validate-utf8, no-parse {{- if (conv.ToBool (getenv "SC4S_SOURCE_STORE_RAWMSG" "no")) }} store-raw-message {{- end}}) ); {{- end}} {{- if (conv.ToBool (getenv "SC4S_SOURCE_TLS_ENABLE" "no")) }} @@ -48,7 +57,7 @@ source s_{{ .port_id }} { use-dns(no) use-fqdn(no) chain-hostnames(off) - flags(no-parse {{- if (conv.ToBool (getenv "SC4S_SOURCE_STORE_RAWMSG" "no")) }} store-raw-message {{- end}}) + flags(validate-utf8, no-parse {{- if (conv.ToBool (getenv "SC4S_SOURCE_STORE_RAWMSG" "no")) }} store-raw-message {{- end}}) tls(allow-compress(yes) key-file("/opt/syslog-ng/tls/server.key") cert-file("/opt/syslog-ng/tls/server.pem") @@ -197,4 +206,4 @@ source s_{{ .port_id }} { {{- end -}} {{- if or (or (or (getenv (print "SC4S_LISTEN_" .port_id "_TCP_PORT")) (getenv (print "SC4S_LISTEN_" .port_id "_UDP_PORT"))) (getenv (print "SC4S_LISTEN_" .port_id "_TLS_PORT"))) (eq .port_id "DEFAULT") -}} {{- template "T1" (.) -}} -{{- end -}} \ No newline at end of file +{{- end -}}