Update firewall.py

pull/632/head
Mr Chen 6 months ago
parent f040b590d5
commit c66ad2b7fb
  1. 47
      web/utils/firewall.py

@ -60,32 +60,27 @@ class Firewall(object):
if t[1] != '': if t[1] != '':
return True return True
print(t) all_port = t[0].strip()
ports_list = all_port.split('\n')
# all_port = t[0].strip()
# data = all_port.split(":") ports_all = []
# ports_str = data[1] for pinfo in ports_list:
# ports_list = ports_str.strip().split(' ') info = pinfo.split('/')
# ports_all = [] is_same = False
# for pinfo in ports_list: for i in range(len(ports_all)):
# info = pinfo.split('/') if ports_all[i]['port'] == info[0] and ports_all[i]['protocol'] != info[1]:
ports_all[i]['protocol'] = ports_all[i]['protocol']+'/'+info[1]
# is_same = False is_same = True
# for i in range(len(ports_all)):
# if ports_all[i]['port'] == info[0] and ports_all[i]['protocol'] != info[1]: if not is_same:
# ports_all[i]['protocol'] = ports_all[i]['protocol']+'/'+info[1] t = {}
# is_same = True t['port'] = info[0].replace('-',':')
t['protocol'] = info[1]
# if not is_same: ports_all.append(t)
# t = {} for add_info in ports_all:
# t['port'] = info[0].replace('-',':') if thisdb.getFirewallCountByPort(add_info['port']) == 0:
# t['protocol'] = info[1] thisdb.addFirewall(add_info['port'], ps='自动识别',protocol=add_info['protocol'])
# ports_all.append(t)
# for add_info in ports_all:
# if thisdb.getFirewallCountByPort(add_info['port']) == 0:
# thisdb.addFirewall(add_info['port'], ps='自动识别',protocol=add_info['protocol'])
def AIF_Firewalld(self): def AIF_Firewalld(self):
# firewall-cmd --list-all | grep ' ports' # firewall-cmd --list-all | grep ' ports'

Loading…
Cancel
Save