Skip to content

Instantly share code, notes, and snippets.

@thefinn93
Created April 17, 2012 18:57
Show Gist options
  • Save thefinn93/2408260 to your computer and use it in GitHub Desktop.
Save thefinn93/2408260 to your computer and use it in GitHub Desktop.
Cloudflare DDNS
#!/usr/bin/env python
import sys
try:
import requests
except:
"Install python requests asshole!"
sys.exit()
import json
if len(sys.argv) != 4:
print "Use: " + sys.argv[0] + " <email> <API key> <hostname>"
ip = requests.get("http://icanhazip.com").content;
response = requests.get("https://www.cloudflare.com/api_json?a=DIUP&u=" + sys.argv[1] + "&tkn=" + sys.argv[2] + "&hosts=" + sys.argv[3] + "&ip=" + ip)
parsed = json.loads(response.content)
if parsed['result'] == "success":
print "Successfully updated"
else:
print parsed.msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment