Advertisement
vicf

bash proxy checker 2

Dec 7th, 2022 (edited)
1,209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. #! /bin/bash
  2. # $PROG: All type proxies checker, default proxy type is "socks5" if no argument given
  3. # long running period due to big proxies list, be patient.
  4.  
  5. usage="${0##*/} [socks5|socks4|http|https]"
  6. list="https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/json/proxies.json"
  7. check="https://ipwho.is"
  8. arg=$1
  9. : ${arg:=socks5}
  10. OIFS=$IFS
  11. IFS='
  12. '
  13. case "$arg" in
  14.         socks5) proxy=($(curl -s "$list" | jq -r '.socks5' | tr -d '[ ]",')) ;;
  15.         socks4) proxy=($(curl -s "$list" | jq -r '.socks4' | tr -d '[ ]",')) ;;
  16.         http) proxy=($(curl -s "$list" | jq -r '.http' | tr -d '[ ]",')) ;;
  17.         https) proxy=($(curl -s "$list" | jq -r '.https' | tr -d '[ ]",')) ;;
  18.         *) echo "$usage" >&2 ; exit 5 ;;
  19. esac
  20.  
  21. count="${#proxy[@]}"
  22. min=0
  23. max=$((count - 1))
  24. while (( min <= max ))  ; do
  25.         ip="${proxy[$min]//:*}"
  26.         port="${proxy[$min]//*:}"
  27.         if ping -c3 "$ip" &> /dev/null ; then
  28.                 info=$(curl -x "$arg://${proxy[$min]}" --connect-timeout 10 -s "$check" | jq -r -c '.country,.region')
  29.                 if [ -n "$info" ] ; then
  30.                         echo "Worked $arg proxy"
  31.                         echo "IP: $ip"
  32.                         echo "PORT: $port"
  33.                         echo "Location: $info"
  34.                         echo ""
  35.                 fi
  36.         fi
  37.         (( min++ ))
  38. done
  39.  
  40. unset IFS
  41. IFS=$OIFS
  42. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement