Created
August 9, 2022 07:28
-
-
Save nobiit/8d6ae553cf170b05ddc54ded212caaff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
DOMAIN=${1} | |
URI=${2} | |
printf "Testing WS Status for %s ...\n" ${DOMAIN} | |
for item in $(dig +short ${DOMAIN} | sort); do | |
if [[ ${item} =~ ^[0-9.]+$ ]]; then | |
printf "%15s ..... " ${item} | |
websocket_key='QGH+pbZkGhi5T71i+Q2ovQ==' # $(openssl rand -base64 16 | grep -oE '[A-Za-z0-9=+]+' | tr -d '\n') | |
status=$(curl -s -o /dev/null --max-time 5 -w "%{http_code}" --resolve "${DOMAIN}:443:${item}" https://${DOMAIN}/${URI} -H 'Upgrade: websocket' -H 'Sec-WebSocket-Version: 13' -H "Sec-WebSocket-Key: ${websocket_key}" || true) | |
if [ ${status} == 101 ]; then | |
echo OK | |
else | |
echo ${status} | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment