Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Dec 21, 2024
1 parent 48468a1 commit 649990f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion web/admin/site/ssl_acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_acme():
apply_type = request.form.get('apply_type', 'file')
dnspai = request.form.get('dnspai','')
dns_alias = request.form.get('dns_alias','')
return MwSites.instance().createAcme(site_name, domains, force, renew, apply_type, dnspai, email, wildcard_domain)
return MwSites.instance().createAcme(site_name, domains, force, renew, apply_type, dnspai, email, wildcard_domain,dns_alias)



Expand Down
13 changes: 11 additions & 2 deletions web/static/app/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,11 @@ function opSSLAcme(type, id, siteName, callback){
<span class="tname text-center">邮箱</span>\
<input class="bt-input-text" style="width:240px;" type="text" name="admin_email" />\
</div>\
<div class="line mtb10" id="dns_alias" style="display:none;">\
<span class="tname text-center">别名验证</span>\
<input class="bt-input-text" style="width:240px;" type="text" name="dns_alias" />\
<span> (可不填) <a class="btlink" target="_blank" href="https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode#7-challenge-alias-or-domain-alias">文档说明</a><span>\
</div>\
<div class="line mtb10">\
<span class="tname text-center">域名</span>\
<ul id="ymlist" style="padding: 5px 10px;max-height:180px;overflow:auto; width:240px;border:#ccc 1px solid;border-radius:3px"></ul>\
Expand All @@ -2334,9 +2339,11 @@ function opSSLAcme(type, id, siteName, callback){
if (val == 'file'){
$('#dnsapi_option').css('display','none');
$('#wildcard_domain_block').css('display','none');
$('#dns_alias').css('display','none');
} else {
$('#dnsapi_option').css('display','block');
$('#wildcard_domain_block').css('display','block');
$('#dns_alias').css('display','block');
}
});

Expand Down Expand Up @@ -2673,11 +2680,10 @@ function newAcmeHandApplyNotice(siteName, id, domains, data){
<ul id="acme_hand_ssl_notice_help" class="help-info-text c6">\
<li>解析域名需要一定时间来生效,完成所以上所有解析操作后,请等待1分钟后再点击【验证】按钮</li>\
<li>可通过CMD命令来手动验证域名解析是否生效: nslookup -q=txt _acme-challenge.xx.cn</li>\
<li>若您使用的是阿里云DNS,DnsPod作为DNS,可使用DNS接口自动解析</li>\
<li>若您使用的是阿里云DNS,DnsPod等等作为DNS,可使用DNS接口自动解析</li>\
</ul>\
</div>',
success:function(){

var list = '';
for (var i = 0; i < data.length; i++) {
list += '<tr>';
Expand Down Expand Up @@ -2720,6 +2726,8 @@ function newAcmeHandApplyNotice(siteName, id, domains, data){
if (apply_type == 'dns'){
pdata['dnspai'] = $('#dnsapi_option option:selected').val();
}
pdata['dns_alias'] = $("input[name='dns_alias']").val();

pdata['renew'] = 'true';
$.post('/site/create_acme',pdata,function(rdata){
showMsg(rdata.msg, function(){
Expand Down Expand Up @@ -2755,6 +2763,7 @@ function newAcmeSSL(siteName, id, domains){
pdata['dnspai'] = $('#dnsapi_option option:selected').val();
}

pdata['dns_alias'] = $("input[name='dns_alias']").val();
$.post('/site/create_acme',pdata,function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
Expand Down
17 changes: 12 additions & 5 deletions web/utils/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ def findAcmeHandDnsNotice(self, top_domain):

# acme手动申请方式
# https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode
def createAcmeDnsTypeNone(self, site_name, domains, email, dnspai, wildcard_domain, force, renew):
def createAcmeDnsTypeNone(self, site_name, domains, email, dnspai, wildcard_domain, force, renew, dns_alias):
# print(site_name, domains, email, dnspai, wildcard_domain, force, renew)
acme_dir = mw.getAcmeDir()
log_file = self.acmeLogFile()
Expand All @@ -2302,6 +2302,9 @@ def createAcmeDnsTypeNone(self, site_name, domains, email, dnspai, wildcard_doma
cmd += "acme.sh --issue -d " + d + " "
cmd += " --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please"

if dns_alias != '':
cmd += ' --domain-alias '+str(dns_alias)

if renew == 'true':
cmd += " --renew"
cmd += ' > ' + log_file
Expand Down Expand Up @@ -2341,15 +2344,15 @@ def createAcmeDnsTypeNone(self, site_name, domains, email, dnspai, wildcard_doma
mw.restartWeb()
return mw.returnData(True, '证书已更新!', result)

def createAcmeDns(self, site_name, domains, email, dnspai, wildcard_domain, force, renew):
def createAcmeDns(self, site_name, domains, email, dnspai, wildcard_domain, force, renew, dns_alias):
dnsapi_option = thisdb.getOptionByJson('dnsapi', default={})
log_file = self.acmeLogFile()
cmd = 'echo "..." > '+ log_file
mw.execShell(cmd)

# 手动方式申请
if dnspai == 'none':
return self.createAcmeDnsTypeNone(site_name, domains, email, dnspai, wildcard_domain, force, renew)
return self.createAcmeDnsTypeNone(site_name, domains, email, dnspai, wildcard_domain, force, renew, dns_alias)

if not dnspai in dnsapi_option:
return mw.returnData(False, '['+dnspai+']未设置!')
Expand All @@ -2375,6 +2378,10 @@ def createAcmeDns(self, site_name, domains, email, dnspai, wildcard_domain, forc
d = top_domain
else:
cmd += 'acme.sh --issue --dns '+str(dnspai)+' -d '+d

if dns_alias != '':
cmd += ' --domain-alias '+str(dns_alias)

cmd += ' > ' + log_file
# print(cmd)
result = mw.execShell(cmd)
Expand Down Expand Up @@ -2424,7 +2431,7 @@ def createAcmeDns(self, site_name, domains, email, dnspai, wildcard_domain, forc
mw.restartWeb()
return mw.returnData(True, '证书已更新!', result)

def createAcme(self, site_name, domains, force, renew, apply_type, dnspai, email, wildcard_domain):
def createAcme(self, site_name, domains, force, renew, apply_type, dnspai, email, wildcard_domain, dns_alias):
domains = json.loads(domains)
if len(domains) < 1:
return mw.returnData(False, '请选择域名')
Expand Down Expand Up @@ -2452,7 +2459,7 @@ def createAcme(self, site_name, domains, force, renew, apply_type, dnspai, email
if apply_type == 'file':
return self.createAcmeFile(site_name, domains, email,force,renew)
elif apply_type == 'dns':
return self.createAcmeDns(site_name, domains, email, dnspai, wildcard_domain,force, renew)
return self.createAcmeDns(site_name, domains, email, dnspai, wildcard_domain,force, renew, dns_alias)
return mw.returnData(False, '异常请求')

def createLet(self, site_name, domains, force, renew, apply_type, dnspai, email, wildcard_domain):
Expand Down

0 comments on commit 649990f

Please sign in to comment.