Skip to content

Instantly share code, notes, and snippets.

@qxo
Forked from isaacs/gist:11404998
Last active August 29, 2015 14:06
Show Gist options
  • Save qxo/4af8f31efe04319c3c90 to your computer and use it in GitHub Desktop.
Save qxo/4af8f31efe04319c3c90 to your computer and use it in GitHub Desktop.
Gist generate registry.npmjs.org hosts for dnsmasq
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