Update firewall_api.py

This commit is contained in:
Mr Chen
2019-01-26 23:34:36 +08:00
parent bf3ddbf4a5
commit 142437ea7e
+15 -1
View File
@@ -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: