From 84a1ab0ca39d4a4842bccf055071296a16f5509a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Schulthess?= Date: Mon, 29 Apr 2024 07:59:55 +0200 Subject: [PATCH 1/6] add option to load identity from file --- Examples/Echo.py | 18 +++++++++++++++--- Examples/Link.py | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Examples/Echo.py b/Examples/Echo.py index e5b3930..abb79ff 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -5,6 +5,7 @@ # of the packet. # ########################################################## +import os import argparse import RNS @@ -27,8 +28,19 @@ def server(configpath): # We must first initialise Reticulum reticulum = RNS.Reticulum(configpath) - # Randomly create a new identity for our echo server - server_identity = RNS.Identity() + # 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 link examples + server_identity = RNS.Identity() + RNS.log("created new identity", RNS.LOG_VERBOSE) # We create a destination that clients can query. We want # to be able to verify echo replies to our clients, so we @@ -328,4 +340,4 @@ if __name__ == "__main__": client(args.destination, configarg, timeout=timeoutarg) except KeyboardInterrupt: print("") - exit() \ No newline at end of file + exit() diff --git a/Examples/Link.py b/Examples/Link.py index 6b3210c..37de9dd 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -28,8 +28,20 @@ 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() + # 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) + RNS.log("ifilepath: %s" % ifilepath) + 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 link examples + 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 @@ -288,4 +300,4 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") - exit() \ No newline at end of file + exit() From f804ba0263bbf8720cf23d8fec369cbe46f7a65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Schulthess?= Date: Mon, 29 Apr 2024 08:04:04 +0200 Subject: [PATCH 2/6] explicit exit not needed --- Examples/Echo.py | 1 - Examples/Link.py | 1 - 2 files changed, 2 deletions(-) diff --git a/Examples/Echo.py b/Examples/Echo.py index abb79ff..fed4c5b 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -340,4 +340,3 @@ if __name__ == "__main__": client(args.destination, configarg, timeout=timeoutarg) except KeyboardInterrupt: print("") - exit() diff --git a/Examples/Link.py b/Examples/Link.py index 37de9dd..b76ce3c 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -300,4 +300,3 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") - exit() From b5556f664b8b4edfed8859bb2196376231d85be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Schulthess?= Date: Mon, 29 Apr 2024 08:07:22 +0200 Subject: [PATCH 3/6] realign with upstream --- Examples/Echo.py | 2 ++ Examples/Link.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Examples/Echo.py b/Examples/Echo.py index fed4c5b..95bfa97 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -340,3 +340,5 @@ if __name__ == "__main__": client(args.destination, configarg, timeout=timeoutarg) except KeyboardInterrupt: print("") + exit() + diff --git a/Examples/Link.py b/Examples/Link.py index b76ce3c..54efe5e 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -300,3 +300,5 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") + exit() + From b69b939d6fdf157a0547bc0af3a69ab1385f9c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Schulthess?= Date: Mon, 29 Apr 2024 08:10:48 +0200 Subject: [PATCH 4/6] realign with upstream --- Examples/Echo.py | 1 - Examples/Link.py | 1 - 2 files changed, 2 deletions(-) diff --git a/Examples/Echo.py b/Examples/Echo.py index 95bfa97..abb79ff 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -341,4 +341,3 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") exit() - diff --git a/Examples/Link.py b/Examples/Link.py index 54efe5e..37de9dd 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -301,4 +301,3 @@ if __name__ == "__main__": except KeyboardInterrupt: print("") exit() - From 12bf7977d236de8fad282815d3c8ada76f5fb79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Schulthess?= Date: Mon, 29 Apr 2024 08:25:40 +0200 Subject: [PATCH 5/6] fix comment --- Examples/Echo.py | 2 +- Examples/Link.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Echo.py b/Examples/Echo.py index abb79ff..8cb8264 100644 --- a/Examples/Echo.py +++ b/Examples/Echo.py @@ -38,7 +38,7 @@ def server(configpath): 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 link examples + # Randomly create a new identity for our echo example server_identity = RNS.Identity() RNS.log("created new identity", RNS.LOG_VERBOSE) diff --git a/Examples/Link.py b/Examples/Link.py index 37de9dd..4286003 100644 --- a/Examples/Link.py +++ b/Examples/Link.py @@ -39,7 +39,7 @@ def server(configpath): 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 link examples + # Randomly create a new identity for our link example server_identity = RNS.Identity() RNS.log("created new identity", RNS.LOG_VERBOSE) From 4b0a0668a574d42f50803a8ff43071e511976413 Mon Sep 17 00:00:00 2001 From: markqvist Date: Wed, 1 May 2024 17:50:15 +0200 Subject: [PATCH 6/6] Update Contributing.md --- Contributing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Contributing.md b/Contributing.md index 9ccebd0..0f5a95e 100644 --- a/Contributing.md +++ b/Contributing.md @@ -35,6 +35,7 @@ Pull requests have a high chance of being accepted if they are: - In alignment with the [Roadmap](./Roadmap.md) or solve an open issue or feature request - Sufficiently tested to work with all API functions, and pass the standard test suite - Functionally and conceptually complete and well-designed +- Not simply formatting or code style changes - Well-documented Even new ideas and proposals that have not been approved by a maintainer, or fall outside the established roadmap, are *occasionally* accepted - if they possess the remaining of the above qualities. If not, they will be closed and removed without comments or explanation.