#!/usr/bin/env bash #use for test proxy available and speed #fping fast check available ping #curl to check available connect #copy https://hidemy.name/cn/proxy-list/ 's ul tag's content about ip and port in a single file,you can append multi page in a single file #then run this script with parameter and file's name if [ $# != 2 ]; then echo "help your to find the best available proxy server sort by speed" echo "usage:`basename $0` -3 filename (http/https filter)" echo " :`basename $0` -4 filename (socks4 filter)" echo " :`basename $0` -5 filename (socks5 filter)" exit -1 fi cat $2|grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}"|awk '{print $1,$2}' > /tmp/hostlist cat /tmp/hostlist|awk '{print $1}'|xargs -I % sh -c 'fping -c1 -t500 %' > /tmp/ping_host cat /tmp/ping_host |grep bytes|awk '{print $1,$6}'|uniq|sort -k2 -g > /tmp/sort_ping_host cat /tmp/sort_ping_host|awk '{print $1}'|xargs -I % sh -c 'cat /tmp/hostlist|grep %' > /tmp/host_result if [ ${1} == '-3' ]; then cat /tmp/host_result|sort|uniq|awk '{print "http",$1,$2}' > /tmp/fastproxylist cat /tmp/fastproxylist |awk '{position=$2":"$3;print position}'|xargs -I % sh -c 'curl --proxy % --connect-timeout 5 -s https://ipinfo.io/ip 2>&1>/dev/null && (echo http %|tee -a proxy.txt)' fi if [ ${1} == '-4' ]; then cat /tmp/host_result|sort|uniq|awk '{print "socks4",$1,$2}' > /tmp/fastproxylist cat /tmp/fastproxylist |awk '{position=$2":"$3;print position}'|xargs -I % sh -c 'curl --socks4 % --connect-timeout 5 -s https://ipinfo.io/ip 2>&1>/dev/null && (echo socks4 %|tee -a proxy.txt)' fi if [ ${1} == '-5' ]; then cat /tmp/host_result|sort|uniq|awk '{print "socks5",$1,$2}' > /tmp/fastproxylist cat /tmp/fastproxylist |awk '{position=$2":"$3;print position}'|xargs -I % sh -c 'curl --socks5 % --connect-timeout 5 -s https://ipinfo.io/ip 2>&1>/dev/null && (echo socks5 %|tee -a proxy.txt)' fi