Skip to content

Instantly share code, notes, and snippets.

@Fluxflashor
Created March 5, 2013 19:00
Show Gist options
  • Save Fluxflashor/5093112 to your computer and use it in GitHub Desktop.
Save Fluxflashor/5093112 to your computer and use it in GitHub Desktop.
api_url = "https://api.github.com/"
request_ip = "204.232.175.75"
# get a list of ips from github
def gh_api_req(path):
try:
request_data = urllib2.urlopen(api_url+path).read()
except urllib2.HTTPError, e:
print "HTTP Error: %d" % e.code
return json.loads(request_data)
meta = gh_api_req("meta")
for ipcidr in meta['hooks']:
if ipaddr.IPAddress(request_ip) in ipaddr.IPNetwork(ipcidr):
print "YES"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment