diff --git a/dns.py b/dns.py new file mode 100755 index 0000000..d4816b6 --- /dev/null +++ b/dns.py @@ -0,0 +1,56 @@ +#!/bin/python3 +# @Author skiqqy +import requests +import os +import json + +f = open("secret/godaddy_key", "r") + +secret = "" +key = "" +for line in f: + line = line.replace("\n","") + parse = line.split(":") + if parse[0] == "secret": + secret = parse[1] + elif parse[0] == "key": + key = parse[1] + +if secret == "" or key == "": + print("No key or secret set") + exit(1) + +url="https://api.godaddy.com/" + +header={ + "content-type":"application/json", + "Authorization":"sso-key " + key + ":" + secret + } + + +# Domains and subdomains +domains = { + "skiqqy.xyz":[ + {"name": "git", "type": "A"}, + {"name": "irc", "type": "A"}, + {"name": "proj", "type": "A"}, + {"name": "pay", "type": "A"}, + ] + } + +# Get current public ip +ip = os.popen('curl ifconfig.me').read() + +# Construct the post data +for domain in domains: + post = [{}] + for sub in domains[domain]: + post[0]["type"] = sub["type"] + post[0]["name"] = sub["name"] + post[0]["data"] = ip + post[0]["ttl"] = 3600 + + # Do the put + req_url = url + "v1/domains/" + domain + "/records/" + sub["type"] + "/" + sub["name"] + r = requests.put(req_url, headers=header, json=post) + print(r)