pull/109/head
Mr Chen 6 years ago
parent 683d107bf2
commit d546b745a6
  1. 25
      class/core/firewall_api.py
  2. 2
      route/static/app/firewall.js

@ -169,9 +169,32 @@ class firewall_api:
except: except:
isPing = True isPing = True
import system_api
panelsys = system_api.system_api()
version = panelsys.getSystemVersion()
if os.path.exists('/usr/bin/apt-get'):
if os.path.exists('/etc/init.d/sshd'):
cmd = "service sshd status | grep -P '(dead|stop)'|grep -v grep"
status = public.execShell(cmd)
else:
cmd = "service ssh status | grep -P '(dead|stop)'|grep -v grep"
status = public.execShell(cmd)
else:
if version.find(' 7.') != -1:
cmd = "systemctl status sshd.service | grep 'dead'|grep -v grep"
status = public.execShell(cmd)
else:
cmd = "/etc/init.d/sshd status | grep -e 'stopped' -e '已停'|grep -v grep"
status = public.execShell(cmd)
if len(status[0]) > 3:
status = False
else:
status = True
data = {} data = {}
data['port'] = port data['port'] = port
data['status'] = True
data['status'] = status
data['ping'] = isPing data['ping'] = isPing
if public.isAppleSystem(): if public.isAppleSystem():
data['firewall_status'] = False data['firewall_status'] = False

@ -195,7 +195,7 @@ function setMstscStatus(){
if(index > 0){ if(index > 0){
layer.msg('正在处理,请稍候...',{icon:16,time:20000}); layer.msg('正在处理,请稍候...',{icon:16,time:20000});
$.post('/firewall/set_ssh_status','status='+status,function(rdata){ $.post('/firewall/set_ssh_status','status='+status,function(rdata){
console.log(rdata); // console.log(rdata);
layer.closeAll(); layer.closeAll();
layer.msg(rdata.msg,{icon:rdata.status?1:2}); layer.msg(rdata.msg,{icon:rdata.status?1:2});
setTimeout(function(){window.location.reload();},3000); setTimeout(function(){window.location.reload();},3000);

Loading…
Cancel
Save