我使用一个 python 脚本,它允许我在配置/选择的 Cloudflare DNS 条目上自动更新我的 Raspberry Pi 的公共(public) IP。这是通过 Cloudflare API 完成的。
看起来 API 中的代理参数现在默认为 false,这会禁用 Cloudflare 保护。
我已经创建了 Cloudflare 支持票证并得到了以下答复:
在 api 调用中设置 proxied = true 将在更新记录时设置 Cloudflare 保护。
不幸的是,我还不会用 Python 编程,所以我无法解决这个问题。
原文:
data=json.dumps({'type': record['type'], 'name': record['name'], 'content': ip_address}),
我的尝试:
data=json.dumps({'type': record['type'], 'name': record['name'], 'content': ip_address, 'proxied':'true'}),
我在尝试将 proxied 设置为 true 时收到这些错误消息:
Updating the A record (ID 28b768cfd9760226648f3f22880bff7d) of (sub)domain www.******.com (ID 5129ccb06da9ae49f0a326ef945ff3e4) to **.**.***.**.
DNS record failed to update.
CloudFlare returned the following errors: [{u'error_chain': [{u'message': u"Invalid 'proxied' value, must be a boolean", u'code': 9003}], u'message': u'DNS Validation Error', u'code': 1004}].
CloudFlare returned the following messages: []
Updating the A record (ID f0269da1fab6dcad62c31755f98a6321) of (sub)domain ******.com (ID 5129ccb06da9ae49f0a326ef945ff3e4) to **.**.***.**.
DNS record failed to update.
CloudFlare returned the following errors: [{u'error_chain': [{u'message': u"Invalid 'proxied' value, must be a boolean", u'code': 9003}], u'message': u'DNS Validation Error', u'code': 1004}].
CloudFlare returned the following messages: []
完整的 python 脚本:
GitHub view
Raw
这样做的正确方法是什么?
提前致谢
最佳答案
将 'proxied':'true'
更改为 'proxied': True
以使其成为 bool 值而不是字符串。
关于python - Cloudflare API 将代理参数默认为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56477450/