update
This commit is contained in:
parent
b1dd7ea609
commit
fbe2da1cd8
|
|
@ -53,23 +53,18 @@ def get_ssh_info():
|
|||
@blueprint.route('/set_ping', endpoint='set_ping', methods=['POST'])
|
||||
@panel_login_required
|
||||
def set_ping():
|
||||
mf = MwFirewall.instance()
|
||||
return mf.setPing()
|
||||
return MwFirewall.instance().setPing()
|
||||
|
||||
# 添加放行端口
|
||||
@blueprint.route('/add_accept_port', endpoint='add_accept_port', methods=['POST'])
|
||||
@panel_login_required
|
||||
def add_accept_port():
|
||||
mf = MwFirewall.instance()
|
||||
if not mf.getFwStatus():
|
||||
return mw.returnData(False, '防火墙启动时,才能添加规则!')
|
||||
|
||||
port = request.form.get('port', '').strip()
|
||||
ps = request.form.get('ps', '').strip()
|
||||
protocol = request.form.get('protocol', '').strip()
|
||||
stype = request.form.get('type', '').strip()
|
||||
|
||||
return mf.addAcceptPort(port, ps, stype, protocol=protocol)
|
||||
return MwFirewall.instance().addAcceptPort(port, ps, stype, protocol=protocol)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,27 +35,7 @@ def list():
|
|||
p = request.form.get('p', '1')
|
||||
limit = request.form.get('limit', '10').strip()
|
||||
search = request.form.get('search', '').strip()
|
||||
|
||||
count = Tasks.query.filter_by().count()
|
||||
pagination = Tasks.query.filter_by().order_by(Tasks.id.desc()).paginate(page=int(p), per_page=int(limit))
|
||||
|
||||
rows = []
|
||||
for item in pagination.items:
|
||||
t = {}
|
||||
t['id'] = item.id
|
||||
t['name'] = item.name
|
||||
t['type'] = item.type
|
||||
t['cmd'] = item.cmd
|
||||
t['start'] = item.start
|
||||
t['end'] = item.end
|
||||
t['status'] = item.status
|
||||
t['add_time'] = item.add_time
|
||||
rows.append(t)
|
||||
|
||||
data = {}
|
||||
data['data'] = rows
|
||||
data['page'] = mw.getPage({'count':count,'tojs':'remind','p':p})
|
||||
return data
|
||||
return MwTasks.getTaskList(int(p), int(limit))
|
||||
|
||||
@blueprint.route('/get_exec_log', endpoint='get_exec_log', methods=['POST'])
|
||||
@panel_login_required
|
||||
|
|
|
|||
|
|
@ -52,8 +52,13 @@ def getTaskList(
|
|||
limit = str(start) + ',' + str(size)
|
||||
|
||||
field = 'id,name,type,start,end,status,add_time'
|
||||
data = mw.M('tasks').where('', ()).field(field).limit(limit).order('id asc').select()
|
||||
return data
|
||||
task_list = mw.M('tasks').where('', ()).field(field).limit(limit).order('id asc').select()
|
||||
count = mw.M('tasks').where('', ()).count()
|
||||
|
||||
rdata = {}
|
||||
rdata['list'] = task_list
|
||||
rdata['count'] = count
|
||||
return rdata
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -229,16 +229,16 @@ class Firewall(object):
|
|||
):
|
||||
if not self.getFwStatus():
|
||||
self.setFw(0)
|
||||
|
||||
return mw.returnData(False, '防火墙启动时,才能添加规则!')
|
||||
|
||||
rep = r"^\d{1,5}(:\d{1,5})?$"
|
||||
if not re.search(rep, port):
|
||||
return mw.returnData(False, '端口范围不正确!')
|
||||
|
||||
if model.getFirewallCountByPort(port) > 0:
|
||||
if thisdb.getFirewallCountByPort(port) > 0:
|
||||
return mw.returnData(False, '您要放行的端口已存在,无需重复放行!')
|
||||
|
||||
model.addFirewall(port, ps=ps,protocol=protocol)
|
||||
thisdb.addFirewall(port, ps=ps,protocol=protocol)
|
||||
self.addAcceptPortCmd(port, protocol=protocol)
|
||||
self.reload()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,15 @@ import pwd
|
|||
import time
|
||||
|
||||
import core.mw as mw
|
||||
import thisdb
|
||||
|
||||
def getTaskList(page=1,size=10):
|
||||
info = thisdb.getTaskList(page=page, size=size)
|
||||
|
||||
rdata = {}
|
||||
rdata['data'] = info['list']
|
||||
rdata['page'] = mw.getPage({'count':info['count'],'tojs':'remind','p':page,'row':size})
|
||||
return rdata
|
||||
|
||||
# 删除进程下的所有进程
|
||||
def removeTaskRecursion(pid):
|
||||
|
|
|
|||
Loading…
Reference in New Issue