mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -27,7 +27,7 @@ from flask import request
|
||||
|
||||
class config_api:
|
||||
|
||||
__version = '0.16.1'
|
||||
__version = '0.16.1.1'
|
||||
__api_addr = 'data/api.json'
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -89,7 +89,7 @@ class firewall_api:
|
||||
return mw.getJson(data)
|
||||
|
||||
# 添加放行端口
|
||||
def addAcceptPortArgs(self, port, ps, stype):
|
||||
def addAcceptPortArgs(self, port, ps, stype, protocol='tcp'):
|
||||
import re
|
||||
import time
|
||||
|
||||
@@ -106,9 +106,10 @@ class firewall_api:
|
||||
msg = mw.getInfo('放行端口[{1}]成功', (port,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
addtime = time.strftime('%Y-%m-%d %X', time.localtime())
|
||||
mw.M('firewall').add('port,ps,addtime', (port, ps, addtime))
|
||||
mw.M('firewall').add('port,protocol,ps,addtime',
|
||||
(port, protocol, ps, addtime))
|
||||
|
||||
self.addAcceptPort(port)
|
||||
self.addAcceptPort(port, protocol)
|
||||
self.firewallReload()
|
||||
return mw.returnData(True, '添加放行(' + port + ')端口成功!')
|
||||
|
||||
@@ -406,7 +407,7 @@ class firewall_api:
|
||||
data['page'] = mw.getPage(_page)
|
||||
return mw.getJson(data)
|
||||
|
||||
def addAcceptPort(self, port):
|
||||
def addAcceptPort(self, port, protocol='tcp'):
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw allow ' + port + '/tcp')
|
||||
elif self.__isFirewalld:
|
||||
|
||||
@@ -316,6 +316,7 @@ function addAcceptPort(){
|
||||
var type = $("#firewalldType").val();
|
||||
var port = $("#AcceptPort").val();
|
||||
var ps = $("#Ps").val();
|
||||
var protocol = $('select[name="protocol"]').val();
|
||||
var action = "add_drop_address";
|
||||
if(type == 'port'){
|
||||
ports = port.split(':');
|
||||
@@ -335,7 +336,7 @@ function addAcceptPort(){
|
||||
return;
|
||||
}
|
||||
var loadT = layer.msg('正在添加,请稍候...',{icon:16,time:0,shade: [0.3, '#000']})
|
||||
$.post('/firewall/'+action,'port='+port+"&ps="+ps+'&type='+type,function(rdata){
|
||||
$.post('/firewall/'+action,'port='+port+"&ps="+ps+'&type='+type+'&protocol='+protocol,function(rdata){
|
||||
layer.close(loadT);
|
||||
if(rdata.status == true || rdata.status == 'true'){
|
||||
layer.msg(rdata.msg,{icon:1});
|
||||
|
||||
Reference in New Issue
Block a user