Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/.devcontainer/bin/utils

22 lines
737 B

# Function to check server availability
check_server_availability() {
local url=$1
curl --connect-timeout 3 --silent ${url} 1>/dev/null
if [ $? -ne 0 ]; then
echo "VPN must be enabled to connect to ${url}"
exit 1
fi
}
# Function to check server accessibility with a POST request
check_server_accessibility() {
local url=$1
local payload='[{"id":0,"params":["latest",false],"method":"eth_getBlockByNumber","jsonrpc":"2.0"}]'
http_code=$(curl -s -o /dev/null -w "%{http_code}" -X POST ${url} -H "Content-Type: application/json" -d "${payload}")
if [ "$http_code" -ne 200 ]; then
echo "VPN must be enabled to access ${url} (HTTP status code: ${http_code})"
exit 1
fi
}