mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 05:19:26 +08:00
Update firewall_api.py
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user