From 2bf75f60bcdf9b3af02f73d0f630392552c7a031 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 4 Sep 2024 11:23:08 +0200 Subject: [PATCH] Cleanup --- Examples/Echo.py | 18 +++--------------- Examples/Link.py | 12 +++--------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Examples/Echo.py b/Examples/Echo.py index 8cb8264..e5b3930 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -5,7 +5,6 @@ # of the packet. # ########################################################## -import os import argparse import RNS @@ -28,19 +27,8 @@ def server(configpath): # We must first initialise Reticulum reticulum = RNS.Reticulum(configpath) - # Load identity from file if it exist or randomley create - if configpath: - ifilepath = "%s/storage/identitiesy/%s" % (configpath,APP_NAME) - else: - ifilepath = "%s/storage/identities/%s" % (RNS.Reticulum.configdir,APP_NAME) - if os.path.exists(ifilepath): - # Load identity from file - server_identity = RNS.Identity.from_file(ifilepath) - RNS.log("loaded identity from file: "+ifilepath, RNS.LOG_VERBOSE) - else: - # Randomly create a new identity for our echo example - server_identity = RNS.Identity() - RNS.log("created new identity", RNS.LOG_VERBOSE) + # Randomly create a new identity for our echo server + server_identity = RNS.Identity() # We create a destination that clients can query. We want # to be able to verify echo replies to our clients, so we @@ -340,4 +328,4 @@ if __name__ == "__main__": client(args.destination, configarg, timeout=timeoutarg) except KeyboardInterrupt: print("") - exit() + exit() \ No newline at end of file diff --git a/Examples/Link.py b/Examples/Link.py index c61458e..6b3210c 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -28,8 +28,8 @@ def server(configpath): # We must first initialise Reticulum reticulum = RNS.Reticulum(configpath) + # Randomly create a new identity for our link example server_identity = RNS.Identity() - RNS.log("created new identity", RNS.LOG_VERBOSE) # We create a destination that clients can connect to. We # want clients to create links to this destination, so we @@ -58,7 +58,7 @@ def server_loop(destination): " running, waiting for a connection." ) - RNS.log("Hit enter to manually send an announce (Ctrl-C or \"quit\" to quit)") + RNS.log("Hit enter to manually send an announce (Ctrl-C to quit)") # We enter a loop that runs until the users exits. # If the user hits enter, we will announce our server @@ -68,12 +68,6 @@ def server_loop(destination): entered = input() destination.announce() RNS.log("Sent announce from "+RNS.prettyhexrep(destination.hash)) - if entered == "quit": - if latest_client_link: - latest_client_link.teardown() - break - print("") - exit() # When a client establishes a link to our server # destination, this function will be called with @@ -294,4 +288,4 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") - exit() + exit() \ No newline at end of file