Skip to content

Commit

Permalink
Merge pull request #368 from midoks/dev
Browse files Browse the repository at this point in the history
0.12.3
  • Loading branch information
midoks authored Feb 14, 2023
2 parents a207215 + 96d0115 commit 628175a
Show file tree
Hide file tree
Showing 73 changed files with 1,845 additions and 692 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,15 @@ data/basic_auth.json
data/api.json
data/bind_domain.pl

plugins/vip_*
plugins/own_*
plugins/my_*
plugins/l2tp
plugins/openlitespeed
plugins/migration_api
plugins/system_safe
plugins/tamper_proof
plugins/tamper_proof_*
plugins/op_load_balance
plugins/gdrive
plugins/mtproxy
plugins/zimg
Expand All @@ -171,3 +175,4 @@ plugins/file_search
debug.out


data/unauthorized_status.pl
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
基本上可以使用,后续会继续优化!欢迎提供意见!

- 吹水组 - https://t.me/mdserver_web

```
如果出现问题,最好私给我面板信息。不要让我猜。如果不提供,不要提出问题,自行解决。 — 座右铭
Talk is cheap, show me the code. -- linus
```

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

Expand All @@ -38,6 +44,7 @@
* PHP[53-82] - PHP是世界上最好的编程语言。
* MySQL - 一种关系数据库管理系统。
* MariaDB - 是MySQL的一个重要分支。
* MySQL[APT/YUM] - 一种关系数据库管理系统。
* MongoDB - 一种非关系NOSQL数据库管理系统。
* phpMyAdmin - 著名Web端MySQL管理工具。
* Memcached - 一个高性能的分布式内存对象缓存系统。
Expand Down Expand Up @@ -84,27 +91,24 @@ PHP[72-81]支持phpMyAdmin[5.2.0]
# Docker

-[DDSRem](https://github.com/DDSRem)开发维护。
- https://hub.docker.com/r/ddsderek/mw-server
- https://hub.docker.com/r/ddsderek/mw

```
docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:443 -p 888:888 ddsderek/mw-server:latest
```


### 版本更新 0.12.2
### 版本更新 0.12.3

* 开放菜单权限配置。
* 升级SSH终端2.0。
* 增加已安装类型。
* 加入切换linux软件源的命令。
* iptables安装优化。
* 网站统计POST获取数据优化。
* mysql[apt/yum]迁移优化。
* 优化防火墙导入。
* 图标可设置。
* 优先使用firewalld防火墙。
* PHP[APT]加入curl扩展。
* 配置添加【未认证响应状态】功能。
* 存在ipv6时,启动时强制开启。
* OP防火墙-性能优化。
* 网站统计优化。
* 优化backup_ftp插件。
* 各种细节优化。


### JSDelivr安装地址

- 初始安装
Expand Down
46 changes: 43 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.12.2'
__version = '0.12.3'
__api_addr = 'data/api.json'

def __init__(self):
Expand Down Expand Up @@ -647,9 +647,22 @@ def checkPanelToken(self):
else:
return False, ''

def setStatusCodeApi(self):
status_code = request.form.get('status_code', '').strip()
if re.match("^\d+$", status_code):
status_code = int(status_code)
if status_code != 0:
if status_code < 100 or status_code > 999:
return mw.returnJson(False, '状态码范围错误!')
else:
return mw.returnJson(False, '状态码范围错误!')

mw.writeFile('data/unauthorized_status.pl', str(status_code))
mw.writeLog('面板设置', '将未授权响应状态码设置为:{}'.format(status_code))
return mw.returnJson(True, '设置成功!')

def getPanelTokenApi(self):
api_file = self.__api_addr

tmp = mw.readFile(api_file)
if not os.path.exists(api_file):
ready_data = {"open": False, "token": "", "limit_addr": []}
Expand All @@ -668,7 +681,7 @@ def getPanelTokenApi(self):
token = mw.getRandomString(32)
data['token'] = mw.md5(token)
data['token_crypt'] = mw.enCrypt(
data['token'], token).decode('utf-8')
data['token'], token)
mw.writeFile(api_file, json.dumps(data))
data['token'] = "***********************************"

Expand Down Expand Up @@ -714,6 +727,31 @@ def setPanelTokenApi(self):
mw.writeFile(api_file, json.dumps(data))
return mw.returnJson(True, '保存成功!')

def renderUnauthorizedStatus(self, data):
cfg_unauth_status = 'data/unauthorized_status.pl'
if os.path.exists(cfg_unauth_status):
status_code = mw.readFile(cfg_unauth_status)
data['status_code'] = status_code
data['status_code_msg'] = status_code
if status_code == '0':
data['status_code_msg'] = "默认-安全入口错误提示"
elif status_code == '400':
data['status_code_msg'] = "400-客户端请求错误"
elif status_code == '401':
data['status_code_msg'] = "401-未授权访问"
elif status_code == '403':
data['status_code_msg'] = "403-拒绝访问"
elif status_code == '404':
data['status_code_msg'] = "404-页面不存在"
elif status_code == '408':
data['status_code_msg'] = "408-客户端超时"
elif status_code == '416':
data['status_code_msg'] = "416-无效的请求"
else:
data['status_code'] = '0'
data['status_code_msg'] = "默认-安全入口错误提示"
return data

def get(self):

data = {}
Expand Down Expand Up @@ -766,6 +804,8 @@ def get(self):
else:
data['bind_domain'] = ''

data = self.renderUnauthorizedStatus(data)

api_token = self.__api_addr
if os.path.exists(api_token):
bac = mw.readFile(api_token)
Expand Down
72 changes: 21 additions & 51 deletions class/core/files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,70 +677,40 @@ def getBody(self, path):
if os.path.getsize(path) > 2097152:
return mw.returnJson(False, '不能在线编辑大于2MB的文件!')

if os.path.isdir(path):
return mw.returnJson(False, '这不是一个文件!')

fp = open(path, 'rb')
data = {}
data['status'] = True
try:
if fp:
from chardet.universaldetector import UniversalDetector
detector = UniversalDetector()
srcBody = b""
for line in fp.readlines():
detector.feed(line)
srcBody += line
detector.close()
char = detector.result
data['encoding'] = char['encoding']
if char['encoding'] == 'GB2312' or not char['encoding'] or char[
'encoding'] == 'TIS-620' or char['encoding'] == 'ISO-8859-9':
data['encoding'] = 'GBK'
if char['encoding'] == 'ascii' or char[
'encoding'] == 'ISO-8859-1':
data['encoding'] = 'utf-8'
if char['encoding'] == 'Big5':
data['encoding'] = 'BIG5'

if not data['encoding'] in ['GBK', 'utf-8', 'BIG5']:
data['encoding'] = 'utf-8'
if fp:
srcBody = fp.read()
fp.close()

encoding_list = ['utf-8', 'GBK', 'BIG5']
for el in encoding_list:
try:
if sys.version_info[0] == 2:
data['data'] = srcBody.decode(
data['encoding']).encode('utf-8', errors='ignore')
else:
data['data'] = srcBody.decode(data['encoding'])
except:
data['encoding'] = char['encoding']
if sys.version_info[0] == 2:
data['data'] = srcBody.decode(
data['encoding']).encode('utf-8', errors='ignore')
else:
data['data'] = srcBody.decode(data['encoding'])
return mw.returnJson(True, 'OK', data)
else:
if sys.version_info[0] == 2:
data['data'] = srcBody.decode('utf-8').encode('utf-8')
else:
data['data'] = srcBody.decode('utf-8')
data['encoding'] = 'utf-8'
data['encoding'] = el
data['data'] = srcBody.decode(data['encoding'])
break
except Exception as ex:
if el == 'BIG5':
return mw.returnJson(False, '文件编码不被兼容,无法正确读取文件!' + str(ex))
else:
return mw.returnJson(False, '文件未正常打开!')

return mw.returnJson(True, 'OK', data)
except Exception as ex:
return mw.returnJson(False, '文件编码不被兼容,无法正确读取文件!' + str(ex))
return mw.returnJson(True, 'OK', data)

def saveBody(self, path, data, encoding='utf-8'):
if not os.path.exists(path):
return mw.returnJson(False, '文件不存在')
try:
if encoding == 'ascii':
encoding = 'utf-8'
if sys.version_info[0] == 2:
data = data.encode(encoding, errors='ignore')
fp = open(path, 'w+')
else:
data = data.encode(
encoding, errors='ignore').decode(encoding)
fp = open(path, 'w+', encoding=encoding)

data = data.encode(
encoding, errors='ignore').decode(encoding)
fp = open(path, 'w+', encoding=encoding)
fp.write(data)
fp.close()

Expand Down
8 changes: 4 additions & 4 deletions class/core/firewall_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class firewall_api:

def __init__(self):
iptables_file = mw.systemdCfgDir() + '/iptables.service'
if os.path.exists(iptables_file):
self.__isIptables = True
if os.path.exists('/usr/sbin/firewalld'):
self.__isFirewalld = True
if os.path.exists('/usr/sbin/ufw'):
elif os.path.exists(iptables_file):
self.__isIptables = True
elif os.path.exists('/usr/sbin/ufw'):
self.__isUfw = True
if mw.isAppleSystem():
elif mw.isAppleSystem():
self.__isMac = True

##### ----- start ----- ###
Expand Down
Loading

0 comments on commit 628175a

Please sign in to comment.