Skip to content

Commit

Permalink
Merge pull request #620 from midoks/dev
Browse files Browse the repository at this point in the history
0.17.2
  • Loading branch information
midoks authored Jul 26, 2024
2 parents b602ab6 + d5f5287 commit 3e51722
Show file tree
Hide file tree
Showing 117 changed files with 3,019 additions and 575 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Talk is cheap, show me the code. -- linus
### 主要插件介绍

* OpenResty - 轻量级,占有内存少,并发能力强。
* PHP[53-83] - PHP是世界上最好的编程语言。
* PHP[53-84] - PHP是世界上最好的编程语言。
* MySQL - 一种关系数据库管理系统。
* MariaDB - 是MySQL的一个重要分支。
* MySQL[APT/YUM] - 一种关系数据库管理系统。
Expand Down Expand Up @@ -75,10 +75,10 @@ Talk is cheap, show me the code. -- linus

```
phpMyAdmin[4.4.15]支持MySQL[5.5-5.7]
phpMyAdmin[5.2.0]支持MySQL[8.0]
phpMyAdmin[5.2.1]支持MySQL[8.0+]
PHP[53-72]支持phpMyAdmin[4.4.15]
PHP[72-83]支持phpMyAdmin[5.2.0]
PHP[72-84]支持phpMyAdmin[5.2.1]
```

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


### 版本更新 0.17.1
### 版本更新 0.17.2

- 任务管理器-插件。
- MySQL9.0。
- zabbix,zabbix-agent测试。
- 正则匹配修复(兼容)。
- 常规更新。

### JSDelivr安装地址

Expand Down
19 changes: 9 additions & 10 deletions class/core/cert_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def requestsPost(self, url, data, timeout):
return response
except Exception as ex:
# self.getError()
raise Exception("requestsPost: {}".format(self.getError(str(ex))))
raise Exception("异常: {}".format(self.getError(str(ex))))

def getRequestJson(self, response):
try:
Expand Down Expand Up @@ -1279,7 +1279,7 @@ def getSitePath(self, siteName):
file = self.getHostConf(siteName)
if os.path.exists(file):
conf = mw.readFile(file)
rep = '\s*root\s*(.+);'
rep = r'\s*root\s*(.+);'
path = re.search(rep, conf).groups()[0]
return path
return ''
Expand Down Expand Up @@ -1391,7 +1391,8 @@ def renewCert(self, index):
raise Exception("指定订单号不存在,无法续签!")
order_index.append(index)
else:
start_time = time.time() + (30 * 86400)
# 测试一天过期
now_time = time.time()
# print(self.__config)
if not 'orders' in self.__config:
self.__config['orders'] = {}
Expand All @@ -1402,16 +1403,14 @@ def renewCert(self, index):
continue

if 'cert' in self.__config['orders'][i]:
self.__config['orders'][i]['cert_timeout'] = self.__config[
'orders'][i]['cert']['cert_timeout']
self.__config['orders'][i]['cert_timeout'] = self.__config['orders'][i]['cert']['cert_timeout']

if not 'cert_timeout' in self.__config['orders'][i]:
self.__config['orders'][i][
'cert_timeout'] = int(time.time())
self.__config['orders'][i]['cert_timeout'] = int(time.time())

if self.__config['orders'][i]['cert_timeout'] > start_time:
msg = "|-本次跳过域名: {},未过期!".format(
self.__config['orders'][i]['domains'][0])
# print(self.__config['orders'][i]['domains'][0], (self.__config['orders'][i]['cert_timeout'] - now_time)/86400, now_time)
if self.__config['orders'][i]['cert_timeout'] - now_time > 83*86400:
msg = "|-本次跳过域名: {},未过期!".format(self.__config['orders'][i]['domains'][0])
writeLog(msg)
continue

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.17.1'
__version = '0.17.2'
__api_addr = 'data/api.json'

# 统一默认配置文件
Expand Down
22 changes: 11 additions & 11 deletions class/core/firewall_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def addDropAddressApi(self):
port = request.form.get('port', '').strip()
ps = request.form.get('ps', '').strip()

rep = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?$"
rep = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?$"
if not re.search(rep, port):
return mw.returnJson(False, '您输入的IP地址不合法!')
address = port
Expand Down Expand Up @@ -97,7 +97,7 @@ def addAcceptPortArgs(self, port, ps, stype, protocol='tcp'):
if not self.getFwStatus():
self.setFw(0)

rep = "^\d{1,5}(:\d{1,5})?$"
rep = r"^\d{1,5}(:\d{1,5})?$"
if not re.search(rep, port):
return mw.returnData(False, '端口范围不正确!')

Expand Down Expand Up @@ -217,7 +217,7 @@ def getSshInfoApi(self):

file = '/etc/ssh/sshd_config'
conf = mw.readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n"
rep = r"#*Port\s+([0-9]+)\s*\n"
port = re.search(rep, conf).groups(0)[0]

isPing = True
Expand All @@ -227,7 +227,7 @@ def getSshInfoApi(self):
else:
file = '/etc/sysctl.conf'
sys_conf = mw.readFile(file)
rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)"
rep = r"#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)"
tmp = re.search(rep, sys_conf).groups(0)[0]
if tmp == '1':
isPing = False
Expand All @@ -248,7 +248,7 @@ def getSshInfoApi(self):

data['pass_prohibit_status'] = False
# 密码登陆配置检查
pass_rep = "PasswordAuthentication\s+(\w*)\s*\n"
pass_rep = r"PasswordAuthentication\s+(\w*)\s*\n"
pass_status = re.search(pass_rep, conf)
if pass_status:
if pass_status and pass_status.groups(0)[0].strip() == 'no':
Expand Down Expand Up @@ -277,7 +277,7 @@ def setSshPortApi(self):
file = '/etc/ssh/sshd_config'
conf = mw.readFile(file)

rep = "#*Port\s+([0-9]+)\s*\n"
rep = r"#*Port\s+([0-9]+)\s*\n"
conf = re.sub(rep, "Port " + port + "\n", conf)
mw.writeFile(file, conf)

Expand Down Expand Up @@ -330,17 +330,17 @@ def setSshPassStatusApi(self):

conf = mw.readFile(file)

pass_rep = "PasswordAuthentication\s+(\w*)\s*\n"
pass_rep = r"PasswordAuthentication\s+(\w*)\s*\n"
pass_status = re.search(pass_rep, conf)
if not pass_status:
rep = "(#)?PasswordAuthentication\s+(\w*)\s*\n"
rep = r"(#)?PasswordAuthentication\s+(\w*)\s*\n"
conf = re.sub(rep, "PasswordAuthentication yes\n", conf)

if status == '1':
rep = "PasswordAuthentication\s+(\w*)\s*\n"
rep = r"PasswordAuthentication\s+(\w*)\s*\n"
conf = re.sub(rep, "PasswordAuthentication yes\n", conf)
else:
rep = "PasswordAuthentication\s+(\w*)\s*\n"
rep = r"PasswordAuthentication\s+(\w*)\s*\n"
conf = re.sub(rep, "PasswordAuthentication no\n", conf)
mw.writeFile(file, conf)
mw.execShell("systemctl restart sshd.service")
Expand All @@ -355,7 +355,7 @@ def setPingApi(self):
filename = '/etc/sysctl.conf'
conf = mw.readFile(filename)
if conf.find('net.ipv4.icmp_echo') != -1:
rep = u"net\.ipv4\.icmp_echo.*"
rep = r"net\.ipv4\.icmp_echo.*"
conf = re.sub(rep, 'net.ipv4.icmp_echo_ignore_all=' + status, conf)
else:
conf += "\nnet.ipv4.icmp_echo_ignore_all=" + status
Expand Down
2 changes: 1 addition & 1 deletion class/core/plugins_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def inputZipApi(self):
plugin_path = mw.getPluginDir() + '/' + plugin_name
if not os.path.exists(plugin_path):
print(mw.execShell('mkdir -p ' + plugin_path))
mw.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
mw.execShell("cp -rf " + tmp_path + '/* ' + plugin_path + '/')
mw.execShell('chmod -R 755 ' + plugin_path)
p_info = mw.readFile(plugin_path + '/info.json')
if p_info:
Expand Down
6 changes: 3 additions & 3 deletions class/core/site_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ def setSslConf(self, siteName):
add_header Strict-Transport-Security "max-age=63072000";
add_header Alt-Svc 'h3=":443";ma=86400';
"""
if version != '1.25.3.1':
if not version.startswith('1.25'):
http3Header = '';

sslStr = """#error_page 404/404.html;
Expand All @@ -2820,12 +2820,12 @@ def setSslConf(self, siteName):

conf = conf.replace('#error_page 404/404.html;', sslStr)

rep = "listen\s+([0-9]+)\s*[default_server]*;"
rep = "listen\s+([0-9]+)\s*[default_server|reuseport]*;"
tmp = re.findall(rep, conf)
if not mw.inArray(tmp, '443'):
listen = re.search(rep, conf).group()

if version == '1.25.3.1':
if version.startswith('1.25'):
http_ssl = "\n\tlisten 443 ssl;"
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl;"
http_ssl = http_ssl + "\n\tlisten 443 quic;"
Expand Down
12 changes: 6 additions & 6 deletions plugins/gitea/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def initDreplace():

def getRootUrl():
content = mw.readFile(getConf())
rep = 'ROOT_URL\s*=\s*(.*)'
rep = r'ROOT_URL\s*=\s*(.*)'
tmp = re.search(rep, content)
if tmp:
return tmp.groups()[0]

rep = 'EXTERNAL_URL\s*=\s*(.*)'
rep = r'EXTERNAL_URL\s*=\s*(.*)'
tmp = re.search(rep, content)
if tmp:
return tmp.groups()[0]
Expand All @@ -184,7 +184,7 @@ def getRootUrl():

def getSshPort():
content = mw.readFile(getConf())
rep = 'SSH_PORT\s*=\s*(.*)'
rep = r'SSH_PORT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -193,7 +193,7 @@ def getSshPort():

def getHttpPort():
content = mw.readFile(getConf())
rep = 'HTTP_PORT\s*=\s*(.*)'
rep = r'HTTP_PORT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -202,7 +202,7 @@ def getHttpPort():

def getRootPath():
content = mw.readFile(getConf())
rep = 'ROOT\s*=\s*(.*)'
rep = r'ROOT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -215,7 +215,7 @@ def getDbConfValue():
return {}

content = mw.readFile(conf)
rep_scope = "\[database\](.*?)\["
rep_scope = r"\[database\](.*?)\["
tmp = re.findall(rep_scope, content, re.S)

rep = '(\w*)\s*=\s*(.*)'
Expand Down
14 changes: 7 additions & 7 deletions plugins/gogs/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ def initDreplace():

def getRootUrl():
content = mw.readFile(getConf())
rep = 'ROOT_URL\s*=\s*(.*)'
rep = r'ROOT_URL\s*=\s*(.*)'
tmp = re.search(rep, content)
if tmp:
return tmp.groups()[0]

rep = 'EXTERNAL_URL\s*=\s*(.*)'
rep = r'EXTERNAL_URL\s*=\s*(.*)'
tmp = re.search(rep, content)
if tmp:
return tmp.groups()[0]
Expand All @@ -187,7 +187,7 @@ def getRootUrl():

def getSshPort():
content = mw.readFile(getConf())
rep = 'SSH_PORT\s*=\s*(.*)'
rep = r'SSH_PORT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -196,7 +196,7 @@ def getSshPort():

def getHttpPort():
content = mw.readFile(getConf())
rep = 'HTTP_PORT\s*=\s*(.*)'
rep = r'HTTP_PORT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -205,7 +205,7 @@ def getHttpPort():

def getRootPath():
content = mw.readFile(getConf())
rep = 'ROOT\s*=\s*(.*)'
rep = r'ROOT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
Expand All @@ -218,10 +218,10 @@ def getDbConfValue():
return {}

content = mw.readFile(conf)
rep_scope = "\[database\](.*?)\["
rep_scope = r"\[database\](.*?)\["
tmp = re.findall(rep_scope, content, re.S)

rep = '(\w*)\s*=\s*(.*)'
rep = r'(\w*)\s*=\s*(.*)'
tmp = re.findall(rep, tmp[0])
r = {}
for x in range(len(tmp)):
Expand Down
2 changes: 1 addition & 1 deletion plugins/keepalived/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def getPort():
conf = getServerDir() + '/keepalived.conf'
content = mw.readFile(conf)

rep = "^(" + 'port' + ')\s*([.0-9A-Za-z_& ~]+)'
rep = r"^(" + 'port' + r')\s*([.0-9A-Za-z_& ~]+)'
tmp = re.search(rep, content, re.M)
if tmp:
return tmp.groups()[1]
Expand Down
2 changes: 1 addition & 1 deletion plugins/mariadb/conf/my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

skip-name-resolve = on
skip-name-resolve = 1
#skip-networking
#skip-external-locking
#loose-skip-innodb
Expand Down
Loading

0 comments on commit 3e51722

Please sign in to comment.