Created
April 17, 2012 18:57
-
-
Save thefinn93/2408260 to your computer and use it in GitHub Desktop.
Cloudflare DDNS
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
#!/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