#!/usr/bin/env bash
# CheckIP: run on the machine whose egress you want to measure.
set -euo pipefail
command -v curl >/dev/null || { echo 'curl is required' >&2; exit 1; }
command -v python3 >/dev/null || { echo 'Python 3 is required' >&2; exit 1; }
script=$(mktemp "${TMPDIR:-/tmp}/checkip-stream.XXXXXXXX.py")
trap 'rm -f -- "$script"' EXIT
curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --max-time 30 https://checkip.com/toolbox/stream-check.py -o "$script"
python3 "$script" "$@"
