-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
FROM golang:1.12 as builder | ||
FROM golang:1.12-alpine3.10 as builder | ||
COPY . /build | ||
RUN cd /build/cmd/dtap && go build | ||
RUN apk --update --no-cache add git gcc musl-dev \ | ||
&& cd /build/cmd/dtap \ | ||
&& go build | ||
|
||
FROM alpine:latest | ||
FROM alpine:3.10 | ||
|
||
ENV DTAP_INPUT_UNIX_SOCKET "/dtap/dnstap.sock" | ||
ENV DTAP_INPUT_UNIX_SOCKET_USER "daemon" | ||
ENV DTAP_INPUT_TCP_LISTEN_ADDR "" | ||
ENV DTAP_INPUT_TCP_LISTEN_PORT "10053" | ||
ENV DTAP_OUTPUT_TCP_HOST "" | ||
ENV DTAP_OUTPUT_TCP_PORT "10053" | ||
ENV DTAP_OUTPUT_UNIX_SOCKET "" | ||
ENV DTAP_OUTPUT_FLUENT_HOSTS "" | ||
ENV DTAP_OUTPUT_FLUENT_PORT "24224" | ||
ENV DTAP_OUTPUT_FLUENT_TAG "dnstap" | ||
ENV DTAP_OUTPUT_KAFKA_HOSTS "" | ||
ENV DTAP_OUTPUT_KAFKA_TOPIC "dnstap_message" | ||
ENV DTAP_OUTPUT_NATS_HOST "" | ||
ENV DTAP_OUTPUT_NATS_SUBJECT "dnstap_message" | ||
ENV DTAP_OUTPUT_NATS_USER "" | ||
ENV DTAP_OUTPUT_NATS_PASS "" | ||
ENV DTAP_OUTPUT_NATS_TOKEN "" | ||
ENV DTAP_IPV4_MASK 24 | ||
ENV DTAP_IPV6_MASK 48 | ||
ENV DTAP_ENABLE_ECS "false" | ||
ENV DTAP_ENABLE_HASH_IP "false" | ||
ENV DTAP_ENABLE_HASH_SALT "" | ||
|
||
COPY entrypoint.sh / | ||
COPY --from=builder /build/cmd/dtap/dtap /usr/bin/dtap | ||
COPY misc/dtap.toml /config.toml | ||
|
||
CMD ["/usr/bin/dtap"] | ||
RUN mkdir /etc/dtap \ | ||
&& chmod 755 /entrypoint.sh | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] | ||
CMD ["/usr/bin/dtap", "-c", "/etc/dtap/dtap.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/ash | ||
|
||
if [ ! -e "/etc/dtap/dtap.conf" ] ; then | ||
if [ "${DTAP_INPUT_UNIX_SOCKET}" != "" ] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[InputUnix]] | ||
Path="${DTAP_INPUT_UNIX_SOCKET}" | ||
User="${DTAP_INPUT_UNIX_SOCKET_USER}" | ||
EOS | ||
fi | ||
if [ "${DTAP_INPUT_TCP_LISTEN_ADDR}" != "" ] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[InputTCP]] | ||
Address="${DTAP_INPUT_TCP_LISTEN_ADDR}" | ||
Port=${DTAP_INPUT_TCP_LISTEN_PORT} | ||
EOS | ||
fi | ||
if [ "${DTAP_OUTPUT_TCP_HOST}" != "" ] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[OutputTCP]] | ||
Host="${DTAP_OUTPUT_TCP_HOST}" | ||
Port=${DTAP_OUTPUT_TCP_PORT} | ||
EOS | ||
fi | ||
if [ "$DTAP_OUTPUT_UNIX_SOCKET" != "" ] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[OutputUnix]] | ||
Path="${DTAP_OUTPUT_UNIX_SOCKET}" | ||
EOS | ||
fi | ||
if [ "${DTAP_OUTPUT_FLUENT_HOST}"] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[OutputFluent]] | ||
Host = "${DTAP_OUTPUT_FLUENT_HOST}" | ||
Port = ${DTAP_OUTPUT_FLUENT_PORT} | ||
Tag = "${DTAP_OUTPUT_FLUENT_TAG}" | ||
[OutputKafka.flat] | ||
IPv4Mask = ${DTAP_IPV4_MASK} | ||
IPv6Mask = ${DTAP_IPV6_MASK} | ||
EnableECS = ${DTAP_ENABLE_ECS} | ||
EnableHashIP = ${DTAP_ENABLE_HASH_IP} | ||
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}" | ||
EOS | ||
|
||
fi | ||
if [ "${DTAP_OUTPUT_KAFKA_HOSTS}" != "" ] ; then | ||
host=$(echo ${DTAP_OUTPUT_KAFKA_HOSTS} | sed 's/,/","/g') | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[OutputKafka]] | ||
Hosts = ["${host}"] | ||
Topic = "${DTAP_OUTPUT_KAFKA_TOPIC}" | ||
[OutputKafka.flat] | ||
IPv4Mask = ${DTAP_IPV4_MASK} | ||
IPv6Mask = ${DTAP_IPV6_MASK} | ||
EnableECS = ${DTAP_ENABLE_ECS} | ||
EnableHashIP = ${DTAP_ENABLE_HASH_IP} | ||
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}" | ||
EOS | ||
fi | ||
if [ "${DTAP_OUTPUT_NATS_HOST}" != "" ] ; then | ||
cat <<- EOS >> /etc/dtap/dtap.conf | ||
[[OutputNats]] | ||
Hosts = "${DTAP_OUTPUT_NATS_HOST}" | ||
User = "${DTAP_OUTPUT_NATS_USER}" | ||
Password = "${DTAP_OUTPUT_NATS_PASS}" | ||
Token = "${DTAP_OUTPUT_NATS_TOKEN}" | ||
Subject = "${DTAP_OUTPUT_NATS_SUBJECT}" | ||
[OutputNats.flat] | ||
IPv4Mask = ${DTAP_IPV4_MASK} | ||
IPv6Mask = ${DTAP_IPV6_MASK} | ||
EnableECS = ${DTAP_ENABLE_ECS} | ||
EnableHashIP = ${DTAP_ENABLE_HASH_IP} | ||
IPHashSaltPath = "${DTAP_ENABLE_HASH_SALT}" | ||
EOS | ||
fi | ||
fi | ||
|
||
cat /etc/dtap/dtap.conf | ||
|
||
exec "$@" |