From 00225fdbc6a3e586cab5cf3b6b01c99750578222 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 27 Jul 2022 14:08:57 -0600 Subject: Exclude Cloudflare instances from services.json by default This updates the services json file to exclude all instances that are detected to be using Cloudflare nameservers. A separate "services-full.json" file will continue to be tracked in the repo, which will include the full list of all instances for each service and can be used with the `FARSIDE_SERVICES_JSON` environment variable for anyone wanting to access the full instance list for each service. See #43 --- .github/workflows/update-instances.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to '.github') diff --git a/.github/workflows/update-instances.yml b/.github/workflows/update-instances.yml index c795192..2e87276 100644 --- a/.github/workflows/update-instances.yml +++ b/.github/workflows/update-instances.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install dependencies - run: sudo apt-get install -y jq + run: sudo apt-get install -y jq dnsutils - uses: webfactory/ssh-agent@v0.5.3 with: @@ -27,6 +27,32 @@ jobs: sed -i 's/\/"/"/g' services.json } + function remove_cf_instances() { + rm out.json + file="services.json" + + while read -r line; do + if [[ "$line" == "\"https://"* ]]; then + domain=$(echo "$line" | sed -e "s/^\"https:\/\///" -e "s/\",//" -e "s/\"//") + ns=$(dig ns "$domain") + if [[ "$ns" == *"cloudflare"* ]]; then + echo "\"$domain\" using cloudflare, skipping..." + else + echo "$line" >> out.json + fi + else + echo "$line" >> out.json + fi + done <$file + + # Remove any trailing commas from new instance lists + sed -i '' -e ':begin' -e '$!N' -e 's/,\n]/\n]/g' -e 'tbegin' -e 'P' -e 'D' out.json + + mv services.json services-full.json + cat out.json | jq --indent 2 . > services.json + rm out.json + } + # ============================================================== # Git config # ============================================================== @@ -173,6 +199,11 @@ jobs: # TODO: Update instances for other services # ============================================================== + # ============================================================== + # Remove cloudflare instances + # ============================================================== + remove_cf_instances + # ============================================================== # Push changes # ============================================================== -- cgit v1.2.3