diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index 3486353f9..10a930d87 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -169,9 +169,32 @@ class firewall_api: except: 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['port'] = port - data['status'] = True + + data['status'] = status data['ping'] = isPing if public.isAppleSystem(): data['firewall_status'] = False diff --git a/route/static/app/firewall.js b/route/static/app/firewall.js index befa0ba75..a6e41c069 100755 --- a/route/static/app/firewall.js +++ b/route/static/app/firewall.js @@ -195,7 +195,7 @@ function setMstscStatus(){ if(index > 0){ layer.msg('正在处理,请稍候...',{icon:16,time:20000}); $.post('/firewall/set_ssh_status','status='+status,function(rdata){ - console.log(rdata); + // console.log(rdata); layer.closeAll(); layer.msg(rdata.msg,{icon:rdata.status?1:2}); setTimeout(function(){window.location.reload();},3000);