diff options
| author | Ben Busby <contact@benbusby.com> | 2022-07-27 14:08:57 -0600 |
|---|---|---|
| committer | Ben Busby <contact@benbusby.com> | 2022-07-27 14:08:57 -0600 |
| commit | 00225fdbc6a3e586cab5cf3b6b01c99750578222 (patch) | |
| tree | 3d4d21e3115701afdcfcc07861ed1369fe7a105f /.github | |
| parent | 7248af0d5f2d401fa22df86ee7cbf9539e8a1fb6 (diff) | |
| download | farside-00225fdbc6a3e586cab5cf3b6b01c99750578222.tar.gz | |
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
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/update-instances.yml | 33 |
1 files changed, 32 insertions, 1 deletions
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 # ============================================================== @@ -174,6 +200,11 @@ jobs: # ============================================================== # ============================================================== + # Remove cloudflare instances + # ============================================================== + remove_cf_instances + + # ============================================================== # Push changes # ============================================================== git add services.json |
