55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Force GoDaddy registrar NS to Cloudflare."""
|
|
import json
|
|
import time
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
KEY = "2wYVpc3VT4_Gi9AsNqzJ6BtSfNz6nLDuo"
|
|
SECRET = "NvC3qexGAU7Rd5QExUTH6z"
|
|
DOMAIN = "exposedgays.com"
|
|
CF_NS = ["annabel.ns.cloudflare.com", "mitchell.ns.cloudflare.com"]
|
|
GD = "https://api.godaddy.com/v1"
|
|
|
|
|
|
def gd(path, method="GET", body=None):
|
|
req = urllib.request.Request(
|
|
GD + path,
|
|
data=json.dumps(body).encode() if body is not None else None,
|
|
method=method,
|
|
headers={
|
|
"Authorization": f"sso-key {KEY}:{SECRET}",
|
|
"Content-Type": "application/json",
|
|
"Accept": "application/json",
|
|
},
|
|
)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=45) as r:
|
|
raw = r.read().decode()
|
|
return r.status, json.loads(raw) if raw else {}
|
|
except urllib.error.HTTPError as e:
|
|
raw = e.read().decode()
|
|
try:
|
|
return e.code, json.loads(raw)
|
|
except Exception:
|
|
return e.code, {"raw": raw[:500]}
|
|
|
|
|
|
code, d = gd(f"/domains/{DOMAIN}")
|
|
print("Before:", d.get("nameServers"))
|
|
|
|
# Try PUT instead of PATCH
|
|
code, res = gd(f"/domains/{DOMAIN}", "PATCH", {"nameServers": CF_NS, "locked": False})
|
|
print(f"PATCH HTTP {code}: {res}")
|
|
|
|
time.sleep(3)
|
|
code, d = gd(f"/domains/{DOMAIN}")
|
|
print("After:", d.get("nameServers"))
|
|
|
|
# Also try nameservers endpoint if exists
|
|
code, res = gd(f"/domains/{DOMAIN}/nameservers", "PUT", CF_NS)
|
|
print(f"PUT /nameservers HTTP {code}: {res}")
|
|
|
|
time.sleep(3)
|
|
code, d = gd(f"/domains/{DOMAIN}")
|
|
print("Final:", d.get("nameServers")) |