From bcc0b78521f8ccddc31d3d5721aae2b09e104ff9 Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 13 Mar 2022 18:55:49 +0100 Subject: [PATCH 1/4] Allow debugging of entrypoint --- data/docker-entrypoint.sh | 5 +++++ tests/03-wildcard-cname.sh | 8 ++++---- tests/05-extrahosts-cname.sh | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/data/docker-entrypoint.sh b/data/docker-entrypoint.sh index 5cab66e..d073671 100755 --- a/data/docker-entrypoint.sh +++ b/data/docker-entrypoint.sh @@ -4,6 +4,11 @@ set -e set -u set -o pipefail +# Enable debug of entrypoint +if [ "${DEBUG:-}" = "1" ]; then + set -x +fi + ################################################################################# # VARIABLES diff --git a/tests/03-wildcard-cname.sh b/tests/03-wildcard-cname.sh index 18703fa..c83507d 100755 --- a/tests/03-wildcard-cname.sh +++ b/tests/03-wildcard-cname.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short www.devilbox | wc -l )" = "0" ]; then @@ -30,7 +30,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short t1.devilbox | wc -l )" = "0" ]; then @@ -41,7 +41,7 @@ docker stop "${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short t1.devilbox | wc -l )" = "0" ]; then @@ -52,7 +52,7 @@ docker stop "${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'WILDCARD_DNS=devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short t1.devilbox | wc -l )" = "0" ]; then diff --git a/tests/05-extrahosts-cname.sh b/tests/05-extrahosts-cname.sh index 391543d..532bd14 100755 --- a/tests/05-extrahosts-cname.sh +++ b/tests/05-extrahosts-cname.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short www.devilbox | wc -l )" = "0" ]; then @@ -34,7 +34,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short www.devilbox | wc -l )" = "0" ]; then @@ -49,7 +49,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short www.devilbox | wc -l )" = "0" ]; then @@ -64,7 +64,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if [ "$( dig @127.0.0.1 -p ${PORT} +short www.devilbox | wc -l )" = "0" ]; then From 458971a8d34b5c519a03820c81c7618ded0f0ab0 Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 13 Mar 2022 19:10:54 +0100 Subject: [PATCH 2/4] Document DEBUG var --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e41fd1f..38709c0 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Bind caching DNS server based on Debian slim with support for DNS forwarders, in | Variable | Type | Default | Description | |--------------------|--------|-----------|-------------| +| `DEBUG` | bool | `0` | Set to `1` in order to add `set -x` to entrypoint script for bash debugging | | `DEBUG_ENTRYPOINT` | bool | `0` | Show shell commands executed during start.
Values: `0`, `1` or `2` | | `DOCKER_LOGS` | bool | `0` | Set to `1` to log info and queries to Docker logs. | | `WILDCARD_DNS` | string | | Add one or more tld's, domains or subdomains as catch-all for a specific IP address or CNAME. Reverse DNS is optional and can also be specified. | From f3c6fa4426628bae3ece29c20aaf723621229f6c Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 13 Mar 2022 19:23:09 +0100 Subject: [PATCH 3/4] Test more aggressively --- Makefile | 2 ++ tests/01-run.sh | 8 ++++---- tests/02-wildcard-addr.sh | 8 ++++---- tests/04-extrahosts-addr.sh | 8 ++++---- tests/06-ttl-time.sh | 8 ++++---- tests/07-docker-logs.sh | 8 ++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 30c8a7d..e8367e6 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,8 @@ test: update-readme .PHONY: _test-integration _test-integration: + @# Run twice to catch more potential errors/race-conditions + ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) .PHONY: update-readme diff --git a/tests/01-run.sh b/tests/01-run.sh index 5029398..f499252 100755 --- a/tests/01-run.sh +++ b/tests/01-run.sh @@ -19,7 +19,7 @@ NAME="bind$( shuf -i 1000000000-2000000000 -n 1 )" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "docker exec ${NAME} named -V"; then @@ -34,7 +34,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "docker exec ${NAME} named -V"; then @@ -49,7 +49,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "docker exec ${NAME} named -V"; then @@ -64,7 +64,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "docker exec ${NAME} named -V"; then diff --git a/tests/02-wildcard-addr.sh b/tests/02-wildcard-addr.sh index 810819c..8630166 100755 --- a/tests/02-wildcard-addr.sh +++ b/tests/02-wildcard-addr.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short t1.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -30,7 +30,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short t1.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -41,7 +41,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short t1.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -52,7 +52,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'WILDCARD_DNS=devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short t1.devilbox | grep -E '^1\.1\.1\.1$'"; then diff --git a/tests/04-extrahosts-addr.sh b/tests/04-extrahosts-addr.sh index 65149b2..538de94 100755 --- a/tests/04-extrahosts-addr.sh +++ b/tests/04-extrahosts-addr.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short www.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -34,7 +34,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short www.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -49,7 +49,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short www.devilbox | grep -E '^1\.1\.1\.1$'"; then @@ -64,7 +64,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'EXTRA_HOSTS=www.devilbox=1.1.1.1' -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} +short www.devilbox | grep -E '^1\.1\.1\.1$'"; then diff --git a/tests/06-ttl-time.sh b/tests/06-ttl-time.sh index ac39de6..5a93a01 100755 --- a/tests/06-ttl-time.sh +++ b/tests/06-ttl-time.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} www.devilbox | grep -E '^www\.devilbox\.\s+500\s+IN\s+A'"; then @@ -30,7 +30,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} www.devilbox | grep -E '^www\.devilbox\.\s+500\s+IN\s+A'"; then @@ -41,7 +41,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} www.devilbox | grep -E '^www\.devilbox\.\s+500\s+IN\s+A'"; then @@ -52,7 +52,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e TTL_TIME=500 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" if ! run "dig @127.0.0.1 -p ${PORT} www.devilbox | grep -E '^www\.devilbox\.\s+500\s+IN\s+A'"; then diff --git a/tests/07-docker-logs.sh b/tests/07-docker-logs.sh index 1d7d89a..b7cd92a 100755 --- a/tests/07-docker-logs.sh +++ b/tests/07-docker-logs.sh @@ -19,7 +19,7 @@ PORT="5300" # DEBUG_ENTRYPOINT=2 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=2 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" run "dig @127.0.0.1 -p ${PORT} +short www.devilbox || true" @@ -32,7 +32,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=1 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" run "dig @127.0.0.1 -p ${PORT} +short www.devilbox || true" @@ -45,7 +45,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=0 -run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e DEBUG_ENTRYPOINT=0 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" run "dig @127.0.0.1 -p ${PORT} +short www.devilbox || true" @@ -58,7 +58,7 @@ run "docker stop ${NAME}" # DEBUG_ENTRYPOINT=null -run "docker run --rm --platform ${ARCH} --name ${NAME} -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" +run "docker run --rm --platform ${ARCH} --name ${NAME} -e DEBUG=1 -e 'EXTRA_HOSTS=www.devilbox=google.com' -e DOCKER_LOGS=1 -p ${PORT}:53/udp ${IMAGE}:${TAG} &" run "sleep 5" sanity_check "${NAME}" run "dig @127.0.0.1 -p ${PORT} +short www.devilbox || true" From 4d1616c5456b74f1eee3f780bba7e906af8cf11b Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 13 Mar 2022 19:30:13 +0100 Subject: [PATCH 4/4] Ensure to only return one address by dig command --- Makefile | 2 -- data/docker-entrypoint.sh | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e8367e6..30c8a7d 100644 --- a/Makefile +++ b/Makefile @@ -87,8 +87,6 @@ test: update-readme .PHONY: _test-integration _test-integration: - @# Run twice to catch more potential errors/race-conditions - ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) .PHONY: update-readme diff --git a/data/docker-entrypoint.sh b/data/docker-entrypoint.sh index d073671..f3f3d5c 100755 --- a/data/docker-entrypoint.sh +++ b/data/docker-entrypoint.sh @@ -544,7 +544,7 @@ if printenv WILDCARD_DNS >/dev/null 2>&1; then fi if ! is_ip4 "${tmp}"; then # Try dig command second - tmp="$( dig @8.8.8.8 +short "${my_add}" A )" + tmp="$( dig @8.8.8.8 +short "${my_add}" A | head -1 )" if ! is_ip4 "${tmp}"; then log "warn" "CNAME '${my_add}' could not be resolved. Skipping to add wildcard" "${DEBUG_ENTRYPOINT}" continue; @@ -597,7 +597,7 @@ if printenv EXTRA_HOSTS >/dev/null 2>&1 && [ -n "$( printenv EXTRA_HOSTS )" ]; t fi if ! is_ip4 "${tmp}"; then # Try dig command second - tmp="$( dig @8.8.8.8 +short "${my_add}" A )" + tmp="$( dig @8.8.8.8 +short "${my_add}" A | head -1 )" if ! is_ip4 "${tmp}"; then log "warn" "CNAME '${my_add}' could not be resolved. Skipping to add extra host" "${DEBUG_ENTRYPOINT}" continue;