Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit c588cea

Browse files
committed
fix ssl status check, support http verfication, sort menu order
1 parent fdece27 commit c588cea

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

cloudflare-partner-cli.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
"User": "用户",
5454
"Subdomain": "子域名",
5555
"Resolve to": "源站地址",
56+
"Content": "内容",
5657
"Login as %s": "%s 已登录",
5758
"vetting": "审批中",
5859
"validating": "等待验证",
5960
"ready": "已启用",
61+
"none": "未知",
6062
"Select your action:": "选择所需的操作,输入数字:",
6163
"Missing required arg \"%s\". (act:%s)": "缺少参数 \"%s\". (act:%s)",
6264
"Login failed, msg: %s": "登录失败: %s",
@@ -73,6 +75,8 @@
7375
"??? %s": "喵喵喵? %s",
7476
"Please set CNAME record of %s to %s and run this option again after record become effective":
7577
"请将%s的CNAME记录设置为%s, 然后在解析生效后再运行一次\"开通SSL\"",
78+
"Please create a file with the following content and run this option again after record become effective:":
79+
"请新建文件使下列URL能访问到指定的内容,然后再运行一次\"开通SSL\":",
7680
"Can't delete root record": "不能删除根域名",
7781
"Record %s is deleted": "DNS记录%s已删除",
7882
"Record %s is not found in zone %s": "记录%s不存在于域名%s中",
@@ -210,9 +214,18 @@ def ssl_verfication(self, arg):
210214
log("SSL for domain %s has already been activated.", arg['zone'])
211215
return True
212216
verification_info = r['result'][0]['verification_info']
213-
log("Please set CNAME record of %s to %s and run this option again after record become effective", (
214-
verification_info['record_name'].encode('utf-8'), verification_info['record_target'].encode('utf-8')))
215-
217+
if 'record_name' in verification_info: # DNS verification
218+
log("Please set CNAME record of %s to %s and run this option again after record become effective", (
219+
verification_info['record_name'].encode('utf-8'), verification_info['record_target'].encode('utf-8')))
220+
else: # HTTP verification
221+
log("Please create a file with the following content and run this option again after record become effective:")
222+
print("%-90s%s" % (i18n("URL"), i18n("Content")))
223+
print("-" * 80)
224+
print("\n".join(map(lambda x: "%-90s%s" % (
225+
x['verification_info']['http_url'],
226+
x['verification_info']['http_body']),
227+
r['result'])))
228+
216229
def add_subdomain(self, arg):
217230
r = self._hostapi("zone_lookup", {"zone_name": arg['zone_name']})
218231
if 'hosted_cnames' not in r['response'] or not r['response']['hosted_cnames']:
@@ -295,7 +308,7 @@ def _zone_lookup(self, j):
295308
ssl_cname = z.encode('utf-8')
296309
ssl_resolve_to = hosted[z].encode('utf-8')
297310
continue
298-
print("%-32s%-24s%-32s" % (z, hosted[z], tos[z]))
311+
print("%-32s%-32s%-32s" % (z, hosted[z], tos[z]))
299312
if ssl_cname and j['response']['ssl_status'] != "ready":
300313
print("")
301314
log("If you want to activate SSL, please set CNAME record of %s to %s and " \
@@ -330,7 +343,7 @@ def check_hostkey(force = False):
330343

331344
def menu(act = None):
332345
if not act:
333-
acts = [k for k in CFARG.keys() if k != "user_auth"] + ["logout"]
346+
acts = [k for k in sorted(CFARG.keys()) if k != "user_auth"] + ["logout"]
334347
print("=" * 32)
335348
print(i18n("Select your action:"))
336349
for i in range(len(acts)):

0 commit comments

Comments
 (0)