Skip to content

Commit

Permalink
Merge pull request midoks#387 from midoks/dev
Browse files Browse the repository at this point in the history
0.13.1
  • Loading branch information
midoks authored Feb 28, 2023
2 parents 196fbbd + 422514c commit 9d9b39d
Show file tree
Hide file tree
Showing 31 changed files with 421 additions and 140 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ plugins/openlitespeed
plugins/system_safe
plugins/tamper_proof
plugins/tamper_proof_*
plugins/cryptocurrency_trade
plugins/op_load_balance
plugins/gdrive
plugins/mtproxy
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
基本上可以使用,后续会继续优化!欢迎提供意见!

- 吹水组 - https://t.me/mdserver_web
- 交流论坛 - https://bbs.midoks.me

```
如果出现问题,最好私给我面板信息。不要让我猜。如果不提供,不要提出问题,自行解决。 — 座右铭
Expand Down Expand Up @@ -98,12 +99,12 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.13.0
### 版本更新 0.13.1

* 一键迁移插件
* 修复acme ssl申请。
* IP识别优化。
* 解决删除站点残留的问题。
* 关闭issue,建立bbs.midoks.me。问题集中处理,发挥群众的力量
* 添加站操作回调钩子site_cb。 网站统计和OP防火墙不再手动重载配置
* 修复ubuntu20 pureftp 安装时,端口没有加入安全里
* 增加global_static hook关键字,并优化menu的文件加载hook
* 各种细节优化。

### JSDelivr安装地址
Expand All @@ -112,7 +113,6 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:

```
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash
```

- 直接更新
Expand Down
2 changes: 1 addition & 1 deletion class/core/cert_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ def renewCert(self, index):
self.__config['orders'][i]['auth_to'] = auth_to

# 是否到了允许重试的时间
if 'next_retry_time' in self._config['orders'][i]:
if 'next_retry_time' in self.__config['orders'][i]:
timeout = self.__config['orders'][i][
'next_retry_time'] - int(time.time())
if timeout > 0:
Expand Down
17 changes: 14 additions & 3 deletions class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class config_api:

__version = '0.13.0'
__version = '0.13.1'
__api_addr = 'data/api.json'

def __init__(self):
Expand Down Expand Up @@ -824,7 +824,9 @@ def get(self):
data['username'] = mw.M('users').where(
"id=?", (1,)).getField('username')

# databases hook 获取
data['hook_tag'] = request.args.get('tag', '')

# databases hook
database_hook_file = 'data/hook_database.json'
if os.path.exists(database_hook_file):
df = mw.readFile(database_hook_file)
Expand All @@ -833,7 +835,7 @@ def get(self):
else:
data['hook_database'] = []

# menu hook 获取
# menu hook
menu_hook_file = 'data/hook_menu.json'
if os.path.exists(menu_hook_file):
df = mw.readFile(menu_hook_file)
Expand All @@ -842,4 +844,13 @@ def get(self):
else:
data['hook_menu'] = []

# global_static hook
global_static_hook_file = 'data/hook_global_static.json'
if os.path.exists(global_static_hook_file):
df = mw.readFile(global_static_hook_file)
df = json.loads(df)
data['hook_global_static'] = df
else:
data['hook_global_static'] = []

return data
19 changes: 10 additions & 9 deletions class/core/firewall_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ def delDropAddressApi(self):
address = port
if self.__isUfw:
mw.execShell('ufw delete deny from ' + address + ' to any')
elif self.__isIptables:
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
mw.execShell(cmd)
elif self.__isFirewalld:
mw.execShell(
'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'')
elif self.__isIptables:
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
mw.execShell(cmd)
else:
pass

Expand All @@ -149,14 +149,15 @@ def delAcceptPortApi(self):
return mw.returnJson(False, '失败,不能删除当前面板端口!')
if self.__isUfw:
mw.execShell('ufw delete allow ' + port + '/tcp')
elif self.__isIptables:
mw.execShell(
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
elif self.__isFirewalld:
port = port.replace(':', '-')
mw.execShell(
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp')
mw.execShell(
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp')
elif self.__isIptables:
mw.execShell(
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
else:
pass
msg = mw.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
Expand Down Expand Up @@ -438,13 +439,13 @@ def getLogList(self, page, limit, search=''):
def addAcceptPort(self, port):
if self.__isUfw:
mw.execShell('ufw allow ' + port + '/tcp')
elif self.__isIptables:
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
mw.execShell(cmd)
elif self.__isFirewalld:
port = port.replace(':', '-')
cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp'
mw.execShell(cmd)
elif self.__isIptables:
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
mw.execShell(cmd)
else:
pass
return True
Expand Down
12 changes: 7 additions & 5 deletions class/core/plugins_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def menuApi(self):
t = mw.readFile(menu_file)
tlist = json.loads(t)
for menu_data in tlist:
if 'path' in menu_data:
if tag == menu_data['name'] and 'path' in menu_data:
tpath = self.menuGetAbsPath(tag, menu_data['path'])
content = mw.readFile(tpath)
data['plugin_content'] = content
Expand Down Expand Up @@ -256,13 +256,14 @@ def hookUninstallFile(self, hook_name, info):
data = json.loads(t)

for idx in range(len(data)):
if data[idx]['title'] == info['title'] and data[idx]['name'] == info['name']:
if data[idx]['name'] == info['name']:
data.remove(data[idx])
break
mw.writeFile(hookPath, json.dumps(data))

def hookInstall(self, info):
valid_hook = ['backup', 'database']
valid_list_hook = ['menu']
valid_list_hook = ['menu', 'global_static', 'site_cb']
if 'hook' in info:
hooks = info['hook']
for h in hooks:
Expand All @@ -280,7 +281,7 @@ def hookInstall(self, info):

def hookUninstall(self, info):
valid_hook = ['backup', 'database']
valid_list_hook = ['menu']
valid_list_hook = ['menu', 'global_static', 'site_cb']
if 'hook' in info:
hooks = info['hook']
for h in hooks:
Expand Down Expand Up @@ -795,7 +796,8 @@ def getAllListPage(self, sType='0', page=1, pageSize=10):
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
except Exception as e:
print(e)
print(json_file)
print(mw.getTracebackInfo())

start = (page - 1) * pageSize
end = start + pageSize
Expand Down
37 changes: 33 additions & 4 deletions class/core/site_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ def __init__(self):
mw.execShell("mkdir -p " + self.sslLetsDir +
" && chmod -R 755 " + self.sslLetsDir)

def runHook(self, hook_name, func_name):
# 站点操作Hook
hook_file = 'data/hook_site_cb.json'
hook_cfg = []
if os.path.exists(hook_file):
t = mw.readFile(hook_file)
hook_cfg = json.loads(t)

hook_num = len(hook_cfg)
if hook_num == 0:
return

import plugins_api
pa = plugins_api.plugins_api()

for x in range(hook_num):
hook_data = hook_cfg[x]
if func_name in hook_data:
app_name = hook_data["name"]
run_func = hook_data[func_name]['func']
# print(app_name, run_func)
pa.run(app_name, run_func)
return True

##### ----- start ----- ###
def listApi(self):
limit = request.form.get('limit', '10')
Expand Down Expand Up @@ -1272,6 +1296,7 @@ def addDomain(self, domain, webname, pid):
mw.M('domain').add('pid,name,port,addtime',
(pid, domain_name, domain_port, mw.getDate()))

self.runHook('site_cb', 'add')
return mw.returnJson(True, '域名添加成功!')

def addDirBindApi(self):
Expand Down Expand Up @@ -1401,7 +1426,7 @@ def getDirBindRewriteApi(self):
data['filename'] = filename
return mw.getJson(data)

# 修改物理路径
# 修改物理路径
def setPathApi(self):
mid = request.form.get('id', '')
path = request.form.get('path', '')
Expand Down Expand Up @@ -2530,16 +2555,18 @@ def add(self, webname, port, ps, path, version):
self.createRootDir(self.sitePath)
self.nginxAddConf()

mw.M('domain').add('pid,name,port,addtime',
(pid, self.siteName, self.sitePort, mw.getDate()))

# 添加更多域名
for domain in siteMenu['domainlist']:
self.addDomain(domain, self.siteName, pid)

mw.M('domain').add('pid,name,port,addtime',
(pid, self.siteName, self.sitePort, mw.getDate()))

data = {}
data['siteStatus'] = False
mw.restartWeb()

self.runHook('site_cb', 'add')
return mw.returnJson(True, '添加成功')

def deleteWSLogs(self, webname):
Expand Down Expand Up @@ -2608,6 +2635,8 @@ def delete(self, sid, webname, path):

mw.M('binding').where("pid=?", (sid,)).delete()
mw.restartWeb()

self.runHook('site_cb', 'delete')
return mw.returnJson(True, '站点删除成功!')

def setEndDate(self, sid, edate):
Expand Down
6 changes: 5 additions & 1 deletion plugins/gitea/hook/commit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ if [ ! -d $WEB_PATH ];then
mkdir -p $WEB_PATH
rsync -vauP --delete --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
else
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
if [ -f $GIT_PROJECT_DIR/exclude.list ];then
rsync -vauP --delete --exclude-from="$GIT_PROJECT_DIR/exclude.list" $GIT_PROJECT_DIR/ $WEB_PATH
else
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
fi
fi

sysName=`uname`
Expand Down
14 changes: 13 additions & 1 deletion plugins/op_waf/info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"hook":[
{
"tag":"site_cb",
"site_cb": {
"title":"网站统计",
"name":"op_waf",
"add":{"func":"reload"},
"update":{"func":"reload"},
"delete":{"func":"reload"}
}
}
],
"title":"OP防火墙",
"tip":"soft",
"name":"op_waf",
Expand All @@ -12,5 +24,5 @@
"home":"https://github.com/loveshell/ngx_lua_waf",
"date":"2019-04-21",
"pid": "1",
"versions": ["0.2.5"]
"versions": ["0.2.6"]
}
2 changes: 1 addition & 1 deletion plugins/openresty/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ Install_openresty()
mkdir -p ${openrestyDir}
echo '正在安装脚本文件...' > $install_tmp

# wget -O openresty-1.21.4.1.tar.gz https://openresty.org/download/openresty-1.21.4.1.tar.gz
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
wget -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz
fi


cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz

# --with-openssl=$serverPath/source/lib/openssl-1.0.2q
Expand Down
1 change: 0 additions & 1 deletion plugins/pureftp/conf/pure-ftpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ AutoRename no
AnonymousCantUpload no
MaxDiskUsage 99
CustomerProof yes
PassivePortRange 48000 50000
PIDFile {$SERVER_PATH}/pureftp/etc/pure-ftpd.pid
PureDB {$SERVER_PATH}/pureftp/etc/pureftpd.pdb

Expand Down
5 changes: 5 additions & 0 deletions plugins/pureftp/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ serverPath=$(dirname "$rootPath")

install_tmp=${rootPath}/tmp/mw_install.pl


if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi

sysName=`uname`
echo "use system: ${sysName}"

Expand Down
4 changes: 4 additions & 0 deletions plugins/rsyncd/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`


if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi

if id www &> /dev/null ;then
echo "www uid is `id -u www`"
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
Expand Down
Loading

0 comments on commit 9d9b39d

Please sign in to comment.