Skip to content

Commit

Permalink
Support a dynamic number of listeners for udp
Browse files Browse the repository at this point in the history
  • Loading branch information
rfaircloth-splunk committed Apr 1, 2020
1 parent 7568570 commit 73871fe
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions package/etc/go_templates/source_network.t
Original file line number Diff line number Diff line change
@@ -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"}})
Expand All @@ -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_INSTANCES" "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 (
Expand All @@ -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")) }}
Expand All @@ -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")
Expand Down

0 comments on commit 73871fe

Please sign in to comment.