This commit is contained in:
Mr Chen
2018-12-25 16:56:57 +08:00
parent 4df0859734
commit 3e705b02cf
15 changed files with 389 additions and 636 deletions
+35
View File
@@ -9,12 +9,47 @@ import re
import json
import pwd
from flask import request
class firewall_api:
def __init__(self):
pass
##### ----- start ----- ###
def getWwwPathApi(self):
path = public.getLogsDir()
return public.getJson({'path': path})
def getListApi(self):
p = request.form.get('p', '1').strip()
limit = request.form.get('limit', '10').strip()
return self.getList(int(p), int(limit))
def getLogListApi(self):
p = request.form.get('p', '1').strip()
limit = request.form.get('limit', '10').strip()
search = request.form.get('search', '').strip()
return self.getLogList(int(p), int(limit), search)
def getSshInfo(self):
file = '/etc/ssh/sshd_config'
conf = public.readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n"
port = re.search(rep, conf).groups(0)[0]
data = {}
data['port'] = port
data['status'] = True
data['ping'] = True
if public.isAppleSystem():
data['firewall_status'] = False
else:
data['firewall_status'] = True
return public.getJson(data)
##### ----- start ----- ###
def getList(self, page, limit):
start = (page - 1) * limit