-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from midoks/dev
0.17.3
- Loading branch information
Showing
74 changed files
with
5,985 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE TABLE IF NOT EXISTS `dnsapi` ( | ||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, | ||
`name` TEXT, | ||
`type` TEXT, | ||
`val` TEXT, | ||
`remark` TEXT, | ||
`addtime` TEXT | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS `email` ( | ||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, | ||
`addr` TEXT, | ||
`remark` TEXT, | ||
`addtime` TEXT | ||
); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS `domain` ( | ||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, | ||
`domain` TEXT, | ||
`dnsapi_id` TEXT, | ||
`email` TEXT, | ||
`remark` TEXT, | ||
`effective_date` TEXT, | ||
`expiration_date` TEXT, | ||
`error` TEXT, | ||
`status` INTEGER default '0', | ||
`addtime` TEXT | ||
); | ||
|
||
-- ALTER TABLE `domain` ADD COLUMN `effective_date` TEXT DEFAULT ''; | ||
-- ALTER TABLE `domain` ADD COLUMN `expiration_date` TEXT DEFAULT ''; | ||
-- ALTER TABLE `domain` ADD COLUMN `error` TEXT DEFAULT ''; | ||
-- ALTER TABLE `domain` ADD COLUMN `status` INTEGER DEFAULT '0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# coding:utf-8 | ||
|
||
import sys | ||
import io | ||
import os | ||
import time | ||
import re | ||
import requests | ||
import base64 | ||
|
||
|
||
# 8001 / 7788 | ||
goedge_addr = 'http://127.0.0.2:8009' | ||
access_keyid = "xxx" | ||
access_key = "xxx" | ||
|
||
# 指定用户 | ||
userId = 1 | ||
|
||
sys.path.append(os.getcwd() + "/class/core") | ||
import mw | ||
|
||
domain = sys.argv[1] | ||
ssl_path = sys.argv[2] | ||
|
||
|
||
def getToken(): | ||
api_url = goedge_addr+'/APIAccessTokenService/getAPIAccessToken' | ||
post_data = { | ||
"type": "admin", | ||
"accessKeyId": access_keyid, | ||
"accessKey": access_key | ||
} | ||
data = requests.post(api_url,json=post_data) | ||
data_obj = data.json() | ||
|
||
return data_obj['data']['token'] | ||
|
||
token = getToken() | ||
|
||
def commonReq(url, data): | ||
headers = { | ||
'X-Edge-Access-Token': token | ||
} | ||
api_url = goedge_addr+url | ||
resp_data = requests.post(api_url,json=data, headers=headers) | ||
return resp_data.json() | ||
|
||
def listSSLCerts(domain): | ||
request_data = { | ||
"userId":userId, | ||
"isCA":False, | ||
"keyword": "ACME泛域名自动上传", | ||
"domains":[domain,"*."+domain], | ||
"size":1 | ||
} | ||
response_data = commonReq('/SSLCertService/listSSLCerts', request_data) | ||
|
||
data = response_data['data']['sslCertsJSON'] | ||
data = mw.base64StrDecode(data) | ||
data = mw.getObjectByJson(data) | ||
# print(data) | ||
return data | ||
|
||
|
||
|
||
# createSSLCert(domain) | ||
def createSSLCert(domain, did=0): | ||
|
||
ssl_cer_file = ssl_path + '/'+domain+'.cer' | ||
|
||
if not os.path.exists(ssl_cer_file): | ||
print("没有有效证书!") | ||
return '' | ||
# print(ssl_cer_file) | ||
ssl_info = mw.getCertName(ssl_cer_file) | ||
cer_data = mw.readFile(ssl_cer_file) | ||
cer_data = mw.base64StrEncode(cer_data) | ||
# print('cer',cer_data) | ||
|
||
ssl_key_file = ssl_path + '/'+domain+'.key' | ||
key_data = mw.readFile(ssl_key_file) | ||
key_data = mw.base64StrEncode(key_data) | ||
# print('ssl_info',ssl_info) | ||
|
||
timeBeginAt = int(time.mktime(time.strptime(ssl_info['notBefore'], "%Y-%m-%d"))) | ||
timeEndAt = int(time.mktime(time.strptime(ssl_info['notAfter'], "%Y-%m-%d"))) | ||
|
||
request_data = { | ||
"isOn":True, | ||
"userId":userId, | ||
"name": "ACME泛域名自动上传", | ||
"isCA":False, | ||
"description":domain, | ||
"serverName":domain, | ||
"certData":cer_data, | ||
"keyData":key_data, | ||
"timeBeginAt":timeBeginAt, | ||
"timeEndAt": timeEndAt, | ||
"dnsNames":[domain,"*."+domain], | ||
"commonNames":[ssl_info['issuer']] | ||
} | ||
|
||
if did>0: | ||
request_data['sslCertId'] = did | ||
# print(request_data) | ||
response_data = commonReq('/SSLCertService/updateSSLCert', request_data) | ||
print('更新成功',domain,response_data) | ||
return response_data | ||
else: | ||
# print(request_data) | ||
response_data = commonReq('/SSLCertService/createSSLCert', request_data) | ||
print('创建成功',domain,response_data) | ||
return response_data | ||
return response_data | ||
|
||
def autoSyncDomain(domain): | ||
data = listSSLCerts(domain) | ||
if len(data) > 0 : | ||
did = data[0]['id'] | ||
createSSLCert(domain,did) | ||
else: | ||
createSSLCert(domain) | ||
print(data) | ||
|
||
|
||
autoSyncDomain(domain) | ||
print(domain,ssl_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# coding:utf-8 | ||
|
||
import sys | ||
import io | ||
import os | ||
import time | ||
import re | ||
|
||
domain = sys.argv[1] | ||
path = sys.argv[2] | ||
|
||
print(domain,path) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<style> | ||
.overflow_hide { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
vertical-align: middle; | ||
} | ||
</style> | ||
|
||
<div class="bt-form"> | ||
<div class='plugin_version'></div> | ||
<div class="bt-w-main"> | ||
<div class="bt-w-menu"> | ||
<p class="bgw" onclick="pluginService('acme_pandominassl_apply');">服务</p> | ||
<p onclick="dnsapiList();">DNSAPI *</p> | ||
<p onclick="emailList();">邮件地址 </p> | ||
<p onclick="domainList()">域名SSL *</p> | ||
<p onclick="pluginConfigTpl('acme_pandominassl_apply',$('.plugin_version').attr('version'));">HOOK</p> | ||
<p onclick="pluginLogs('acme_pandominassl_apply','','run_log');">日志</p> | ||
<p onclick="apaReadme();">相关说明</p> | ||
|
||
</div> | ||
<div class="bt-w-con pd15"> | ||
<div class="soft-man-con"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript"> | ||
resetPluginWinWidth(1000); | ||
resetPluginWinHeight(550); | ||
$.getScript( "/plugins/file?name=acme_pandominassl_apply&f=js/common.js", function(){ | ||
pluginService('acme_pandominassl_apply', $('.plugin_version').attr('version')); | ||
}); | ||
</script> |
Oops, something went wrong.