1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-04-25 13:10:02 +00:00

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
This commit is contained in:
Ben Busby 2022-07-27 14:08:57 -06:00
parent 7248af0d5f
commit 00225fdbc6
No known key found for this signature in database
GPG key ID: B9B7231E01D924A1
3 changed files with 391 additions and 80 deletions

View file

@ -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
# ==============================================================