Skip to content

Commit

Permalink
Merge pull request #539 from midoks/dev
Browse files Browse the repository at this point in the history
0.16.5
  • Loading branch information
midoks authored Apr 15, 2024
2 parents 6d34061 + 5dca6bf commit 540fb5a
Show file tree
Hide file tree
Showing 22 changed files with 329 additions and 226 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Talk is cheap, show me the code. -- linus
```

- [兼容性测试报告](/compatibility.md)
- [常用命令说明](/cmd.md) [ mw default ]
- [常用命令说明](/cmd.md) [ mw default ] [ mw update_dev ]

### 主要插件介绍

Expand Down Expand Up @@ -110,12 +110,9 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.16.4
### 版本更新 0.16.5

* 二次验证。
* OP防火墙修复。
* 任务日志查看优化。
* 优化MySQL打开phpMyAdmin速度。
* 文件管理,增加排序。

### JSDelivr安装地址

Expand Down
99 changes: 2 additions & 97 deletions class/core/cert_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,19 +441,7 @@ def getSiteRunPathByid(self, site_id):
return None
if not os.path.exists(site_path):
return None
args = mw.dict_obj()
args.id = site_id
import panelSite
run_path = panelSite.panelSite().GetRunPath(args)
if run_path in ['/']:
run_path = ''
if run_path:
if run_path[0] == '/':
run_path = run_path[1:]
site_run_path = os.path.join(site_path, run_path)
if not os.path.exists(site_run_path):
return site_path
return site_run_path
return site_path
else:
return False

Expand Down Expand Up @@ -1283,85 +1271,6 @@ def extractZone(self, domain_name):
root = old_domain_name
return root, zone

# 获取当前正在使用此证书的网站目录
def getSslUsedSite(self, save_path):
pkey_file = '{}/privkey.pem'.format(save_path)
pkey = mw.readFile(pkey_file)
if not pkey:
return False
cert_paths = 'vhost/cert'
import panelSite
args = mw.dict_obj()
args.siteName = ''
for c_name in os.listdir(cert_paths):
skey_file = '{}/{}/privkey.pem'.format(cert_paths, c_name)
skey = mw.readFile(skey_file)
if not skey:
continue
if skey == pkey:
args.siteName = c_name
run_path = panelSite.panelSite().GetRunPath(args)
if not run_path:
continue
sitePath = mw.M('sites').where(
'name=?', c_name).getField('path')
if not sitePath:
continue
to_path = "{}/{}".format(sitePath, run_path)
return to_path
return False

def renewCertOther(self):
cert_path = "{}/vhost/cert".format(mw.getRunDir())
if not os.path.exists(cert_path):
return
new_time = time.time() + (86400 * 30)
n = 0
if not 'orders' in self.__config:
self.__config['orders'] = {}
import panelSite
siteObj = panelSite.panelSite()
args = mw.dict_obj()
for siteName in os.listdir(cert_path):
try:
cert_file = '{}/{}/fullchain.pem'.format(cert_path, siteName)
if not os.path.exists(cert_file):
continue # 无证书文件
siteInfo = mw.M('sites').where('name=?', siteName).find()
if not siteInfo:
continue # 无网站信息
cert_init = self.getCertInit(cert_file)
if not cert_init:
continue # 无法获取证书
end_time = time.mktime(time.strptime(
cert_init['notAfter'], '%Y-%m-%d'))
if end_time > new_time:
continue # 未到期
try:
if not cert_init['issuer'] in ['R3', "Let's Encrypt"] and cert_init['issuer'].find("Let's Encrypt") == -1:
continue # 非同品牌证书
except:
continue

if isinstance(cert_init['dns'], str):
cert_init['dns'] = [cert_init['dns']]
index = self.getIndex(cert_init['dns'])
if index in self.__config['orders'].keys():
continue # 已在订单列表

n += 1
writeLog(
"|-正在续签第 {} 张其它证书,域名: {}..".format(n, cert_init['subject']))
writeLog("|-正在创建订单..")
args.id = siteInfo['id']
runPath = siteObj.GetRunPath(args)
if runPath and not runPath in ['/']:
path = siteInfo['path'] + '/' + runPath
else:
path = siteInfo['path']
except:
writeLog("|-[{}]续签失败".format(siteName))

# 外部API - START ----------------------------------------------------------
def getHostConf(self, siteName):
return mw.getServerDir() + '/web_conf/nginx/vhost/' + siteName + '.conf'
Expand Down Expand Up @@ -1509,8 +1418,7 @@ def renewCert(self, index):
# 已删除的网站直接跳过续签
if self.__config['orders'][i]['auth_to'].find('|') == -1 and self.__config['orders'][i]['auth_to'].find('/') != -1:
if not os.path.exists(self.__config['orders'][i]['auth_to']):
auth_to = self.getSslUsedSite(
self.__config['orders'][i]['save_path'])
auth_to = self.__config['orders'][i]['auth_to']
if not auth_to:
continue

Expand Down Expand Up @@ -1549,9 +1457,6 @@ def renewCert(self, index):
# 加入到续签订单
order_index.append(i)
if not order_index:
writeLog("|-没有找到30天内到期的SSL证书,正在尝试去寻找其它可续签证书!")
# self.getApis()
# self.renewCertOther()
writeLog("|-所有任务已处理完成!")
return
writeLog("|-共需要续签 {} 张证书".format(len(order_index)))
Expand Down
2 changes: 1 addition & 1 deletion class/core/cert_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def getAccountKey(self):
# 注册acme帐户
def register(self, existing=False):
if not 'email' in self.__config:
self.__config['email'] = 'mdioks@163.com'
self.__config['email'] = 'xxxx.xxxx@gmail.com'
if existing:
payload = {"onlyReturnExisting": True}
elif self.__config['email']:
Expand Down
2 changes: 1 addition & 1 deletion class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class config_api:

__version = '0.16.4'
__version = '0.16.5'
__api_addr = 'data/api.json'

# 统一默认配置文件
Expand Down
77 changes: 65 additions & 12 deletions class/core/files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,12 @@ def getDirApi(self):
search = request.args.get('search', '').strip().lower()
search_all = request.args.get('all', '').strip().lower()
page = request.args.get('p', '1').strip().lower()
row = request.args.get('showRow', '10')
disk = request.form.get('disk', '')
if disk == 'True':
row = 1000
row = request.args.get('row', '10')
order = request.form.get('order', '')

# return self.getAllDir(path, int(page), int(row), "wp-inlcude")
if search_all == 'yes' and search != '':
return self.getAllDir(path, int(page), int(row), search)
return self.getDir(path, int(page), int(row), search)
return self.getAllDir(path, int(page), int(row), order, search)
return self.getDir(path, int(page), int(row), order, search)

def createFileApi(self):
file = request.form.get('path', '')
Expand Down Expand Up @@ -948,16 +945,64 @@ def getCount(self, path, search):
i += 1
return i

def getAllDir(self, path, page=1, page_size=10, search=None):
def getAllDir(self, path, page=1, page_size=10, order='', search=None):
# print("search:", search)
data = {}
dirnames = []
filenames = []

info = {}

i = 0
n = 0
count = 0
max_limit = 3000
order_arr = order.split(' ')
if len(order_arr) < 2:
plist = mw.sortAllFileList(path, order_arr[0],'',search, max_limit)
else:
plist = mw.sortAllFileList(path, order_arr[0], order_arr[1], search,max_limit)

info['count'] = len(plist)
info['row'] = page_size
info['p'] = page
info['tojs'] = 'getFiles'
pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
data['PAGE'] = pageObj[0]

for dst_file in plist:

if not os.path.exists(dst_file):
continue

i += 1
if n >= pageObj[1].ROW:
break
if i < pageObj[1].SHIFT:
continue

if os.path.isdir(dst_file):
dirnames.append(self.__get_stats(dst_file, path))
else:
filenames.append(self.__get_stats(dst_file, path))
n += 1

data['DIR'] = dirnames
data['FILES'] = filenames
data['PATH'] = path.replace('//', '/')

return mw.getJson(data)

#备份
def getAllDirBk(self, path, page=1, page_size=10, order='', search=None):
data = {}
dirnames = []
filenames = []

count = 0
max_limit = 3000
for d_list in os.walk(path):

if count >= max_limit:
break

Expand Down Expand Up @@ -996,7 +1041,7 @@ def getAllDir(self, path, page=1, page_size=10, search=None):

return mw.getJson(data)

def getDir(self, path, page=1, page_size=10, search=None):
def getDir(self, path, page=1, page_size=10, order = '', search=None):
data = {}
dirnames = []
filenames = []
Expand All @@ -1011,7 +1056,14 @@ def getDir(self, path, page=1, page_size=10, search=None):

i = 0
n = 0
for filename in os.listdir(path):

order_arr = order.split(' ')
if len(order_arr) < 2:
plist = mw.sortFileList(path, order_arr[0],'')
else:
plist = mw.sortFileList(path, order_arr[0],order_arr[1])

for filename in plist:
if search:
if filename.lower().find(search) == -1:
continue
Expand All @@ -1033,8 +1085,8 @@ def getDir(self, path, page=1, page_size=10, search=None):
n += 1
except Exception as e:
continue
data['DIR'] = sorted(dirnames)
data['FILES'] = sorted(filenames)
data['DIR'] = dirnames
data['FILES'] = filenames
data['PATH'] = path.replace('//', '/')

return mw.getJson(data)
Expand Down Expand Up @@ -1067,6 +1119,7 @@ def getExecShellMsgApi(self):
return mw.returnJson(status, mw.getNumLines(fileName, 200))

def __get_stats(self, filename, path=None):
# print(filename,path)
filename = filename.replace('//', '/')
try:
stat = os.stat(filename)
Expand Down
57 changes: 57 additions & 0 deletions class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,63 @@ def checkCert(certPath='ssl/certificate.pem'):
return True


def sortFileList(path, ftype = 'mtime', sort = 'desc'):
flist = os.listdir(path)
if ftype == 'mtime':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=False)

if ftype == 'size':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getsize(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getsize(os.path.join(path,f)), reverse=False)
return flist


def sortAllFileList(path, ftype = 'mtime', sort = 'desc', search = '',limit = 3000):
count = 0
flist = []
for d_list in os.walk(path):
if count >= limit:
break

for d in d_list[1]:
if count >= limit:
break
if d.lower().find(search) != -1:
filename = d_list[0] + '/' + d
if not os.path.exists(filename):
continue
count += 1
flist.append(filename)

for f in d_list[2]:
if count >= limit:
break

if f.lower().find(search) != -1:
filename = d_list[0] + '/' + f
if not os.path.exists(filename):
continue
count += 1
flist.append(filename)

if ftype == 'mtime':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(f), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(f), reverse=False)

if ftype == 'size':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getsize(f), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getsize(f), reverse=False)
return flist

def getPathSize(path):
# 取文件或目录大小
if not os.path.exists(path):
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/versions/10.11/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb

MY_VER=10.11.6
MY_VER=10.11.7

Install_app()
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/versions/10.6/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb

MY_VER=10.6.16
MY_VER=10.6.17

Install_app()
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/versions/11.0/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb

MY_VER=11.0.4
MY_VER=11.0.5

Install_app()
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/versions/11.1/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mariadbDir=${serverPath}/source/mariadb

MY_VER=11.1.3
MY_VER=11.1.4

Install_app()
{
Expand Down
Loading

0 comments on commit 540fb5a

Please sign in to comment.