From 5b185fc498679f90d4ee46f5b820e9c69272f3b5 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 10 Feb 2021 14:46:26 +0100 Subject: [PATCH] Add resolvers check to CI --- .github/workflows/resolverscheck.sh | 71 ++++++++++++++++++++++++++++ .github/workflows/resolverscheck.yml | 17 +++++++ 2 files changed, 88 insertions(+) create mode 100755 .github/workflows/resolverscheck.sh create mode 100644 .github/workflows/resolverscheck.yml diff --git a/.github/workflows/resolverscheck.sh b/.github/workflows/resolverscheck.sh new file mode 100755 index 00000000..f6e4b248 --- /dev/null +++ b/.github/workflows/resolverscheck.sh @@ -0,0 +1,71 @@ +#! /bin/sh + +DNSLOOKUP_VERSION=1.4.5 + +case "$(uname -ms)" in +Darwin\ x86_64) DNSLOOKUP_ARCH=darwin-amd64 ;; +Linux\ x86_64) DNSLOOKUP_ARCH=linux-amd64 ;; +*) + echo "Unsupported platform" >&2 + exit 2 + ;; +esac + +RESOLVERS_LIST="v3/public-resolvers.md" + +ERROR_LOG=".error-log" +: >"$ERROR_LOG" + +if [ ! -x "${DNSLOOKUP_ARCH}/dnslookup" ]; then + curl -sL https://github.com/ameshkov/dnslookup/releases/download/v${DNSLOOKUP_VERSION}/dnslookup-${DNSLOOKUP_ARCH}-v${DNSLOOKUP_VERSION}.tar.gz | tar xzpf - || exit 1 +fi +PATH="$(pwd)/${DNSLOOKUP_ARCH}:$PATH" + +try_resolver() { + ERROR_LOG_TMP=".errors" + resolver_name="$1" + stamp="$2" + if dnslookup one.net "$line" >/dev/null 2>&1; then + echo "pass: ${resolver_name}" + elif dnslookup one.net "$line" >/dev/null 2>&1; then + echo "pass: ${resolver_name} (1 retry)" + elif dnslookup one.net "$line" >/dev/null 2>&1; then + echo "pass: ${resolver_name} (2 retries)" + elif dnslookup one.net "$line" >/dev/null 2>"$ERROR_LOG_TMP"; then + echo "pass: ${resolver_name} (3 retries)" + else + if grep -Eq "(no route|unreachable)" "$ERROR_LOG_TMP"; then + echo "ipv6: ${resolver_name}" + else + ( + echo "* FAILED: ${resolver_name}" + echo "$stamp" + cat "$ERROR_LOG_TMP" + echo + ) >>"$ERROR_LOG" + return 1 + fi + fi +} + +resolver_name="" +while read -r line; do + case "$line" in + \#\#\ *) + resolver_name=$(echo "$line" | sed 's/^## *//') + continue + ;; + sdns:*) + try_resolver "$resolver_name" "$line" + ;; + esac +done <"$RESOLVERS_LIST" + +if [ -s "$ERROR_LOG" ]; then + exec 1>&2 + echo + echo "** FAILURES **" + echo + cat "$ERROR_LOG" + exit 1 +fi diff --git a/.github/workflows/resolverscheck.yml b/.github/workflows/resolverscheck.yml new file mode 100644 index 00000000..fd4c9e0d --- /dev/null +++ b/.github/workflows/resolverscheck.yml @@ -0,0 +1,17 @@ +name: resolverscheck + +on: + push: + branches: [next, ci] + pull_request: + branches: [next, ci] + workflow_dispatch: + +jobs: + resolverscheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: resolvers check + run: .github/workflows/resolverscheck.sh