Added configurable TTL option, plus documentation
This commit is contained in:
parent
2b9ebdeab2
commit
ef4e3a5787
@ -78,6 +78,7 @@ Some ISP provided modems only allow port forwarding over IPv4 or IPv6. In this c
|
||||
"zone_id": "The ID of the zone that will get the records. From your dashboard click into the zone. Under the overview tab, scroll down and the zone ID is listed in the right rail",
|
||||
"subdomains": "Array of subdomains you want to update the A & where applicable, AAAA records. IMPORTANT! Only write subdomain name. Do not include the base domain name. (e.g. foo or an empty string to update the base domain)",
|
||||
"proxied": false (defaults to false. Make it true if you want CDN/SSL benefits from cloudflare. This usually disables SSH)
|
||||
"ttl": "Defaults to 300 seconds. Longer TTLs speed up DNS lookups by increasing the chance of cached results, but a longer TTL also means that updates to your records take longer to go into effect. You can choose a TTL between 30 seconds and 1 day. For more information, see [Cloudflare's TTL documentation](https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl/)",
|
||||
```
|
||||
|
||||
## 📠 Hosting multiple subdomains on the same IP?
|
||||
|
||||
@ -96,6 +96,7 @@ def getIPs():
|
||||
|
||||
|
||||
def commitRecord(ip):
|
||||
global ttl
|
||||
for option in config["cloudflare"]:
|
||||
subdomains = option["subdomains"]
|
||||
response = cf_api("zones/" + option['zone_id'], "GET", option)
|
||||
@ -103,7 +104,6 @@ def commitRecord(ip):
|
||||
time.sleep(5)
|
||||
return
|
||||
base_domain_name = response["result"]["name"]
|
||||
ttl = 300 # default Cloudflare TTL
|
||||
for subdomain in subdomains:
|
||||
name = subdomain["name"].lower().strip()
|
||||
fqdn = base_domain_name
|
||||
@ -229,6 +229,15 @@ if __name__ == '__main__':
|
||||
except:
|
||||
purgeUnknownRecords = False
|
||||
print("⚙️ No config detected for 'purgeUnknownRecords' - defaulting to False")
|
||||
try:
|
||||
ttl = int(config["ttl"])
|
||||
except:
|
||||
ttl = 300
|
||||
print(
|
||||
"⚙️ No config detected for 'ttl' - defaulting to 300 seconds (5 minutes)")
|
||||
if ttl < 30:
|
||||
ttl = 30 # default Cloudflare TTL
|
||||
print("⚙️ TTL is too low - defaulting to 60 seconds (1 minute)")
|
||||
if(len(sys.argv) > 1):
|
||||
if(sys.argv[1] == "--repeat"):
|
||||
delay = 5*60
|
||||
|
||||
@ -23,5 +23,6 @@
|
||||
],
|
||||
"a": true,
|
||||
"aaaa": true,
|
||||
"purgeUnknownRecords": false
|
||||
"purgeUnknownRecords": false,
|
||||
"ttl": 300
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user