Skip to content

Commit 265a1cd

Browse files
authored
Merge pull request #113 from KeyPJ/cloudflare-use-api-token
Cloudflare use api token
2 parents becc3e8 + d6bc54e commit 265a1cd

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ python run.py -c /path/to/config.json
105105

106106
| key | type | required | default | description | tips |
107107
| :----: | :---------: | :------: | :---------: | :--------------: | ----------------------------------------------------------------- |
108-
| id | string ||| api 访问 ID | cloudflare 为邮箱,<br>HE.net 可留空 |
108+
| id | string ||| api 访问 ID | cloudflare 为邮箱(使用api token可为空,但对应的token需要Zone权限),<br>HE.net 可留空 |
109109
| token | string ||| api 授权 token | 也叫 secret key, **反馈粘贴时删除** |
110110
| dns | string | No | `"dnspod"` | dns 服务商 | 阿里`alidns`,<br>dns.com 为`dnscom`,<br>DNSPOD 国际版`dnspod_com`,<br>HE.net 为`he` |
111111
| ipv4 | array | No | `[]` | ipv4 域名列表 |`[]`时,不会获取和更新 IPv4 地址 |

dns/cloudflare.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def request(method, action, param=None, **params):
5656
if params:
5757
action += '?' + urlencode(params)
5858
params = None
59-
conn.request(method, '/client/v4/zones' + action, params,
60-
{"Content-type": "application/json",
61-
"X-Auth-Email": Config.ID,
62-
"X-Auth-Key": Config.TOKEN})
59+
if Config.ID is None:
60+
headers = {"Content-type": "application/json", "Authorization": "Bearer " + Config.TOKEN}
61+
else:
62+
headers = {"Content-type": "application/json", "X-Auth-Email": Config.ID, "X-Auth-Key": Config.TOKEN}
63+
conn.request(method, '/client/v4/zones' + action, params, headers)
6364
response = conn.getresponse()
6465
res = response.read().decode('utf8')
6566
conn.close()

schema/v2.8.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
},
1818
"id": {
1919
"$id": "/properties/id",
20-
"type": "string",
20+
"type": [
21+
"string",
22+
"null"
23+
],
2124
"title": "ID or Email",
2225
"description": "DNS服务API认证的ID或者邮箱"
2326
},

0 commit comments

Comments
 (0)