Skip to content

Instantly share code, notes, and snippets.

@groundcat
Created March 13, 2026 03:32
Show Gist options
  • Select an option

  • Save groundcat/27f9facda496e7b6123772d5ef21b236 to your computer and use it in GitHub Desktop.

Select an option

Save groundcat/27f9facda496e7b6123772d5ef21b236 to your computer and use it in GitHub Desktop.
Route64.org Tunnel Hub Latency Tester
#!/bin/bash
# Route64 Tunnel Hub Latency Tester
# https://route64.org — tests all available Route64 tunnel hubs (IPv4)
# ── Colours ────────────────────────────────────────────────────────────────
RED='\033[0;31m'; YELLOW='\033[1;33m'; GREEN='\033[0;32m'
BOLD='\033[1m'; DIM='\033[2m'; RESET='\033[0m'
# ── Server list: "Region|Display name|IPv4" ─────────────────────────────────
SERVERS=(
# Canada
"North America|Toronto, CA (yyz1.ca)|23.154.9.27"
# United States
"North America|Kansas City, US (mci1.us)|23.150.41.118"
"North America|Kansas City, US (mci2.us)|23.156.200.132"
"North America|Fremont, US (frm1.us)|23.154.8.27"
"North America|Dallas, US (dal1.us)|213.145.83.41"
"North America|Ashburn, US (ash1.us)|148.59.164.18"
# Europe
"Europe|Frankfurt, DE (fra2.de)|185.121.24.139"
"Europe|Frankfurt, DE (fra3.de)|178.215.228.222"
"Europe|Paris, FR (par2.fr)|45.154.96.16"
"Europe|Paris, FR (par1.fr)|81.18.58.22"
"Europe|London, GB (lon1.uk)|185.121.24.12"
"Europe|Amsterdam, NL (ams1.nl)|118.91.187.67"
"Europe|Amsterdam, NL (ams2.nl)|185.121.24.73"
"Europe|Sandefjord, NO (san1.no)|185.147.35.234"
"Europe|Stockholm, SE (arn1.se)|192.67.33.15"
# Asia
"Asia|Singapore, SG (sin1.sg)|103.172.116.132"
)
TOTAL=${#SERVERS[@]}
PING_COUNT=5
WORK_DIR=$(mktemp -d)
trap 'rm -rf "$WORK_DIR"' EXIT
# ── Helpers ────────────────────────────────────────────────────────────────
lat_color() {
local val="$1"
if [[ "$val" == "N/A" ]]; then
printf '%b' "$RED"; return
fi
local i=${val%%.*}
(( i < 50 )) && { printf '%b' "$GREEN"; return; }
(( i < 150 )) && { printf '%b' "$YELLOW"; return; }
printf '%b' "$RED"
}
colored_field() {
local width="$1" val="$2"
printf '%b%*s%b' "$(lat_color "$val")" "$width" "$val" "$RESET"
}
# ── Parallel ping worker ───────────────────────────────────────────────────
ping_server() {
local idx="$1" region="$2" location="$3" ip="$4"
local result min avg max mdev
result=$(ping -nq -c"$PING_COUNT" -i0.3 -w"$PING_COUNT" "$ip" 2>/dev/null \
| tail -n1 | cut -d' ' -f4)
if [[ "$result" =~ ^[0-9] ]]; then
IFS='/' read -r min avg max mdev <<< "$result"
else
min="N/A"; avg="N/A"; max="N/A"; mdev="N/A"
fi
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
"$region" "$location" "$ip" "$min" "$avg" "$max" "$mdev" \
> "$WORK_DIR/$idx"
}
# ── Main ───────────────────────────────────────────────────────────────────
printf '\n%bRoute64 — Tunnel Hub Latency Test%b\n' "$BOLD" "$RESET"
printf '%bPinging %d hubs · %d packets each · all parallel%b\n\n' \
"$DIM" "$TOTAL" "$PING_COUNT" "$RESET"
for i in "${!SERVERS[@]}"; do
IFS='|' read -r region location ip <<< "${SERVERS[$i]}"
ping_server "$i" "$region" "$location" "$ip" &
done
BAR_LEN=40
while true; do
done_n=$(find "$WORK_DIR" -maxdepth 1 -type f | wc -l | tr -d ' ')
filled=$(( done_n * BAR_LEN / TOTAL ))
empty=$(( BAR_LEN - filled ))
bar=$(printf '%*s' "$filled" | tr ' ' '')
gap=$(printf '%*s' "$empty" | tr ' ' '')
printf '\r [%b%s%b%s] %d / %d' \
"$GREEN" "$bar" "$RESET" "$gap" "$done_n" "$TOTAL"
(( done_n >= TOTAL )) && break
sleep 0.2
done
wait
printf '\r%60s\r' ""
mapfile -t sorted < <(
for i in "${!SERVERS[@]}"; do cat "$WORK_DIR/$i"; done \
| awk -F'\t' '{
key = ($5 == "N/A") ? 99999 : $5 + 0
printf "%010.3f\t%s\n", key, $0
}' \
| sort -n \
| cut -f2-
)
SEP=$(printf '%.0s─' {1..97})
printf '\n%b%-16s %-25s %-17s %8s %8s %8s %8s%b\n' \
"$BOLD" "Region" "Location" "IPv4" "Min" "Avg" "Max" "Mdev" "$RESET"
printf '%b%s%b\n' "$DIM" "$SEP" "$RESET"
printf '%b < 50 ms ' "$GREEN"
printf '%b 50–150 ms ' "$YELLOW"
printf '%b > 150 ms / unreachable%b\n\n' "$RED" "$RESET"
best_loc=""
best_ip=""
best_avg=""
for row in "${sorted[@]}"; do
IFS=$'\t' read -r region location ip min avg max mdev <<< "$row"
printf '%-16s %-25s %-17s ' "$region" "$location" "$ip"
colored_field 8 "$min"; printf ' '
colored_field 8 "$avg"; printf ' '
colored_field 8 "$max"; printf ' '
printf '%8s\n' "$mdev"
[[ -z "$best_loc" && "$avg" != "N/A" ]] && {
best_loc="$location"; best_ip="$ip"; best_avg="$avg"
}
done
printf '%b%s%b\n' "$DIM" "$SEP" "$RESET"
if [[ -n "$best_loc" ]]; then
printf '\n%bLowest avg latency:%b %b%s%b %b%s%b → avg %b%s ms%b\n\n' \
"$BOLD" "$RESET" \
"$GREEN" "$best_loc" "$RESET" \
"$DIM" "$best_ip" "$RESET" \
"$GREEN" "$best_avg" "$RESET"
else
printf '\n%bNo hubs responded.%b\n\n' "$RED" "$RESET"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment