ulygit / asus_rt_ac68u

Configuration and script for Cloudflare DDNS on Asuswrt-Merlin
MIT License
58 stars 24 forks source link

"Invalid TTL. Must be between 120 and 2,147,483,647 seconds, or 1 for automatic" #6

Closed bengalih closed 4 years ago

bengalih commented 4 years ago

I'm not sure what is going on here with CF API. Seems like they made a few changes.

I can't update my records anymore because I get the above error. Log looks more like:

"errors": [ { "code": 9021, "message": "Invalid TTL. Must be between 120 and 2,147,483,647 seconds, or 1 for automatic" } ], "messages": []

Seems they are insisting the TTL is actually sent as part of the request now as opposed to just assuming the default (Auto). To set to auto you need to send integer 1.

Existing code can be fixed by changing:

https://github.com/ulygit/asus_rt_ac68u/blob/116e522ea4dffdc63c2470ba795edaea32e3f22e/cloudflare_ddns#L51-L52

to:

curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$DNS_ZONE_ID/dns_records/$DNS_RECORD_ID" \ --data "{\"type\":\"$DNS_RECORD_TYPE\",\"name\":\"$DNS_RECORD_NAME\",\"content\":\"$NEW_IP\",\"TTL\":1}"

After that I was able to successfully update.

ulygit commented 4 years ago

Yes, I see TTL is now a required field. I'll look at this tomorrow. Thanks!

ulygit commented 4 years ago

Strangely, TTL does not seem to be required for me. I'm able to update without it just fine. I wonder if it's to do with when the zone was created or when API access began. I tried updating with the new token-auth and with the old email-auth, but both seem to work.

If you can submit a new PR with lowercase 'ttl' to maintain consistent casing, I'll go ahead and merge your PR in case someone else runs into your problem.

Thanks!

bengalih commented 4 years ago

I just tested again removing the TTL change and it is working for me now. When I googled this issue I saw several instance of this dating back a couple of years. I have a feeling that CF occasionally flips a switch or does some kind of maintenance where there systems start requiring this. It probably was a fluke I happened to be testing during the day or two this was an issue, but it definitely was during this time. While it may not be required, I think it is worth having it in there as a safety.

bengalih commented 4 years ago

I edited the current PR to lower case. I'm unsure why this wouldn't be acceptable/preferable to creating a new PR (I'm still new to GH workflow). If you actually want me to close this PR and open an entirely new one let me know.