diff --git a/Utilities/create_node.py b/Utilities/create_node.py new file mode 100644 index 0000000..ef86dd0 --- /dev/null +++ b/Utilities/create_node.py @@ -0,0 +1,43 @@ +import subprocess + +def main(): + for i in range(100): + node_add(i) + node_connect(i, i + 1) + +def node_add(node_id): + config = f""" +[reticulum] + +enable_transport = True + +share_instance = Yes +shared_instance_port = {30000 + node_id} +instance_control_port = {40000 + node_id} + +[interfaces] + +[[Standard Server Interface]] +type = TCPServerInterface +interface_enabled = True +listen_ip = localhost +listen_port = {50000 + node_id} +""" + subprocess.run(["mkdir", "-p", f"nodes/{node_id}"]) + + with open(f"nodes/{node_id}/config", "w+") as file: + file.write(config) + +def node_connect(node1, node2): + with open(f"nodes/{node1}/config", "a") as file: + file.write(f""" +[[Connected to Node: {node2}]] +type = TCPClientInterface +interface_enabled = True +target_host = localhost +target_port = {50000 + node2} +#END +""") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/Utilities/start_nodes.sh b/Utilities/start_nodes.sh new file mode 100644 index 0000000..41dc3fa --- /dev/null +++ b/Utilities/start_nodes.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +mkdir -p nodes + +cd nodes + +for dir in *; do + rnsd --config $dir & +done + +wait \ No newline at end of file diff --git a/util/rnssim.py b/util/rnssim.py deleted file mode 100644 index b17e81b..0000000 --- a/util/rnssim.py +++ /dev/null @@ -1,73 +0,0 @@ -import subprocess -import os -import threading -import time - -node_state = {} - -def main(): - if not os.path.exists("nodes"): - os.mkdir("nodes") - - os.chdir("nodes") - watchdog_thread = threading.Thread(target=watchdog) - watchdog_thread.start() - - node_add(1) - node_add(2) - node_add(3) - node_add(4) - node_add(5) - -def watchdog(): - while True: - for node_id in os.listdir(): - if not node_id in node_state: - node_state[node_id] = { - 'active': False, - 'stdout': None - } - - if not node_state[node_id]["active"]: - rnsd_thread = threading.Thread(target=rnsd, args=(node_id,)) - rnsd_thread.start() - - print(node_state) - time.sleep(1) - -def rnsd(node_id): - node_state[node_id]["active"] = True - subprocess.run(f"cd {node_id} && rnsd --config ./", shell=True, stdout=node_state[node_id]['stdout']) - node_state[node_id]["active"] = False - -def node_add(node_id: int): - config = f""" - [reticulum] - - enable_transport = False - - share_instance = Yes - shared_instance_port = {37428 + node_id} - instance_control_port = {38429 + node_id} - - [interfaces] - - [[Autogenerated TCP Server Interface]] - type = TCPServerInterface - interface_enabled = True - listen_ip = localhost - listen_port = {42069 + node_id} - """ - node_id = str(node_id) - - if not os.path.exists(node_id): - os.mkdir(node_id) - - with open(node_id + "/config", "w+") as file: - file.write(config) - -def node_connect(node1, node2): - pass - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/util/watchdog.py b/util/watchdog.py deleted file mode 100644 index 5ad45ef..0000000 --- a/util/watchdog.py +++ /dev/null @@ -1,21 +0,0 @@ -import os, subprocess, threading - -test = '' - -def main(): - if not os.path.exists("nodes"): - os.mkdir("nodes") - - os.chdir("nodes") - - for node_id in os.listdir(): - t = threading.Thread(target=daemon, args=(node_id)) - t.start() - - -def daemon(node_id): - with open(f"{node_id}.log") as f: - subprocess.run(f"cd {node_id} && rnsd --config ./", shell=True, capture_output=True) - -if __name__ == "__main__": - main() \ No newline at end of file