From 142437ea7e0cd75fb7d011ba2da0a7e6a7e6601c Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 26 Jan 2019 23:34:36 +0800 Subject: [PATCH] Update firewall_api.py --- class/core/firewall_api.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index 23eabe1a3..40f60639f 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -39,10 +39,24 @@ class firewall_api: rep = "#*Port\s+([0-9]+)\s*\n" port = re.search(rep, conf).groups(0)[0] + isPing = True + try: + if public.isAppleSystem(): + isPing = True + else: + file = '/etc/sysctl.conf' + conf = public.readFile(file) + rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)" + tmp = re.search(rep, conf).groups(0)[0] + if tmp == '1': + isPing = False + except: + isPing = True + data = {} data['port'] = port data['status'] = True - data['ping'] = True + data['ping'] = isPing if public.isAppleSystem(): data['firewall_status'] = False else: