instanceinfo.sh: Ignore certificate errors.

This commit is contained in:
tastytea 2019-07-18 18:36:35 +02:00
parent a83cfa78ac
commit 7d909c603b
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 17 additions and 10 deletions

View File

@ -8,11 +8,18 @@ if [[ -z "${1}" ]]; then
exit 1
fi
if ! command -v curl > /dev/null; then
echo "You need to install curl (https://curl.haxx.se/)" >&2
exit 2
fi
if ! command -v jq > /dev/null; then
echo "You need to install jq (https://stedolan.github.com/jq/)" >&2
exit 2
fi
mycurl="curl -sk"
function striphtml()
{
local extract="${*}"
@ -23,7 +30,7 @@ function parse_nodeinfo()
{
local instance="${1}"
local nodeinfo="${2}"
json=$(curl -s "${nodeinfo}")
json=$(${mycurl} "${nodeinfo}")
# shellcheck disable=SC2155
local implementation=$(jq -r ".software.name" <<<"${json}")
@ -82,7 +89,7 @@ function parse_mastodon()
{
local instance="${1}"
local mastoinfo="${2}"
json=$(curl -s "${mastoinfo}")
json=$(${mycurl} "${mastoinfo}")
local implementation=""
if grep -Eq '"is_(pro|verified)"' <<<"${json}"; then
@ -131,7 +138,7 @@ function parse_misskey()
{
local instance="${1}"
local misskeyinfo="${2}"
json=$(curl -s -X POST "${misskeyinfo}")
json=$(${mycurl} -X POST "${misskeyinfo}")
# shellcheck disable=SC2155
local version=$(jq -r ".version" <<<"${json}")
@ -142,7 +149,7 @@ function parse_misskey()
[[ -n "${email}" ]] && echo "E-Mail: ${email}"
# shellcheck disable=SC2155
local users=$(curl -s -X POST "https://${instance}/api/stats" | jq -r ".usersCount")
local users=$(${mycurl} -X POST "https://${instance}/api/stats" | jq -r ".usersCount")
[[ -n ${users} ]] && echo "Number of users: ${users}"
echo -n "Open registrations: "
@ -157,25 +164,25 @@ function main()
{
local instance="${1}"
# shellcheck disable=SC2155
local nodeinfo=$(curl -sL "https://${instance}/.well-known/nodeinfo" | jq -r '.links[-1].href' 2> /dev/null)
local nodeinfo=$(${mycurl} -L "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 -sILf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then
if ${mycurl} -ILf -X POST "${misskeyinfo}" | grep -iq 'Content-Type: application/json'; then
echo "Misskey API found."
parse_misskey "${instance}" "${misskeyinfo}"
elif curl -sILf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then
elif ${mycurl} -ILf "${nodeinfo}" | grep -iq 'Content-Type: application/json'; then
echo "Nodeinfo found."
parse_nodeinfo "${instance}" "${nodeinfo}"
elif curl -sILf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then
elif ${mycurl} -ILf "${mastoinfo}" | grep -iq 'Content-Type: application/json'; then
echo "Mastodon API found."
parse_mastodon "${instance}" "${mastoinfo}"
else
echo "Could not detect type of server."
curl -I "https://${instance}/"
${mycurl} -I "https://${instance}/"
fi
if curl -sILf "${instance}" | grep -q 'Server: cloudflare'; then
if ${mycurl} -ILf "${instance}" | grep -q 'Server: cloudflare'; then
echo "Uses CloudFlare."
fi