|
|
|
@ -54,9 +54,31 @@ class Firewall(object): |
|
|
|
|
|
|
|
|
|
def AIF_Firewalld(self): |
|
|
|
|
# firewall-cmd --list-all | grep ' ports' |
|
|
|
|
data = mw.execShell("firewall-cmd --list-all | grep ' ports'") |
|
|
|
|
all_port = data[0].strip() |
|
|
|
|
print(all_port) |
|
|
|
|
t = mw.execShell("firewall-cmd --list-all | grep ' ports'") |
|
|
|
|
all_port = t[0].strip() |
|
|
|
|
data = all_port.split(":") |
|
|
|
|
ports_str = data[1] |
|
|
|
|
ports_list = ports_str.strip().split(' ') |
|
|
|
|
|
|
|
|
|
ports_all = [] |
|
|
|
|
for pinfo in ports_list: |
|
|
|
|
info = pinfo.split('/') |
|
|
|
|
|
|
|
|
|
is_same = False |
|
|
|
|
for i in range(len(ports_all)): |
|
|
|
|
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 = True |
|
|
|
|
|
|
|
|
|
if not is_same: |
|
|
|
|
t = {} |
|
|
|
|
t['port'] = info[0] |
|
|
|
|
t['protocol'] = info[1] |
|
|
|
|
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 getList(self, page=1,size=10): |
|
|
|
|
info = thisdb.getFirewallList(page=page, size=size) |
|
|
|
|