Skip to content
Snippets Groups Projects
Commit f248dcc1 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

log

parent c0dbae9e
Branches
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import numpy as np
import topohub
import struct
import math
import signal
import gns3manager
# import matplotlib.pyplot as plt
......@@ -25,6 +26,8 @@ NUM_UBUNTU_BASE = 0
NUM_UBUNTU_INTERMEDIATE = 0
NUM_UBUNTU_UNCTRL = 0
is_stop_vc_server = False
#
# def process_packet(pkt):
......@@ -78,17 +81,22 @@ def send_para_server(A_raw, f, num_host, p_NAT, P_values, max_total_traffic, pro
def run_vc_server(map_connection_ubuntu_base, is_reaction):
global NUM_UBUNTU_BASE
global NUM_UBUNTU_BASE, is_stop_vc_server
map_json = json.dumps({"map_ip": map_connection_ubuntu_base, "is_reaction": is_reaction, "total_router": NUM_UBUNTU_BASE})
command_str = f"python3 {DIR}/ubuntu_base/vc_server.py '{map_json}'"
subprocess.Popen(
['xterm', '-hold', '-e', command_str],
p = subprocess.Popen(
['xterm', '-iconic', '-e', command_str],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
start_new_session=True
)
while not is_stop_vc_server:
pass
os.kill(p.pid, signal.SIGTERM)
def run_unctrl_server(map_connection_ubuntu_unctrl):
global NUM_UBUNTU_UNCTRL
......@@ -205,7 +213,7 @@ def listen_for_measurement(base_filename):
def generate_topohub_GNS3_topology():
global NUM_SWITCH, NUM_HOST, NUM_UBUNTU_BASE, NUM_UBUNTU_INTERMEDIATE, NUM_UBUNTU_UNCTRL
global NUM_SWITCH, NUM_HOST, NUM_UBUNTU_BASE, NUM_UBUNTU_INTERMEDIATE, NUM_UBUNTU_UNCTRL, is_stop_vc_server
gns3manager.PROJECT_ID, project_name = GNS3Manager.get_projectId()
user_input = input("Press enter if correct project to generate topology?")
......@@ -436,6 +444,7 @@ def generate_topohub_GNS3_topology():
GNS3Manager.stop_nodes(array_ubuntu_intermediate, "uinter_r")
GNS3Manager.stop_node(ubuntu_server.id, "u_server")
GNS3Manager.stop_nodes(array_window_hosts, "win")
is_stop_vc_server = True
# Delete project
GNS3Manager.del_project()
......
......@@ -251,7 +251,7 @@ def run_firewall_solo5_hvt(private, public):
command_str = " ".join(command)
# print(f"{command_str}")
subprocess.Popen(
['xterm', '-hold', '-e', command_str],
['xterm', '-e', command_str],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
......@@ -292,7 +292,7 @@ def run_ids_solo5_hvt(map_tap_inf_for_ids):
command_str = " ".join(command)
# process = subprocess.Popen(['gnome-terminal', '--', 'bash', '-c', command_str])
process = subprocess.Popen(
['xterm', '-hold', '-e', command_str],
['xterm', '-e', command_str],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
......@@ -303,16 +303,16 @@ def run_ids_solo5_hvt(map_tap_inf_for_ids):
def stop_ids_solo5_hvt(process):
subproc_pid = None
with os.popen(f"pgrep -f {DIR}/simple-IDS/dist/simple-ids.hvt") as proc_list:
for pid in proc_list.readlines():
subproc_pid = int(pid.strip())
if subproc_pid != process.pid:
break
# subproc_pid = None
# with os.popen(f"pgrep -f {DIR}/simple-IDS/dist/simple-ids.hvt") as proc_list:
# for pid in proc_list.readlines():
# subproc_pid = int(pid.strip())
# if subproc_pid == process.pid:
# break
# Kill the subprocess by its PID
if subproc_pid:
os.kill(subproc_pid, signal.SIGTERM)
# if subproc_pid:
os.kill(process.pid, signal.SIGTERM)
# print(f"----------------- Stopped the IDS with PID {subproc_pid}. -----------------")
# else:
# print("----------------- No child process found to kill. -----------------")
......
......@@ -81,7 +81,7 @@ def check_local_packet(pkt):
print("Decision found, blocking:", socket.inet_ntoa(entry['addition_info']))
FirewallOpportunistic.firewall_queue.put((entry['inter_num'], socket.inet_ntoa(entry['addition_info']), entry['cmd']))
else:
print("DROP found but not me:", entry["node_id"], "and", if_utils.my_id)
print("Decision found for:", entry["node_id"], "not for me:", if_utils.my_id)
def process_opportunistic_node():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment