Submodule integration success

This commit is contained in:
infidel
2023-10-30 23:10:45 +07:00
parent 2e6f695b5a
commit 56fc619696
4 changed files with 116 additions and 8 deletions

View File

@@ -91,11 +91,11 @@ def struct_process():
def line_process():
path = os.getcwd()
log_file = "example/iptables.log"
log_file = "wg_api/iptable_parser/example/iptables.log"
p_file = open(os.path.join(path, log_file))
p_lines = p_file.readlines()
clibrary = ctypes.CDLL(os.path.join(path, 'lib/parser_lib.so'))
clibrary = ctypes.CDLL(os.path.join(path, 'wg_api/iptable_parser/lib/parser_lib.so'))
clibrary.main.restype = ctypes.POINTER(LogData)
clibrary.line_parse.restype = ctypes.POINTER(LogData)
clibrary.line_parse.argtype = ctypes.c_char_p
@@ -157,10 +157,11 @@ def line_process():
"DestinationPort": dst_port,
"Protocol": proto
}
nodes.append(src_ip)
nodes.append(dst_ip)
edges.append((src_ip, dst_ip))
json_dump.append(tmp_data)
if (tag != "VPN-REG"):
nodes.append({'id':src_ip, 'label': src_ip})
nodes.append({'id':dst_ip, 'label': dst_ip})
edges.append({'id': src_ip+"-"+dst_ip, 'source':src_ip, 'target': dst_ip, 'label': src_port+"->"+dst_port if proto != "ICMP" else "ICMP"})
json_dump.append(tmp_data)
nodes = get_uniq(nodes)
edges = get_uniq(edges)
@@ -172,15 +173,18 @@ def line_process():
return nodes, edges
def get_uniq(list):
id_list = []
uniq_list = []
for x in list:
if x not in uniq_list:
if (x not in uniq_list) and (x['id'] not in id_list):
id_list.append(x['id'])
uniq_list.append(x)
print("-"*50)
for x in uniq_list:
print(x)
print("-"*50)
return uniq_list