mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
u
This commit is contained in:
+65
-13
@@ -26,18 +26,6 @@ class firewall_api:
|
||||
if public.isAppleSystem():
|
||||
self.__isMac = True
|
||||
|
||||
def firewallReload(self):
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw reload')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('firewall-cmd --reload')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables restart')
|
||||
|
||||
##### ----- start ----- ###
|
||||
# 添加屏蔽IP
|
||||
def addDropAddressApi(self):
|
||||
@@ -197,7 +185,7 @@ class firewall_api:
|
||||
if public.isAppleSystem():
|
||||
data['firewall_status'] = False
|
||||
else:
|
||||
data['firewall_status'] = True
|
||||
data['firewall_status'] = self.getFwStatus()
|
||||
return public.getJson(data)
|
||||
|
||||
def setPingApi(self):
|
||||
@@ -218,6 +206,36 @@ class firewall_api:
|
||||
public.execShell('sysctl -p')
|
||||
return public.returnJson(True, '设置成功!')
|
||||
|
||||
def setFirewailApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发机不能设置!')
|
||||
|
||||
status = request.form.get('status', '1')
|
||||
if status == '1':
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw stop')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('firewall-cmd --stop')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables stop')
|
||||
else:
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw start')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('firewall-cmd --reload')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables restart')
|
||||
|
||||
return public.returnJson(True, '设置成功!')
|
||||
|
||||
def delPanelLogsApi(self):
|
||||
public.M('logs').where('id>?', (0,)).delete()
|
||||
public.writeLog('面板设置', '面板操作日志已清空!')
|
||||
@@ -264,3 +282,37 @@ class firewall_api:
|
||||
|
||||
data['page'] = public.getPage(_page)
|
||||
return public.getJson(data)
|
||||
|
||||
def firewallReload(self):
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw reload')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('firewall-cmd --reload')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables restart')
|
||||
|
||||
def getFwStatus(self):
|
||||
if self.__isUfw:
|
||||
data = public.execShell(
|
||||
"ps -ef|grep ufw |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
if self.__isFirewalld:
|
||||
data = public.execShell(
|
||||
"ps -ef|grep firewalld |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
elif self.__isMac:
|
||||
return False
|
||||
else:
|
||||
data = public.execShell(
|
||||
"ps -ef|grep iptables |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -151,7 +151,7 @@ function ping(status){
|
||||
*/
|
||||
function firewall(status){
|
||||
var msg = status == 1 ? '禁用防火墙会增加服务器不安全性,您真的要禁用防火墙吗?' : '开启防火墙,增加服务器安全!';
|
||||
layer.confirm(msg,{title:'是否禁ping',closeBtn:2,cancel:function(){
|
||||
layer.confirm(msg,{title:'是否开启防火墙!',closeBtn:2,cancel:function(){
|
||||
if(status == 1){
|
||||
$("#noping").prop("checked",true);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user