This commit is contained in:
Mark Qvist 2024-09-04 11:23:08 +02:00
parent 3f64141455
commit 2bf75f60bc
2 changed files with 6 additions and 24 deletions

View File

@ -5,7 +5,6 @@
# of the packet. # # of the packet. #
########################################################## ##########################################################
import os
import argparse import argparse
import RNS import RNS
@ -28,19 +27,8 @@ def server(configpath):
# We must first initialise Reticulum # We must first initialise Reticulum
reticulum = RNS.Reticulum(configpath) reticulum = RNS.Reticulum(configpath)
# Load identity from file if it exist or randomley create # Randomly create a new identity for our echo server
if configpath: server_identity = RNS.Identity()
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)
# We create a destination that clients can query. We want # We create a destination that clients can query. We want
# to be able to verify echo replies to our clients, so we # to be able to verify echo replies to our clients, so we

View File

@ -28,8 +28,8 @@ def server(configpath):
# We must first initialise Reticulum # We must first initialise Reticulum
reticulum = RNS.Reticulum(configpath) reticulum = RNS.Reticulum(configpath)
# Randomly create a new identity for our link example
server_identity = RNS.Identity() server_identity = RNS.Identity()
RNS.log("created new identity", RNS.LOG_VERBOSE)
# We create a destination that clients can connect to. We # We create a destination that clients can connect to. We
# want clients to create links to this destination, so we # want clients to create links to this destination, so we
@ -58,7 +58,7 @@ def server_loop(destination):
" running, waiting for a connection." " 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. # We enter a loop that runs until the users exits.
# If the user hits enter, we will announce our server # If the user hits enter, we will announce our server
@ -68,12 +68,6 @@ def server_loop(destination):
entered = input() entered = input()
destination.announce() destination.announce()
RNS.log("Sent announce from "+RNS.prettyhexrep(destination.hash)) 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 # When a client establishes a link to our server
# destination, this function will be called with # destination, this function will be called with