From cbfd628f22cf19507e7be4302f4968fe422ac25e Mon Sep 17 00:00:00 2001 From: KenWong Date: Sat, 12 Dec 2020 21:18:44 +0800 Subject: [PATCH] add option ttl Signed-off-by: KenWong --- cloudflare-ddns.py | 6 +++++- config-example.json | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cloudflare-ddns.py b/cloudflare-ddns.py index 6270d04..65a1824 100755 --- a/cloudflare-ddns.py +++ b/cloudflare-ddns.py @@ -48,13 +48,17 @@ def commitRecord(ip): subdomains = c["subdomains"] response = cf_api("zones/" + c['zone_id'], "GET", c) base_domain_name = response["result"]["name"] + ttl = 120 + if "ttl" in c: + ttl=c["ttl"] for subdomain in subdomains: exists = False record = { "type": ip["type"], "name": subdomain, "content": ip["ip"], - "proxied": c["proxied"] + "proxied": c["proxied"], + "ttl": ttl } list = cf_api( "zones/" + c['zone_id'] + "/dns_records?per_page=100&type=" + ip["type"], "GET", c) diff --git a/config-example.json b/config-example.json index 3de729b..5bc8473 100755 --- a/config-example.json +++ b/config-example.json @@ -13,7 +13,8 @@ "", "subdomain" ], - "proxied": false + "proxied": false, + "ttl": 120 } ] }