From f5a0761421fa75c0fd2d9b2a6f3b71829a952711 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 12 Jul 2019 21:23:39 +0200 Subject: [PATCH] instanceinfo.sh: Added CloudFlare-check. --- instanceinfo.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/instanceinfo.sh b/instanceinfo.sh index 13ba420..4c5a544 100755 --- a/instanceinfo.sh +++ b/instanceinfo.sh @@ -1,7 +1,7 @@ #!/bin/bash # Print some basic info about fediverse instances. -# Version: 2019-07-08_1 +# Version: 2019-07-12_1 if [[ -z "${1}" ]]; then echo "usage: ${0} DOMAIN" >&2 @@ -23,11 +23,11 @@ function main() { local instance="${1}" # shellcheck disable=SC2155 - local nodeinfo=$(curl -s "https://${instance}/.well-known/nodeinfo" | jq -r '.links[-1].href' 2> /dev/null) + local nodeinfo=$(curl -sL "https://${instance}/.well-known/nodeinfo" | jq -r '.links[-1].href' 2> /dev/null) local mastoinfo="https://${instance}/api/v1/instance" local misskeyinfo="https://${instance}/api/meta" - if curl -sIf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then + if curl -sILf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then echo "Misskey API found." json=$(curl -s -X POST "${misskeyinfo}") @@ -52,7 +52,7 @@ function main() # shellcheck disable=SC2155 local tos=$(jq -r ".ToSUrl" <<<"${json}") [[ -n "${tos}" ]] && echo "ToS: ${tos}" - elif curl -sIf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then + elif curl -sILf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then echo "Nodeinfo found." json=$(curl -s "${nodeinfo}") @@ -96,7 +96,7 @@ function main() elif [[ "${implementation}" == "mastodon" ]]; then echo "Further info, maybe: https://${instance}/about/more" fi - elif curl -sIf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then + elif curl -sILf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then echo "Mastodon API found." json=$(curl -s "${mastoinfo}") local implementation="" @@ -143,6 +143,10 @@ function main() curl -I "https://${instance}/" fi + if curl -sILf "${instance}" | grep -q 'Server: cloudflare'; then + echo "Uses CloudFlare." + fi + echo "See also: https://fediverse.network/${instance}" }