-
-
Save qxo/4af8f31efe04319c3c90 to your computer and use it in GitHub Desktop.
Gist generate registry.npmjs.org hosts for dnsmasq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ips=$(host -t any a.sni.fastly.net | awk '{print $4}' | egrep '^[0-9]') ; echo $ips; ipList="";ipCount=0;okCount=0; for ip in $ips ; do echo "checking $ip ..."; ipCount=$[ipCount+1];p='archy';s=$(curl -k https://$ip/$p -H host:registry.npmjs.org --connect-timeout 1 -m 3 -s -H accept:application/json | jq '._id') ; echo " result:$s"; if [ "$s" = "\"$p\"" ] ; then ipList="$ipList $ip";okCount=$[okCount+1]; echo "$ip is ok"; else echo "$ip is not ok:("; fi ; done ; echo " $ipCount ok ip list $okCount: $ipList" ; echo "====>"; echo "copy one of below lines to hosts:"; for ip in $ipList; do echo "$ip registry.npmjs.org" ; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment